diff --git a/api/api_gateway.go b/api/api_gateway.go index 9bc69cc0f..f53054f87 100644 --- a/api/api_gateway.go +++ b/api/api_gateway.go @@ -88,8 +88,6 @@ type Gateway interface { EthGetMessageCidByTransactionHash(ctx context.Context, txHash *ethtypes.EthHash) (*cid.Cid, error) EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, error) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*EthTxReceipt, error) - EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) - EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam string) (ethtypes.EthBytes, error) EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam string) (ethtypes.EthBigInt, error) diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 70579af1a..eb8a128ca 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -688,10 +688,6 @@ type GatewayMethods struct { EthGetStorageAt func(p0 context.Context, p1 ethtypes.EthAddress, p2 ethtypes.EthBytes, p3 string) (ethtypes.EthBytes, error) `` - EthGetTransactionByBlockHashAndIndex func(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) `` - - EthGetTransactionByBlockNumberAndIndex func(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) `` - EthGetTransactionByHash func(p0 context.Context, p1 *ethtypes.EthHash) (*ethtypes.EthTx, error) `` EthGetTransactionCount func(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthUint64, error) `` @@ -4395,28 +4391,6 @@ func (s *GatewayStub) EthGetStorageAt(p0 context.Context, p1 ethtypes.EthAddress return *new(ethtypes.EthBytes), ErrNotSupported } -func (s *GatewayStruct) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) { - if s.Internal.EthGetTransactionByBlockHashAndIndex == nil { - return *new(ethtypes.EthTx), ErrNotSupported - } - return s.Internal.EthGetTransactionByBlockHashAndIndex(p0, p1, p2) -} - -func (s *GatewayStub) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) { - return *new(ethtypes.EthTx), ErrNotSupported -} - -func (s *GatewayStruct) EthGetTransactionByBlockNumberAndIndex(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) { - if s.Internal.EthGetTransactionByBlockNumberAndIndex == nil { - return *new(ethtypes.EthTx), ErrNotSupported - } - return s.Internal.EthGetTransactionByBlockNumberAndIndex(p0, p1, p2) -} - -func (s *GatewayStub) EthGetTransactionByBlockNumberAndIndex(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) { - return *new(ethtypes.EthTx), ErrNotSupported -} - func (s *GatewayStruct) EthGetTransactionByHash(p0 context.Context, p1 *ethtypes.EthHash) (*ethtypes.EthTx, error) { if s.Internal.EthGetTransactionByHash == nil { return nil, ErrNotSupported diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index 855db5213..406add1cd 100644 Binary files a/build/openrpc/full.json.gz and b/build/openrpc/full.json.gz differ diff --git a/build/openrpc/gateway.json.gz b/build/openrpc/gateway.json.gz index c44af5aba..1c0862778 100644 Binary files a/build/openrpc/gateway.json.gz and b/build/openrpc/gateway.json.gz differ diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index e275035d1..94e8a9f97 100644 Binary files a/build/openrpc/miner.json.gz and b/build/openrpc/miner.json.gz differ diff --git a/build/openrpc/worker.json.gz b/build/openrpc/worker.json.gz index ed5b80612..11b2769e0 100644 Binary files a/build/openrpc/worker.json.gz and b/build/openrpc/worker.json.gz differ diff --git a/gateway/proxy_eth.go b/gateway/proxy_eth.go index 838a9ba3f..e1a261a7e 100644 --- a/gateway/proxy_eth.go +++ b/gateway/proxy_eth.go @@ -21,7 +21,7 @@ import ( ) func (gw *Node) Web3ClientVersion(ctx context.Context) (string, error) { - if err := gw.limit(ctx, stateRateLimitTokens); err != nil { + if err := gw.limit(ctx, basicRateLimitTokens); err != nil { return "", err } @@ -34,7 +34,7 @@ func (gw *Node) EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error) } func (gw *Node) EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error) { - if err := gw.limit(ctx, stateRateLimitTokens); err != nil { + if err := gw.limit(ctx, chainRateLimitTokens); err != nil { return 0, err } @@ -109,11 +109,7 @@ func (gw *Node) checkBlkParam(ctx context.Context, blkParam string) error { } func (gw *Node) EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error) { - if err := gw.limit(ctx, stateRateLimitTokens); err != nil { - return 0, err - } - - if err := gw.checkBlkHash(ctx, blkHash); err != nil { + if err := gw.limit(ctx, chainRateLimitTokens); err != nil { return 0, err } @@ -161,7 +157,7 @@ func (gw *Node) EthGetTransactionHashByCid(ctx context.Context, cid cid.Cid) (*e } func (gw *Node) EthGetMessageCidByTransactionHash(ctx context.Context, txHash *ethtypes.EthHash) (*cid.Cid, error) { - if err := gw.limit(ctx, stateRateLimitTokens); err != nil { + if err := gw.limit(ctx, chainRateLimitTokens); err != nil { return nil, err } @@ -188,34 +184,6 @@ func (gw *Node) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.Et return gw.target.EthGetTransactionReceipt(ctx, txHash) } -func (gw *Node) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) { - if err := gw.limit(ctx, stateRateLimitTokens); err != nil { - return ethtypes.EthTx{}, err - } - - if err := gw.checkBlkHash(ctx, blkHash); err != nil { - return ethtypes.EthTx{}, err - } - - return gw.target.EthGetTransactionByBlockHashAndIndex(ctx, blkHash, txIndex) -} - -func (gw *Node) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) { - if err := gw.limit(ctx, stateRateLimitTokens); err != nil { - return ethtypes.EthTx{}, err - } - - head, err := gw.target.ChainHead(ctx) - if err != nil { - return ethtypes.EthTx{}, err - } - if err := gw.checkTipsetHeight(head, abi.ChainEpoch(blkNum)); err != nil { - return ethtypes.EthTx{}, err - } - - return gw.target.EthGetTransactionByBlockNumberAndIndex(ctx, blkNum, txIndex) -} - func (gw *Node) EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) { if err := gw.limit(ctx, stateRateLimitTokens); err != nil { return nil, err @@ -253,7 +221,7 @@ func (gw *Node) EthGetBalance(ctx context.Context, address ethtypes.EthAddress, } func (gw *Node) EthChainId(ctx context.Context) (ethtypes.EthUint64, error) { - if err := gw.limit(ctx, stateRateLimitTokens); err != nil { + if err := gw.limit(ctx, basicRateLimitTokens); err != nil { return 0, err } @@ -269,7 +237,7 @@ func (gw *Node) NetVersion(ctx context.Context) (string, error) { } func (gw *Node) NetListening(ctx context.Context) (bool, error) { - if err := gw.limit(ctx, stateRateLimitTokens); err != nil { + if err := gw.limit(ctx, basicRateLimitTokens); err != nil { return false, err } @@ -285,7 +253,7 @@ func (gw *Node) EthProtocolVersion(ctx context.Context) (ethtypes.EthUint64, err } func (gw *Node) EthGasPrice(ctx context.Context) (ethtypes.EthBigInt, error) { - if err := gw.limit(ctx, stateRateLimitTokens); err != nil { + if err := gw.limit(ctx, chainRateLimitTokens); err != nil { return ethtypes.EthBigInt(big.Zero()), err } @@ -316,7 +284,7 @@ func (gw *Node) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (ethtype } func (gw *Node) EthMaxPriorityFeePerGas(ctx context.Context) (ethtypes.EthBigInt, error) { - if err := gw.limit(ctx, stateRateLimitTokens); err != nil { + if err := gw.limit(ctx, chainRateLimitTokens); err != nil { return ethtypes.EthBigInt(big.Zero()), err } diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index fda358f63..ccea349aa 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -43,6 +43,8 @@ import ( "github.com/filecoin-project/lotus/node/modules/dtypes" ) +var ErrUnsupported = errors.New("unsupported method") + type EthModuleAPI interface { EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error) EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error) @@ -55,8 +57,6 @@ type EthModuleAPI interface { EthGetTransactionHashByCid(ctx context.Context, cid cid.Cid) (*ethtypes.EthHash, error) EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, error) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) - EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) - EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam string) (ethtypes.EthBytes, error) EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam string) (ethtypes.EthBigInt, error) @@ -343,13 +343,13 @@ func (a *EthModule) EthGetMessageCidByTransactionHash(ctx context.Context, txHas c = txHash.ToCid() } - _, err = a.StateAPI.Chain.GetSignedMessage(ctx, c) + _, err = a.Chain.GetSignedMessage(ctx, c) if err == nil { // This is an Eth Tx, Secp message, Or BLS message in the mpool return &c, nil } - _, err = a.StateAPI.Chain.GetMessage(ctx, c) + _, err = a.Chain.GetMessage(ctx, c) if err == nil { // This is a BLS message return &c, nil @@ -449,12 +449,12 @@ func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash ethtype return &receipt, nil } -func (a *EthModule) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) { - return ethtypes.EthTx{}, nil +func (a *EthAPI) EthGetTransactionByBlockHashAndIndex(context.Context, ethtypes.EthHash, ethtypes.EthUint64) (ethtypes.EthTx, error) { + return ethtypes.EthTx{}, ErrUnsupported } -func (a *EthModule) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) { - return ethtypes.EthTx{}, nil +func (a *EthAPI) EthGetTransactionByBlockNumberAndIndex(context.Context, ethtypes.EthUint64, ethtypes.EthUint64) (ethtypes.EthTx, error) { + return ethtypes.EthTx{}, ErrUnsupported } // EthGetCode returns string value of the compiled bytecode