Skip to content

Commit

Permalink
Changes based on PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amsanghi committed Dec 23, 2024
1 parent e93d7ca commit 429b0c9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions execution/gethexec/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,24 +334,26 @@ func (api *ArbTraceForwarderAPI) forward(ctx context.Context, method string, arg
return resp, nil
}

func (api *ArbTraceForwarderAPI) ClipToPostNitroGenesis(blockNumOrHash json.RawMessage) (json.RawMessage, error) {
func (api *ArbTraceForwarderAPI) blockSupportedByClassicNode(blockNumOrHash json.RawMessage) error {
var bnh rpc.BlockNumberOrHash
err := bnh.UnmarshalJSON(blockNumOrHash)
if err != nil {
return nil, err
return err
}
blockNum, isNum := bnh.Number()
if !isNum {
return blockNumOrHash, nil
return nil
}
blockNum, _ = api.blockchain.ClipToPostNitroGenesis(blockNum)
bnh.BlockNumber = &blockNum
return json.Marshal(bnh)
if blockNum < 0 || blockNum > rpc.BlockNumber(api.blockchain.Config().ArbitrumChainParams.GenesisBlockNum) {
return fmt.Errorf("block number %v is not supported by classic node", blockNum)
}
return nil
}

func (api *ArbTraceForwarderAPI) Call(ctx context.Context, callArgs json.RawMessage, traceTypes json.RawMessage, blockNumOrHash json.RawMessage) (*json.RawMessage, error) {
var err error

Check failure on line 355 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 355 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 355 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 355 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 355 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

S1021: should merge variable declaration with assignment on next line (gosimple)
blockNumOrHash, err = api.ClipToPostNitroGenesis(blockNumOrHash)
err = api.blockSupportedByClassicNode(blockNumOrHash)
if err != nil {
return nil, err
}
Expand All @@ -360,7 +362,7 @@ func (api *ArbTraceForwarderAPI) Call(ctx context.Context, callArgs json.RawMess

func (api *ArbTraceForwarderAPI) CallMany(ctx context.Context, calls json.RawMessage, blockNumOrHash json.RawMessage) (*json.RawMessage, error) {
var err error

Check failure on line 364 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 364 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 364 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 364 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 364 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

S1021: should merge variable declaration with assignment on next line (gosimple)
blockNumOrHash, err = api.ClipToPostNitroGenesis(blockNumOrHash)
err = api.blockSupportedByClassicNode(blockNumOrHash)
if err != nil {
return nil, err
}
Expand All @@ -369,7 +371,7 @@ func (api *ArbTraceForwarderAPI) CallMany(ctx context.Context, calls json.RawMes

func (api *ArbTraceForwarderAPI) ReplayBlockTransactions(ctx context.Context, blockNumOrHash json.RawMessage, traceTypes json.RawMessage) (*json.RawMessage, error) {
var err error

Check failure on line 373 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 373 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 373 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 373 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

S1021: should merge variable declaration with assignment on next line (gosimple)

Check failure on line 373 in execution/gethexec/api.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

S1021: should merge variable declaration with assignment on next line (gosimple)
blockNumOrHash, err = api.ClipToPostNitroGenesis(blockNumOrHash)
err = api.blockSupportedByClassicNode(blockNumOrHash)
if err != nil {
return nil, err
}
Expand All @@ -390,7 +392,7 @@ func (api *ArbTraceForwarderAPI) Get(ctx context.Context, txHash json.RawMessage

func (api *ArbTraceForwarderAPI) Block(ctx context.Context, blockNumOrHash json.RawMessage) (*json.RawMessage, error) {
var err error
blockNumOrHash, err = api.ClipToPostNitroGenesis(blockNumOrHash)
err = api.blockSupportedByClassicNode(blockNumOrHash)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 429b0c9

Please sign in to comment.