From dc5fc9ded43213f33db14400d0864d9861aace81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Sat, 22 Oct 2022 20:12:54 +0100 Subject: [PATCH] fix eth_feeHistory. --- api/api_full.go | 18 +++++++++--------- api/mocks/mock_full.go | 2 +- api/proxy_gen.go | 6 +++--- node/impl/full/eth.go | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/api/api_full.go b/api/api_full.go index 0ef20a52c..d431b55ac 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -778,15 +778,15 @@ type FullNode interface { EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash EthHash, txIndex EthUint64) (EthTx, error) //perm:read EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum EthUint64, txIndex EthUint64) (EthTx, error) //perm:read - EthGetCode(ctx context.Context, address EthAddress, blkOpt string) (EthBytes, error) //perm:read - EthGetStorageAt(ctx context.Context, address EthAddress, position EthBytes, blkParam string) (EthBytes, error) //perm:read - EthGetBalance(ctx context.Context, address EthAddress, blkParam string) (EthBigInt, error) //perm:read - EthChainId(ctx context.Context) (EthUint64, error) //perm:read - NetVersion(ctx context.Context) (string, error) //perm:read - NetListening(ctx context.Context) (bool, error) //perm:read - EthProtocolVersion(ctx context.Context) (EthUint64, error) //perm:read - EthGasPrice(ctx context.Context) (EthBigInt, error) //perm:read - EthFeeHistory(ctx context.Context, blkCount uint64, newestBlk string, rewardPercentiles [][]int64) (EthFeeHistory, error) //perm:read + EthGetCode(ctx context.Context, address EthAddress, blkOpt string) (EthBytes, error) //perm:read + EthGetStorageAt(ctx context.Context, address EthAddress, position EthBytes, blkParam string) (EthBytes, error) //perm:read + EthGetBalance(ctx context.Context, address EthAddress, blkParam string) (EthBigInt, error) //perm:read + EthChainId(ctx context.Context) (EthUint64, error) //perm:read + NetVersion(ctx context.Context) (string, error) //perm:read + NetListening(ctx context.Context) (bool, error) //perm:read + EthProtocolVersion(ctx context.Context) (EthUint64, error) //perm:read + EthGasPrice(ctx context.Context) (EthBigInt, error) //perm:read + EthFeeHistory(ctx context.Context, blkCount EthUint64, newestBlk string, rewardPercentiles []int64) (EthFeeHistory, error) //perm:read EthMaxPriorityFeePerGas(ctx context.Context) (EthBigInt, error) //perm:read EthEstimateGas(ctx context.Context, tx EthCall) (EthUint64, error) //perm:read diff --git a/api/mocks/mock_full.go b/api/mocks/mock_full.go index e070bf914..2e157a9c6 100644 --- a/api/mocks/mock_full.go +++ b/api/mocks/mock_full.go @@ -997,7 +997,7 @@ func (mr *MockFullNodeMockRecorder) EthEstimateGas(arg0, arg1 interface{}) *gomo } // EthFeeHistory mocks base method. -func (m *MockFullNode) EthFeeHistory(arg0 context.Context, arg1 uint64, arg2 string, arg3 [][]int64) (api.EthFeeHistory, error) { +func (m *MockFullNode) EthFeeHistory(arg0 context.Context, arg1 api.EthUint64, arg2 string, arg3 []int64) (api.EthFeeHistory, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "EthFeeHistory", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(api.EthFeeHistory) diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 064fe3b3e..07d1f3210 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -230,7 +230,7 @@ type FullNodeStruct struct { EthEstimateGas func(p0 context.Context, p1 EthCall) (EthUint64, error) `perm:"read"` - EthFeeHistory func(p0 context.Context, p1 uint64, p2 string, p3 [][]int64) (EthFeeHistory, error) `perm:"read"` + EthFeeHistory func(p0 context.Context, p1 EthUint64, p2 string, p3 []int64) (EthFeeHistory, error) `perm:"read"` EthGasPrice func(p0 context.Context) (EthBigInt, error) `perm:"read"` @@ -1896,14 +1896,14 @@ func (s *FullNodeStub) EthEstimateGas(p0 context.Context, p1 EthCall) (EthUint64 return *new(EthUint64), ErrNotSupported } -func (s *FullNodeStruct) EthFeeHistory(p0 context.Context, p1 uint64, p2 string, p3 [][]int64) (EthFeeHistory, error) { +func (s *FullNodeStruct) EthFeeHistory(p0 context.Context, p1 EthUint64, p2 string, p3 []int64) (EthFeeHistory, error) { if s.Internal.EthFeeHistory == nil { return *new(EthFeeHistory), ErrNotSupported } return s.Internal.EthFeeHistory(p0, p1, p2, p3) } -func (s *FullNodeStub) EthFeeHistory(p0 context.Context, p1 uint64, p2 string, p3 [][]int64) (EthFeeHistory, error) { +func (s *FullNodeStub) EthFeeHistory(p0 context.Context, p1 EthUint64, p2 string, p3 []int64) (EthFeeHistory, error) { return *new(EthFeeHistory), ErrNotSupported } diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index a853cc5b9..3b77c3690 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -45,7 +45,7 @@ type EthModuleAPI interface { EthGetCode(ctx context.Context, address api.EthAddress, blkOpt string) (api.EthBytes, error) EthGetStorageAt(ctx context.Context, address api.EthAddress, position api.EthBytes, blkParam string) (api.EthBytes, error) EthGetBalance(ctx context.Context, address api.EthAddress, blkParam string) (api.EthBigInt, error) - EthFeeHistory(ctx context.Context, blkCount uint64, newestBlk string, rewardPercentiles [][]int64) (api.EthFeeHistory, error) + EthFeeHistory(ctx context.Context, blkCount api.EthUint64, newestBlk string, rewardPercentiles []int64) (api.EthFeeHistory, error) EthChainId(ctx context.Context) (api.EthUint64, error) NetVersion(ctx context.Context) (string, error) NetListening(ctx context.Context) (bool, error) @@ -378,7 +378,7 @@ func (a *EthModule) EthChainId(ctx context.Context) (api.EthUint64, error) { return api.EthUint64(build.Eip155ChainId), nil } -func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount uint64, newestBlkNum string, rewardPercentiles [][]int64) (api.EthFeeHistory, error) { +func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount api.EthUint64, newestBlkNum string, rewardPercentiles []int64) (api.EthFeeHistory, error) { if blkCount > 1024 { return api.EthFeeHistory{}, fmt.Errorf("block count should be smaller than 1024") } @@ -395,8 +395,8 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount uint64, newestBl // Deal with the case that the chain is shorter than the number of // requested blocks. oldestBlkHeight := uint64(1) - if blkCount <= newestBlkHeight { - oldestBlkHeight = newestBlkHeight - blkCount + 1 + if uint64(blkCount) <= newestBlkHeight { + oldestBlkHeight = newestBlkHeight - uint64(blkCount) + 1 } ts, err := a.Chain.GetTipsetByHeight(ctx, abi.ChainEpoch(newestBlkHeight), nil, false)