diff --git a/chain/types/ethtypes/eth_types.go b/chain/types/ethtypes/eth_types.go index f157c7f94c5..02b0012be6e 100644 --- a/chain/types/ethtypes/eth_types.go +++ b/chain/types/ethtypes/eth_types.go @@ -548,12 +548,12 @@ func (h EthSubscriptionID) String() string { } type EthFilterSpec struct { - // Interpreted as an epoch or one of "latest" for last mined block, "earliest" for first, + // Interpreted as an epoch (in hex) or one of "latest" for last mined block, "earliest" for first, // "pending" for not yet committed messages. // Optional, default: "latest". FromBlock *string `json:"fromBlock,omitempty"` - // Interpreted as an epoch or one of "latest" for last mined block, "earliest" for first, + // Interpreted as an epoch (in hex) or one of "latest" for last mined block, "earliest" for first, // "pending" for not yet committed messages. // Optional, default: "latest". ToBlock *string `json:"toBlock,omitempty"` diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index e2c39ed878f..a3898a26661 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -9,6 +9,7 @@ import ( "os" "sort" "strconv" + "strings" "sync" "time" @@ -1180,6 +1181,9 @@ func (e *EthEvent) installEthFilterSpec(ctx context.Context, filterSpec *ethtype } else if *filterSpec.FromBlock == "pending" { return nil, api.ErrNotSupported } else { + if !strings.HasPrefix(*filterSpec.FromBlock, "0x") { + return nil, xerrors.Errorf("FromBlock is not a hex") + } epoch, err := ethtypes.EthUint64FromHex(*filterSpec.FromBlock) if err != nil { return nil, xerrors.Errorf("invalid epoch") @@ -1195,6 +1199,9 @@ func (e *EthEvent) installEthFilterSpec(ctx context.Context, filterSpec *ethtype } else if *filterSpec.ToBlock == "pending" { return nil, api.ErrNotSupported } else { + if !strings.HasPrefix(*filterSpec.ToBlock, "0x") { + return nil, xerrors.Errorf("ToBlock is not a hex") + } epoch, err := ethtypes.EthUint64FromHex(*filterSpec.ToBlock) if err != nil { return nil, xerrors.Errorf("invalid epoch")