fix eth_feeHistory: add missing param.

This commit is contained in:
Raúl Kripalani 2022-10-22 19:10:52 +01:00 committed by vyzo
parent 323ff1b55e
commit 32617a61df
9 changed files with 58 additions and 37 deletions

View File

@ -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) (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 uint64, 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

View File

@ -997,18 +997,18 @@ func (mr *MockFullNodeMockRecorder) EthEstimateGas(arg0, arg1 interface{}) *gomo
}
// EthFeeHistory mocks base method.
func (m *MockFullNode) EthFeeHistory(arg0 context.Context, arg1 uint64, arg2 string) (api.EthFeeHistory, error) {
func (m *MockFullNode) EthFeeHistory(arg0 context.Context, arg1 uint64, arg2 string, arg3 [][]int64) (api.EthFeeHistory, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthFeeHistory", arg0, arg1, arg2)
ret := m.ctrl.Call(m, "EthFeeHistory", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(api.EthFeeHistory)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// EthFeeHistory indicates an expected call of EthFeeHistory.
func (mr *MockFullNodeMockRecorder) EthFeeHistory(arg0, arg1, arg2 interface{}) *gomock.Call {
func (mr *MockFullNodeMockRecorder) EthFeeHistory(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EthFeeHistory", reflect.TypeOf((*MockFullNode)(nil).EthFeeHistory), arg0, arg1, arg2)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EthFeeHistory", reflect.TypeOf((*MockFullNode)(nil).EthFeeHistory), arg0, arg1, arg2, arg3)
}
// EthGasPrice mocks base method.

View File

@ -34,7 +34,7 @@ import (
"github.com/filecoin-project/go-state-types/proof"
apitypes "github.com/filecoin-project/lotus/api/types"
"github.com/filecoin-project/lotus/chain/actors/builtin"
abuiltin "github.com/filecoin-project/lotus/chain/actors/builtin"
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/journal/alerting"
@ -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) (EthFeeHistory, error) `perm:"read"`
EthFeeHistory func(p0 context.Context, p1 uint64, p2 string, p3 [][]int64) (EthFeeHistory, error) `perm:"read"`
EthGasPrice func(p0 context.Context) (EthBigInt, error) `perm:"read"`
@ -733,7 +733,7 @@ type StorageMinerStruct struct {
ComputeDataCid func(p0 context.Context, p1 abi.UnpaddedPieceSize, p2 storiface.Data) (abi.PieceInfo, error) `perm:"admin"`
ComputeProof func(p0 context.Context, p1 []builtin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]builtin.PoStProof, error) `perm:"read"`
ComputeProof func(p0 context.Context, p1 []abuiltin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]abuiltin.PoStProof, error) `perm:"read"`
ComputeWindowPoSt func(p0 context.Context, p1 uint64, p2 types.TipSetKey) ([]miner.SubmitWindowedPoStParams, error) `perm:"admin"`
@ -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) (EthFeeHistory, error) {
func (s *FullNodeStruct) EthFeeHistory(p0 context.Context, p1 uint64, p2 string, p3 [][]int64) (EthFeeHistory, error) {
if s.Internal.EthFeeHistory == nil {
return *new(EthFeeHistory), ErrNotSupported
}
return s.Internal.EthFeeHistory(p0, p1, p2)
return s.Internal.EthFeeHistory(p0, p1, p2, p3)
}
func (s *FullNodeStub) EthFeeHistory(p0 context.Context, p1 uint64, p2 string) (EthFeeHistory, error) {
func (s *FullNodeStub) EthFeeHistory(p0 context.Context, p1 uint64, p2 string, p3 [][]int64) (EthFeeHistory, error) {
return *new(EthFeeHistory), ErrNotSupported
}
@ -4470,15 +4470,15 @@ func (s *StorageMinerStub) ComputeDataCid(p0 context.Context, p1 abi.UnpaddedPie
return *new(abi.PieceInfo), ErrNotSupported
}
func (s *StorageMinerStruct) ComputeProof(p0 context.Context, p1 []builtin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]builtin.PoStProof, error) {
func (s *StorageMinerStruct) ComputeProof(p0 context.Context, p1 []abuiltin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]abuiltin.PoStProof, error) {
if s.Internal.ComputeProof == nil {
return *new([]builtin.PoStProof), ErrNotSupported
return *new([]abuiltin.PoStProof), ErrNotSupported
}
return s.Internal.ComputeProof(p0, p1, p2, p3, p4)
}
func (s *StorageMinerStub) ComputeProof(p0 context.Context, p1 []builtin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]builtin.PoStProof, error) {
return *new([]builtin.PoStProof), ErrNotSupported
func (s *StorageMinerStub) ComputeProof(p0 context.Context, p1 []abuiltin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]abuiltin.PoStProof, error) {
return *new([]abuiltin.PoStProof), ErrNotSupported
}
func (s *StorageMinerStruct) ComputeWindowPoSt(p0 context.Context, p1 uint64, p2 types.TipSetKey) ([]miner.SubmitWindowedPoStParams, error) {

View File

@ -173,3 +173,17 @@ func TestDecodeError(t *testing.T) {
require.NotNil(t, err, hex.EncodeToString(tc))
}
}
func TestDecode1(t *testing.T) {
b := mustDecodeHex("0x02f8758401df5e7680832c8411832c8411830767f89452963ef50e27e06d72d59fcb4f3c2a687be3cfef880de0b6b3a764000080c080a094b11866f453ad85a980e0e8a2fc98cbaeb4409618c7734a7e12ae2f66fd405da042dbfb1b37af102023830ceeee0e703ffba0b8b3afeb8fe59f405eca9ed61072")
decoded, err := ParseEthTxArgs(b)
require.NoError(t, err)
orig, err := decoded.OriginalRlpMsg()
fmt.Println(hex.EncodeToString(orig))
// correct f4 addr: f410fkkld55ioe7qg24wvt7fu6pbknb56ht7pt4zamxa
fmt.Println(decoded.Sender())
fmt.Printf("%+v", decoded)
}

View File

@ -125,15 +125,6 @@ func IsBuiltinActor(c cid.Cid) bool {
return false
}
func IsEmbryo(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "embryo"
}
return false
}
func IsAccountActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {

View File

@ -0,0 +1,16 @@
package builtin
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors"
)
func IsEmbryo(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "embryo"
}
return false
}

View File

@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
cbor "github.com/ipfs/go-ipld-cbor"
@ -17,6 +16,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/big"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/network"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"

View File

@ -17,8 +17,6 @@ import (
"strings"
"time"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/builtin/v8/eam"
"github.com/ipfs/go-cid"
"github.com/urfave/cli/v2"
cbg "github.com/whyrusleeping/cbor-gen"
@ -29,7 +27,9 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
evm "github.com/filecoin-project/go-state-types/builtin/v10/evm"
"github.com/filecoin-project/go-state-types/builtin/v8/eam"
init8 "github.com/filecoin-project/go-state-types/builtin/v8/init"
"github.com/filecoin-project/specs-actors/actors/builtin"

View File

@ -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) (api.EthFeeHistory, error)
EthFeeHistory(ctx context.Context, blkCount uint64, 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) (api.EthFeeHistory, error) {
func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount uint64, newestBlkNum string, rewardPercentiles [][]int64) (api.EthFeeHistory, error) {
if blkCount > 1024 {
return api.EthFeeHistory{}, fmt.Errorf("block count should be smaller than 1024")
}