Move eth types to chain/types/ethtypes

This commit is contained in:
Geoff Stuart 2022-12-14 14:08:38 -05:00
parent 96bb03e1e0
commit 442132be70
15 changed files with 400 additions and 391 deletions

View File

@ -32,6 +32,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/eth"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo/imports"
)
@ -764,37 +765,37 @@ type FullNode interface {
// These methods are used for Ethereum-compatible JSON-RPC calls
//
// EthAccounts will always return [] since we don't expect Lotus to manage private keys
EthAccounts(ctx context.Context) ([]eth.EthAddress, error) //perm:read
EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error) //perm:read
// EthBlockNumber returns the height of the latest (heaviest) TipSet
EthBlockNumber(ctx context.Context) (eth.EthUint64, error) //perm:read
EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error) //perm:read
// EthGetBlockTransactionCountByNumber returns the number of messages in the TipSet
EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum eth.EthUint64) (eth.EthUint64, error) //perm:read
EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum ethtypes.EthUint64) (ethtypes.EthUint64, error) //perm:read
// EthGetBlockTransactionCountByHash returns the number of messages in the TipSet
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash eth.EthHash) (eth.EthUint64, error) //perm:read
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error) //perm:read
EthGetBlockByHash(ctx context.Context, blkHash eth.EthHash, fullTxInfo bool) (eth.EthBlock, error) //perm:read
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (eth.EthBlock, error) //perm:read
EthGetTransactionByHash(ctx context.Context, txHash *eth.EthHash) (*eth.EthTx, error) //perm:read
EthGetTransactionCount(ctx context.Context, sender eth.EthAddress, blkOpt string) (eth.EthUint64, error) //perm:read
EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*EthTxReceipt, error) //perm:read
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash eth.EthHash, txIndex eth.EthUint64) (eth.EthTx, error) //perm:read
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum eth.EthUint64, txIndex eth.EthUint64) (eth.EthTx, error) //perm:read
EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) //perm:read
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (ethtypes.EthBlock, error) //perm:read
EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*eth.EthTx, error) //perm:read
EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, error) //perm:read
EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*EthTxReceipt, error) //perm:read
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (eth.EthTx, error) //perm:read
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (eth.EthTx, error) //perm:read
EthGetCode(ctx context.Context, address eth.EthAddress, blkOpt string) (eth.EthBytes, error) //perm:read
EthGetStorageAt(ctx context.Context, address eth.EthAddress, position eth.EthBytes, blkParam string) (eth.EthBytes, error) //perm:read
EthGetBalance(ctx context.Context, address eth.EthAddress, blkParam string) (eth.EthBigInt, error) //perm:read
EthChainId(ctx context.Context) (eth.EthUint64, error) //perm:read
NetVersion(ctx context.Context) (string, error) //perm:read
NetListening(ctx context.Context) (bool, error) //perm:read
EthProtocolVersion(ctx context.Context) (eth.EthUint64, error) //perm:read
EthGasPrice(ctx context.Context) (eth.EthBigInt, error) //perm:read
EthFeeHistory(ctx context.Context, blkCount eth.EthUint64, newestBlk string, rewardPercentiles []float64) (eth.EthFeeHistory, error) //perm:read
EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) //perm:read
EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam string) (ethtypes.EthBytes, error) //perm:read
EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam string) (ethtypes.EthBigInt, error) //perm:read
EthChainId(ctx context.Context) (ethtypes.EthUint64, error) //perm:read
NetVersion(ctx context.Context) (string, error) //perm:read
NetListening(ctx context.Context) (bool, error) //perm:read
EthProtocolVersion(ctx context.Context) (ethtypes.EthUint64, error) //perm:read
EthGasPrice(ctx context.Context) (ethtypes.EthBigInt, error) //perm:read
EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint64, newestBlk string, rewardPercentiles []float64) (ethtypes.EthFeeHistory, error) //perm:read
EthMaxPriorityFeePerGas(ctx context.Context) (eth.EthBigInt, error) //perm:read
EthEstimateGas(ctx context.Context, tx eth.EthCall) (eth.EthUint64, error) //perm:read
EthCall(ctx context.Context, tx eth.EthCall, blkParam string) (eth.EthBytes, error) //perm:read
EthMaxPriorityFeePerGas(ctx context.Context) (ethtypes.EthBigInt, error) //perm:read
EthEstimateGas(ctx context.Context, tx ethtypes.EthCall) (ethtypes.EthUint64, error) //perm:read
EthCall(ctx context.Context, tx ethtypes.EthCall, blkParam string) (ethtypes.EthBytes, error) //perm:read
EthSendRawTransaction(ctx context.Context, rawTx eth.EthBytes) (eth.EthHash, error) //perm:read
EthSendRawTransaction(ctx context.Context, rawTx ethtypes.EthBytes) (ethtypes.EthHash, error) //perm:read
// CreateBackup creates node backup onder the specified file name. The
// method requires that the lotus daemon is running with the
@ -1291,20 +1292,20 @@ type PruneOpts struct {
}
type EthTxReceipt struct {
TransactionHash eth.EthHash `json:"transactionHash"`
TransactionIndex eth.EthUint64 `json:"transactionIndex"`
BlockHash eth.EthHash `json:"blockHash"`
BlockNumber eth.EthUint64 `json:"blockNumber"`
From eth.EthAddress `json:"from"`
To *eth.EthAddress `json:"to"`
TransactionHash ethtypes.EthHash `json:"transactionHash"`
TransactionIndex ethtypes.EthUint64 `json:"transactionIndex"`
BlockHash ethtypes.EthHash `json:"blockHash"`
BlockNumber ethtypes.EthUint64 `json:"blockNumber"`
From ethtypes.EthAddress `json:"from"`
To *ethtypes.EthAddress `json:"to"`
// Logs
// LogsBloom
StateRoot eth.EthHash `json:"root"`
Status eth.EthUint64 `json:"status"`
ContractAddress *eth.EthAddress `json:"contractAddress"`
CumulativeGasUsed eth.EthUint64 `json:"cumulativeGasUsed"`
GasUsed eth.EthUint64 `json:"gasUsed"`
EffectiveGasPrice eth.EthBigInt `json:"effectiveGasPrice"`
LogsBloom eth.EthBytes `json:"logsBloom"`
Logs []string `json:"logs"`
StateRoot ethtypes.EthHash `json:"root"`
Status ethtypes.EthUint64 `json:"status"`
ContractAddress *ethtypes.EthAddress `json:"contractAddress"`
CumulativeGasUsed ethtypes.EthUint64 `json:"cumulativeGasUsed"`
GasUsed ethtypes.EthUint64 `json:"gasUsed"`
EffectiveGasPrice ethtypes.EthBigInt `json:"effectiveGasPrice"`
LogsBloom ethtypes.EthBytes `json:"logsBloom"`
Logs []string `json:"logs"`
}

View File

@ -42,8 +42,8 @@ import (
apitypes "github.com/filecoin-project/lotus/api/types"
"github.com/filecoin-project/lotus/api/v0api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/eth"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo/imports"
sealing "github.com/filecoin-project/lotus/storage/pipeline"
@ -370,16 +370,16 @@ func init() {
},
})
ethint := eth.EthUint64(5)
ethint := ethtypes.EthUint64(5)
addExample(ethint)
addExample(&ethint)
ethaddr, _ := eth.EthAddressFromHex("0x5CbEeCF99d3fDB3f25E309Cc264f240bb0664031")
ethaddr, _ := ethtypes.EthAddressFromHex("0x5CbEeCF99d3fDB3f25E309Cc264f240bb0664031")
addExample(&ethaddr)
ethhash, _ := eth.NewEthHashFromCid(c)
ethhash, _ := ethtypes.NewEthHashFromCid(c)
addExample(&ethhash)
ethFeeHistoryReward := [][]eth.EthBigInt{}
ethFeeHistoryReward := [][]ethtypes.EthBigInt{}
addExample(&ethFeeHistoryReward)
addExample(&uuid.UUID{})
}

View File

@ -38,6 +38,7 @@ import (
miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
eth "github.com/filecoin-project/lotus/chain/eth"
types "github.com/filecoin-project/lotus/chain/types"
ethtypes "github.com/filecoin-project/lotus/chain/types/ethtypes"
alerting "github.com/filecoin-project/lotus/journal/alerting"
dtypes "github.com/filecoin-project/lotus/node/modules/dtypes"
imports "github.com/filecoin-project/lotus/node/repo/imports"
@ -923,10 +924,10 @@ func (mr *MockFullNodeMockRecorder) Discover(arg0 interface{}) *gomock.Call {
}
// EthAccounts mocks base method.
func (m *MockFullNode) EthAccounts(arg0 context.Context) ([]eth.EthAddress, error) {
func (m *MockFullNode) EthAccounts(arg0 context.Context) ([]ethtypes.EthAddress, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthAccounts", arg0)
ret0, _ := ret[0].([]eth.EthAddress)
ret0, _ := ret[0].([]ethtypes.EthAddress)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -938,10 +939,10 @@ func (mr *MockFullNodeMockRecorder) EthAccounts(arg0 interface{}) *gomock.Call {
}
// EthBlockNumber mocks base method.
func (m *MockFullNode) EthBlockNumber(arg0 context.Context) (eth.EthUint64, error) {
func (m *MockFullNode) EthBlockNumber(arg0 context.Context) (ethtypes.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthBlockNumber", arg0)
ret0, _ := ret[0].(eth.EthUint64)
ret0, _ := ret[0].(ethtypes.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -953,10 +954,10 @@ func (mr *MockFullNodeMockRecorder) EthBlockNumber(arg0 interface{}) *gomock.Cal
}
// EthCall mocks base method.
func (m *MockFullNode) EthCall(arg0 context.Context, arg1 eth.EthCall, arg2 string) (eth.EthBytes, error) {
func (m *MockFullNode) EthCall(arg0 context.Context, arg1 ethtypes.EthCall, arg2 string) (ethtypes.EthBytes, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthCall", arg0, arg1, arg2)
ret0, _ := ret[0].(eth.EthBytes)
ret0, _ := ret[0].(ethtypes.EthBytes)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -968,10 +969,10 @@ func (mr *MockFullNodeMockRecorder) EthCall(arg0, arg1, arg2 interface{}) *gomoc
}
// EthChainId mocks base method.
func (m *MockFullNode) EthChainId(arg0 context.Context) (eth.EthUint64, error) {
func (m *MockFullNode) EthChainId(arg0 context.Context) (ethtypes.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthChainId", arg0)
ret0, _ := ret[0].(eth.EthUint64)
ret0, _ := ret[0].(ethtypes.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -983,10 +984,10 @@ func (mr *MockFullNodeMockRecorder) EthChainId(arg0 interface{}) *gomock.Call {
}
// EthEstimateGas mocks base method.
func (m *MockFullNode) EthEstimateGas(arg0 context.Context, arg1 eth.EthCall) (eth.EthUint64, error) {
func (m *MockFullNode) EthEstimateGas(arg0 context.Context, arg1 ethtypes.EthCall) (ethtypes.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthEstimateGas", arg0, arg1)
ret0, _ := ret[0].(eth.EthUint64)
ret0, _ := ret[0].(ethtypes.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -998,10 +999,10 @@ func (mr *MockFullNodeMockRecorder) EthEstimateGas(arg0, arg1 interface{}) *gomo
}
// EthFeeHistory mocks base method.
func (m *MockFullNode) EthFeeHistory(arg0 context.Context, arg1 eth.EthUint64, arg2 string, arg3 []float64) (eth.EthFeeHistory, error) {
func (m *MockFullNode) EthFeeHistory(arg0 context.Context, arg1 ethtypes.EthUint64, arg2 string, arg3 []float64) (ethtypes.EthFeeHistory, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthFeeHistory", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(eth.EthFeeHistory)
ret0, _ := ret[0].(ethtypes.EthFeeHistory)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1013,10 +1014,10 @@ func (mr *MockFullNodeMockRecorder) EthFeeHistory(arg0, arg1, arg2, arg3 interfa
}
// EthGasPrice mocks base method.
func (m *MockFullNode) EthGasPrice(arg0 context.Context) (eth.EthBigInt, error) {
func (m *MockFullNode) EthGasPrice(arg0 context.Context) (ethtypes.EthBigInt, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGasPrice", arg0)
ret0, _ := ret[0].(eth.EthBigInt)
ret0, _ := ret[0].(ethtypes.EthBigInt)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1028,10 +1029,10 @@ func (mr *MockFullNodeMockRecorder) EthGasPrice(arg0 interface{}) *gomock.Call {
}
// EthGetBalance mocks base method.
func (m *MockFullNode) EthGetBalance(arg0 context.Context, arg1 eth.EthAddress, arg2 string) (eth.EthBigInt, error) {
func (m *MockFullNode) EthGetBalance(arg0 context.Context, arg1 ethtypes.EthAddress, arg2 string) (ethtypes.EthBigInt, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetBalance", arg0, arg1, arg2)
ret0, _ := ret[0].(eth.EthBigInt)
ret0, _ := ret[0].(ethtypes.EthBigInt)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1043,10 +1044,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBalance(arg0, arg1, arg2 interface{})
}
// EthGetBlockByHash mocks base method.
func (m *MockFullNode) EthGetBlockByHash(arg0 context.Context, arg1 eth.EthHash, arg2 bool) (eth.EthBlock, error) {
func (m *MockFullNode) EthGetBlockByHash(arg0 context.Context, arg1 ethtypes.EthHash, arg2 bool) (ethtypes.EthBlock, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetBlockByHash", arg0, arg1, arg2)
ret0, _ := ret[0].(eth.EthBlock)
ret0, _ := ret[0].(ethtypes.EthBlock)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1058,10 +1059,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBlockByHash(arg0, arg1, arg2 interface
}
// EthGetBlockByNumber mocks base method.
func (m *MockFullNode) EthGetBlockByNumber(arg0 context.Context, arg1 string, arg2 bool) (eth.EthBlock, error) {
func (m *MockFullNode) EthGetBlockByNumber(arg0 context.Context, arg1 string, arg2 bool) (ethtypes.EthBlock, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetBlockByNumber", arg0, arg1, arg2)
ret0, _ := ret[0].(eth.EthBlock)
ret0, _ := ret[0].(ethtypes.EthBlock)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1073,10 +1074,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBlockByNumber(arg0, arg1, arg2 interfa
}
// EthGetBlockTransactionCountByHash mocks base method.
func (m *MockFullNode) EthGetBlockTransactionCountByHash(arg0 context.Context, arg1 eth.EthHash) (eth.EthUint64, error) {
func (m *MockFullNode) EthGetBlockTransactionCountByHash(arg0 context.Context, arg1 ethtypes.EthHash) (ethtypes.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetBlockTransactionCountByHash", arg0, arg1)
ret0, _ := ret[0].(eth.EthUint64)
ret0, _ := ret[0].(ethtypes.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1088,10 +1089,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBlockTransactionCountByHash(arg0, arg1
}
// EthGetBlockTransactionCountByNumber mocks base method.
func (m *MockFullNode) EthGetBlockTransactionCountByNumber(arg0 context.Context, arg1 eth.EthUint64) (eth.EthUint64, error) {
func (m *MockFullNode) EthGetBlockTransactionCountByNumber(arg0 context.Context, arg1 ethtypes.EthUint64) (ethtypes.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetBlockTransactionCountByNumber", arg0, arg1)
ret0, _ := ret[0].(eth.EthUint64)
ret0, _ := ret[0].(ethtypes.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1103,10 +1104,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBlockTransactionCountByNumber(arg0, ar
}
// EthGetCode mocks base method.
func (m *MockFullNode) EthGetCode(arg0 context.Context, arg1 eth.EthAddress, arg2 string) (eth.EthBytes, error) {
func (m *MockFullNode) EthGetCode(arg0 context.Context, arg1 ethtypes.EthAddress, arg2 string) (ethtypes.EthBytes, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetCode", arg0, arg1, arg2)
ret0, _ := ret[0].(eth.EthBytes)
ret0, _ := ret[0].(ethtypes.EthBytes)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1118,10 +1119,10 @@ func (mr *MockFullNodeMockRecorder) EthGetCode(arg0, arg1, arg2 interface{}) *go
}
// EthGetStorageAt mocks base method.
func (m *MockFullNode) EthGetStorageAt(arg0 context.Context, arg1 eth.EthAddress, arg2 eth.EthBytes, arg3 string) (eth.EthBytes, error) {
func (m *MockFullNode) EthGetStorageAt(arg0 context.Context, arg1 ethtypes.EthAddress, arg2 ethtypes.EthBytes, arg3 string) (ethtypes.EthBytes, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetStorageAt", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(eth.EthBytes)
ret0, _ := ret[0].(ethtypes.EthBytes)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1133,7 +1134,7 @@ func (mr *MockFullNodeMockRecorder) EthGetStorageAt(arg0, arg1, arg2, arg3 inter
}
// EthGetTransactionByBlockHashAndIndex mocks base method.
func (m *MockFullNode) EthGetTransactionByBlockHashAndIndex(arg0 context.Context, arg1 eth.EthHash, arg2 eth.EthUint64) (eth.EthTx, error) {
func (m *MockFullNode) EthGetTransactionByBlockHashAndIndex(arg0 context.Context, arg1 ethtypes.EthHash, arg2 ethtypes.EthUint64) (eth.EthTx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetTransactionByBlockHashAndIndex", arg0, arg1, arg2)
ret0, _ := ret[0].(eth.EthTx)
@ -1148,7 +1149,7 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionByBlockHashAndIndex(arg0, a
}
// EthGetTransactionByBlockNumberAndIndex mocks base method.
func (m *MockFullNode) EthGetTransactionByBlockNumberAndIndex(arg0 context.Context, arg1, arg2 eth.EthUint64) (eth.EthTx, error) {
func (m *MockFullNode) EthGetTransactionByBlockNumberAndIndex(arg0 context.Context, arg1, arg2 ethtypes.EthUint64) (eth.EthTx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetTransactionByBlockNumberAndIndex", arg0, arg1, arg2)
ret0, _ := ret[0].(eth.EthTx)
@ -1163,7 +1164,7 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionByBlockNumberAndIndex(arg0,
}
// EthGetTransactionByHash mocks base method.
func (m *MockFullNode) EthGetTransactionByHash(arg0 context.Context, arg1 *eth.EthHash) (*eth.EthTx, error) {
func (m *MockFullNode) EthGetTransactionByHash(arg0 context.Context, arg1 *ethtypes.EthHash) (*eth.EthTx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetTransactionByHash", arg0, arg1)
ret0, _ := ret[0].(*eth.EthTx)
@ -1178,10 +1179,10 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionByHash(arg0, arg1 interface
}
// EthGetTransactionCount mocks base method.
func (m *MockFullNode) EthGetTransactionCount(arg0 context.Context, arg1 eth.EthAddress, arg2 string) (eth.EthUint64, error) {
func (m *MockFullNode) EthGetTransactionCount(arg0 context.Context, arg1 ethtypes.EthAddress, arg2 string) (ethtypes.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetTransactionCount", arg0, arg1, arg2)
ret0, _ := ret[0].(eth.EthUint64)
ret0, _ := ret[0].(ethtypes.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1193,7 +1194,7 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionCount(arg0, arg1, arg2 inte
}
// EthGetTransactionReceipt mocks base method.
func (m *MockFullNode) EthGetTransactionReceipt(arg0 context.Context, arg1 eth.EthHash) (*api.EthTxReceipt, error) {
func (m *MockFullNode) EthGetTransactionReceipt(arg0 context.Context, arg1 ethtypes.EthHash) (*api.EthTxReceipt, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetTransactionReceipt", arg0, arg1)
ret0, _ := ret[0].(*api.EthTxReceipt)
@ -1208,10 +1209,10 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionReceipt(arg0, arg1 interfac
}
// EthMaxPriorityFeePerGas mocks base method.
func (m *MockFullNode) EthMaxPriorityFeePerGas(arg0 context.Context) (eth.EthBigInt, error) {
func (m *MockFullNode) EthMaxPriorityFeePerGas(arg0 context.Context) (ethtypes.EthBigInt, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthMaxPriorityFeePerGas", arg0)
ret0, _ := ret[0].(eth.EthBigInt)
ret0, _ := ret[0].(ethtypes.EthBigInt)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1223,10 +1224,10 @@ func (mr *MockFullNodeMockRecorder) EthMaxPriorityFeePerGas(arg0 interface{}) *g
}
// EthProtocolVersion mocks base method.
func (m *MockFullNode) EthProtocolVersion(arg0 context.Context) (eth.EthUint64, error) {
func (m *MockFullNode) EthProtocolVersion(arg0 context.Context) (ethtypes.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthProtocolVersion", arg0)
ret0, _ := ret[0].(eth.EthUint64)
ret0, _ := ret[0].(ethtypes.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1238,10 +1239,10 @@ func (mr *MockFullNodeMockRecorder) EthProtocolVersion(arg0 interface{}) *gomock
}
// EthSendRawTransaction mocks base method.
func (m *MockFullNode) EthSendRawTransaction(arg0 context.Context, arg1 eth.EthBytes) (eth.EthHash, error) {
func (m *MockFullNode) EthSendRawTransaction(arg0 context.Context, arg1 ethtypes.EthBytes) (ethtypes.EthHash, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthSendRawTransaction", arg0, arg1)
ret0, _ := ret[0].(eth.EthHash)
ret0, _ := ret[0].(ethtypes.EthHash)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View File

@ -37,6 +37,7 @@ import (
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/eth"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/filecoin-project/lotus/journal/alerting"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo/imports"
@ -219,49 +220,49 @@ type FullNodeStruct struct {
CreateBackup func(p0 context.Context, p1 string) error `perm:"admin"`
EthAccounts func(p0 context.Context) ([]eth.EthAddress, error) `perm:"read"`
EthAccounts func(p0 context.Context) ([]ethtypes.EthAddress, error) `perm:"read"`
EthBlockNumber func(p0 context.Context) (eth.EthUint64, error) `perm:"read"`
EthBlockNumber func(p0 context.Context) (ethtypes.EthUint64, error) `perm:"read"`
EthCall func(p0 context.Context, p1 eth.EthCall, p2 string) (eth.EthBytes, error) `perm:"read"`
EthCall func(p0 context.Context, p1 ethtypes.EthCall, p2 string) (ethtypes.EthBytes, error) `perm:"read"`
EthChainId func(p0 context.Context) (eth.EthUint64, error) `perm:"read"`
EthChainId func(p0 context.Context) (ethtypes.EthUint64, error) `perm:"read"`
EthEstimateGas func(p0 context.Context, p1 eth.EthCall) (eth.EthUint64, error) `perm:"read"`
EthEstimateGas func(p0 context.Context, p1 ethtypes.EthCall) (ethtypes.EthUint64, error) `perm:"read"`
EthFeeHistory func(p0 context.Context, p1 eth.EthUint64, p2 string, p3 []float64) (eth.EthFeeHistory, error) `perm:"read"`
EthFeeHistory func(p0 context.Context, p1 ethtypes.EthUint64, p2 string, p3 []float64) (ethtypes.EthFeeHistory, error) `perm:"read"`
EthGasPrice func(p0 context.Context) (eth.EthBigInt, error) `perm:"read"`
EthGasPrice func(p0 context.Context) (ethtypes.EthBigInt, error) `perm:"read"`
EthGetBalance func(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthBigInt, error) `perm:"read"`
EthGetBalance func(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthBigInt, error) `perm:"read"`
EthGetBlockByHash func(p0 context.Context, p1 eth.EthHash, p2 bool) (eth.EthBlock, error) `perm:"read"`
EthGetBlockByHash func(p0 context.Context, p1 ethtypes.EthHash, p2 bool) (ethtypes.EthBlock, error) `perm:"read"`
EthGetBlockByNumber func(p0 context.Context, p1 string, p2 bool) (eth.EthBlock, error) `perm:"read"`
EthGetBlockByNumber func(p0 context.Context, p1 string, p2 bool) (ethtypes.EthBlock, error) `perm:"read"`
EthGetBlockTransactionCountByHash func(p0 context.Context, p1 eth.EthHash) (eth.EthUint64, error) `perm:"read"`
EthGetBlockTransactionCountByHash func(p0 context.Context, p1 ethtypes.EthHash) (ethtypes.EthUint64, error) `perm:"read"`
EthGetBlockTransactionCountByNumber func(p0 context.Context, p1 eth.EthUint64) (eth.EthUint64, error) `perm:"read"`
EthGetBlockTransactionCountByNumber func(p0 context.Context, p1 ethtypes.EthUint64) (ethtypes.EthUint64, error) `perm:"read"`
EthGetCode func(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthBytes, error) `perm:"read"`
EthGetCode func(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthBytes, error) `perm:"read"`
EthGetStorageAt func(p0 context.Context, p1 eth.EthAddress, p2 eth.EthBytes, p3 string) (eth.EthBytes, error) `perm:"read"`
EthGetStorageAt func(p0 context.Context, p1 ethtypes.EthAddress, p2 ethtypes.EthBytes, p3 string) (ethtypes.EthBytes, error) `perm:"read"`
EthGetTransactionByBlockHashAndIndex func(p0 context.Context, p1 eth.EthHash, p2 eth.EthUint64) (eth.EthTx, error) `perm:"read"`
EthGetTransactionByBlockHashAndIndex func(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (eth.EthTx, error) `perm:"read"`
EthGetTransactionByBlockNumberAndIndex func(p0 context.Context, p1 eth.EthUint64, p2 eth.EthUint64) (eth.EthTx, error) `perm:"read"`
EthGetTransactionByBlockNumberAndIndex func(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (eth.EthTx, error) `perm:"read"`
EthGetTransactionByHash func(p0 context.Context, p1 *eth.EthHash) (*eth.EthTx, error) `perm:"read"`
EthGetTransactionByHash func(p0 context.Context, p1 *ethtypes.EthHash) (*eth.EthTx, error) `perm:"read"`
EthGetTransactionCount func(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthUint64, error) `perm:"read"`
EthGetTransactionCount func(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthUint64, error) `perm:"read"`
EthGetTransactionReceipt func(p0 context.Context, p1 eth.EthHash) (*EthTxReceipt, error) `perm:"read"`
EthGetTransactionReceipt func(p0 context.Context, p1 ethtypes.EthHash) (*EthTxReceipt, error) `perm:"read"`
EthMaxPriorityFeePerGas func(p0 context.Context) (eth.EthBigInt, error) `perm:"read"`
EthMaxPriorityFeePerGas func(p0 context.Context) (ethtypes.EthBigInt, error) `perm:"read"`
EthProtocolVersion func(p0 context.Context) (eth.EthUint64, error) `perm:"read"`
EthProtocolVersion func(p0 context.Context) (ethtypes.EthUint64, error) `perm:"read"`
EthSendRawTransaction func(p0 context.Context, p1 eth.EthBytes) (eth.EthHash, error) `perm:"read"`
EthSendRawTransaction func(p0 context.Context, p1 ethtypes.EthBytes) (ethtypes.EthHash, error) `perm:"read"`
GasEstimateFeeCap func(p0 context.Context, p1 *types.Message, p2 int64, p3 types.TipSetKey) (types.BigInt, error) `perm:"read"`
@ -1844,246 +1845,246 @@ func (s *FullNodeStub) CreateBackup(p0 context.Context, p1 string) error {
return ErrNotSupported
}
func (s *FullNodeStruct) EthAccounts(p0 context.Context) ([]eth.EthAddress, error) {
func (s *FullNodeStruct) EthAccounts(p0 context.Context) ([]ethtypes.EthAddress, error) {
if s.Internal.EthAccounts == nil {
return *new([]eth.EthAddress), ErrNotSupported
return *new([]ethtypes.EthAddress), ErrNotSupported
}
return s.Internal.EthAccounts(p0)
}
func (s *FullNodeStub) EthAccounts(p0 context.Context) ([]eth.EthAddress, error) {
return *new([]eth.EthAddress), ErrNotSupported
func (s *FullNodeStub) EthAccounts(p0 context.Context) ([]ethtypes.EthAddress, error) {
return *new([]ethtypes.EthAddress), ErrNotSupported
}
func (s *FullNodeStruct) EthBlockNumber(p0 context.Context) (eth.EthUint64, error) {
func (s *FullNodeStruct) EthBlockNumber(p0 context.Context) (ethtypes.EthUint64, error) {
if s.Internal.EthBlockNumber == nil {
return *new(eth.EthUint64), ErrNotSupported
return *new(ethtypes.EthUint64), ErrNotSupported
}
return s.Internal.EthBlockNumber(p0)
}
func (s *FullNodeStub) EthBlockNumber(p0 context.Context) (eth.EthUint64, error) {
return *new(eth.EthUint64), ErrNotSupported
func (s *FullNodeStub) EthBlockNumber(p0 context.Context) (ethtypes.EthUint64, error) {
return *new(ethtypes.EthUint64), ErrNotSupported
}
func (s *FullNodeStruct) EthCall(p0 context.Context, p1 eth.EthCall, p2 string) (eth.EthBytes, error) {
func (s *FullNodeStruct) EthCall(p0 context.Context, p1 ethtypes.EthCall, p2 string) (ethtypes.EthBytes, error) {
if s.Internal.EthCall == nil {
return *new(eth.EthBytes), ErrNotSupported
return *new(ethtypes.EthBytes), ErrNotSupported
}
return s.Internal.EthCall(p0, p1, p2)
}
func (s *FullNodeStub) EthCall(p0 context.Context, p1 eth.EthCall, p2 string) (eth.EthBytes, error) {
return *new(eth.EthBytes), ErrNotSupported
func (s *FullNodeStub) EthCall(p0 context.Context, p1 ethtypes.EthCall, p2 string) (ethtypes.EthBytes, error) {
return *new(ethtypes.EthBytes), ErrNotSupported
}
func (s *FullNodeStruct) EthChainId(p0 context.Context) (eth.EthUint64, error) {
func (s *FullNodeStruct) EthChainId(p0 context.Context) (ethtypes.EthUint64, error) {
if s.Internal.EthChainId == nil {
return *new(eth.EthUint64), ErrNotSupported
return *new(ethtypes.EthUint64), ErrNotSupported
}
return s.Internal.EthChainId(p0)
}
func (s *FullNodeStub) EthChainId(p0 context.Context) (eth.EthUint64, error) {
return *new(eth.EthUint64), ErrNotSupported
func (s *FullNodeStub) EthChainId(p0 context.Context) (ethtypes.EthUint64, error) {
return *new(ethtypes.EthUint64), ErrNotSupported
}
func (s *FullNodeStruct) EthEstimateGas(p0 context.Context, p1 eth.EthCall) (eth.EthUint64, error) {
func (s *FullNodeStruct) EthEstimateGas(p0 context.Context, p1 ethtypes.EthCall) (ethtypes.EthUint64, error) {
if s.Internal.EthEstimateGas == nil {
return *new(eth.EthUint64), ErrNotSupported
return *new(ethtypes.EthUint64), ErrNotSupported
}
return s.Internal.EthEstimateGas(p0, p1)
}
func (s *FullNodeStub) EthEstimateGas(p0 context.Context, p1 eth.EthCall) (eth.EthUint64, error) {
return *new(eth.EthUint64), ErrNotSupported
func (s *FullNodeStub) EthEstimateGas(p0 context.Context, p1 ethtypes.EthCall) (ethtypes.EthUint64, error) {
return *new(ethtypes.EthUint64), ErrNotSupported
}
func (s *FullNodeStruct) EthFeeHistory(p0 context.Context, p1 eth.EthUint64, p2 string, p3 []float64) (eth.EthFeeHistory, error) {
func (s *FullNodeStruct) EthFeeHistory(p0 context.Context, p1 ethtypes.EthUint64, p2 string, p3 []float64) (ethtypes.EthFeeHistory, error) {
if s.Internal.EthFeeHistory == nil {
return *new(eth.EthFeeHistory), ErrNotSupported
return *new(ethtypes.EthFeeHistory), ErrNotSupported
}
return s.Internal.EthFeeHistory(p0, p1, p2, p3)
}
func (s *FullNodeStub) EthFeeHistory(p0 context.Context, p1 eth.EthUint64, p2 string, p3 []float64) (eth.EthFeeHistory, error) {
return *new(eth.EthFeeHistory), ErrNotSupported
func (s *FullNodeStub) EthFeeHistory(p0 context.Context, p1 ethtypes.EthUint64, p2 string, p3 []float64) (ethtypes.EthFeeHistory, error) {
return *new(ethtypes.EthFeeHistory), ErrNotSupported
}
func (s *FullNodeStruct) EthGasPrice(p0 context.Context) (eth.EthBigInt, error) {
func (s *FullNodeStruct) EthGasPrice(p0 context.Context) (ethtypes.EthBigInt, error) {
if s.Internal.EthGasPrice == nil {
return *new(eth.EthBigInt), ErrNotSupported
return *new(ethtypes.EthBigInt), ErrNotSupported
}
return s.Internal.EthGasPrice(p0)
}
func (s *FullNodeStub) EthGasPrice(p0 context.Context) (eth.EthBigInt, error) {
return *new(eth.EthBigInt), ErrNotSupported
func (s *FullNodeStub) EthGasPrice(p0 context.Context) (ethtypes.EthBigInt, error) {
return *new(ethtypes.EthBigInt), ErrNotSupported
}
func (s *FullNodeStruct) EthGetBalance(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthBigInt, error) {
func (s *FullNodeStruct) EthGetBalance(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthBigInt, error) {
if s.Internal.EthGetBalance == nil {
return *new(eth.EthBigInt), ErrNotSupported
return *new(ethtypes.EthBigInt), ErrNotSupported
}
return s.Internal.EthGetBalance(p0, p1, p2)
}
func (s *FullNodeStub) EthGetBalance(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthBigInt, error) {
return *new(eth.EthBigInt), ErrNotSupported
func (s *FullNodeStub) EthGetBalance(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthBigInt, error) {
return *new(ethtypes.EthBigInt), ErrNotSupported
}
func (s *FullNodeStruct) EthGetBlockByHash(p0 context.Context, p1 eth.EthHash, p2 bool) (eth.EthBlock, error) {
func (s *FullNodeStruct) EthGetBlockByHash(p0 context.Context, p1 ethtypes.EthHash, p2 bool) (ethtypes.EthBlock, error) {
if s.Internal.EthGetBlockByHash == nil {
return *new(eth.EthBlock), ErrNotSupported
return *new(ethtypes.EthBlock), ErrNotSupported
}
return s.Internal.EthGetBlockByHash(p0, p1, p2)
}
func (s *FullNodeStub) EthGetBlockByHash(p0 context.Context, p1 eth.EthHash, p2 bool) (eth.EthBlock, error) {
return *new(eth.EthBlock), ErrNotSupported
func (s *FullNodeStub) EthGetBlockByHash(p0 context.Context, p1 ethtypes.EthHash, p2 bool) (ethtypes.EthBlock, error) {
return *new(ethtypes.EthBlock), ErrNotSupported
}
func (s *FullNodeStruct) EthGetBlockByNumber(p0 context.Context, p1 string, p2 bool) (eth.EthBlock, error) {
func (s *FullNodeStruct) EthGetBlockByNumber(p0 context.Context, p1 string, p2 bool) (ethtypes.EthBlock, error) {
if s.Internal.EthGetBlockByNumber == nil {
return *new(eth.EthBlock), ErrNotSupported
return *new(ethtypes.EthBlock), ErrNotSupported
}
return s.Internal.EthGetBlockByNumber(p0, p1, p2)
}
func (s *FullNodeStub) EthGetBlockByNumber(p0 context.Context, p1 string, p2 bool) (eth.EthBlock, error) {
return *new(eth.EthBlock), ErrNotSupported
func (s *FullNodeStub) EthGetBlockByNumber(p0 context.Context, p1 string, p2 bool) (ethtypes.EthBlock, error) {
return *new(ethtypes.EthBlock), ErrNotSupported
}
func (s *FullNodeStruct) EthGetBlockTransactionCountByHash(p0 context.Context, p1 eth.EthHash) (eth.EthUint64, error) {
func (s *FullNodeStruct) EthGetBlockTransactionCountByHash(p0 context.Context, p1 ethtypes.EthHash) (ethtypes.EthUint64, error) {
if s.Internal.EthGetBlockTransactionCountByHash == nil {
return *new(eth.EthUint64), ErrNotSupported
return *new(ethtypes.EthUint64), ErrNotSupported
}
return s.Internal.EthGetBlockTransactionCountByHash(p0, p1)
}
func (s *FullNodeStub) EthGetBlockTransactionCountByHash(p0 context.Context, p1 eth.EthHash) (eth.EthUint64, error) {
return *new(eth.EthUint64), ErrNotSupported
func (s *FullNodeStub) EthGetBlockTransactionCountByHash(p0 context.Context, p1 ethtypes.EthHash) (ethtypes.EthUint64, error) {
return *new(ethtypes.EthUint64), ErrNotSupported
}
func (s *FullNodeStruct) EthGetBlockTransactionCountByNumber(p0 context.Context, p1 eth.EthUint64) (eth.EthUint64, error) {
func (s *FullNodeStruct) EthGetBlockTransactionCountByNumber(p0 context.Context, p1 ethtypes.EthUint64) (ethtypes.EthUint64, error) {
if s.Internal.EthGetBlockTransactionCountByNumber == nil {
return *new(eth.EthUint64), ErrNotSupported
return *new(ethtypes.EthUint64), ErrNotSupported
}
return s.Internal.EthGetBlockTransactionCountByNumber(p0, p1)
}
func (s *FullNodeStub) EthGetBlockTransactionCountByNumber(p0 context.Context, p1 eth.EthUint64) (eth.EthUint64, error) {
return *new(eth.EthUint64), ErrNotSupported
func (s *FullNodeStub) EthGetBlockTransactionCountByNumber(p0 context.Context, p1 ethtypes.EthUint64) (ethtypes.EthUint64, error) {
return *new(ethtypes.EthUint64), ErrNotSupported
}
func (s *FullNodeStruct) EthGetCode(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthBytes, error) {
func (s *FullNodeStruct) EthGetCode(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthBytes, error) {
if s.Internal.EthGetCode == nil {
return *new(eth.EthBytes), ErrNotSupported
return *new(ethtypes.EthBytes), ErrNotSupported
}
return s.Internal.EthGetCode(p0, p1, p2)
}
func (s *FullNodeStub) EthGetCode(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthBytes, error) {
return *new(eth.EthBytes), ErrNotSupported
func (s *FullNodeStub) EthGetCode(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthBytes, error) {
return *new(ethtypes.EthBytes), ErrNotSupported
}
func (s *FullNodeStruct) EthGetStorageAt(p0 context.Context, p1 eth.EthAddress, p2 eth.EthBytes, p3 string) (eth.EthBytes, error) {
func (s *FullNodeStruct) EthGetStorageAt(p0 context.Context, p1 ethtypes.EthAddress, p2 ethtypes.EthBytes, p3 string) (ethtypes.EthBytes, error) {
if s.Internal.EthGetStorageAt == nil {
return *new(eth.EthBytes), ErrNotSupported
return *new(ethtypes.EthBytes), ErrNotSupported
}
return s.Internal.EthGetStorageAt(p0, p1, p2, p3)
}
func (s *FullNodeStub) EthGetStorageAt(p0 context.Context, p1 eth.EthAddress, p2 eth.EthBytes, p3 string) (eth.EthBytes, error) {
return *new(eth.EthBytes), ErrNotSupported
func (s *FullNodeStub) EthGetStorageAt(p0 context.Context, p1 ethtypes.EthAddress, p2 ethtypes.EthBytes, p3 string) (ethtypes.EthBytes, error) {
return *new(ethtypes.EthBytes), ErrNotSupported
}
func (s *FullNodeStruct) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 eth.EthHash, p2 eth.EthUint64) (eth.EthTx, error) {
func (s *FullNodeStruct) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (eth.EthTx, error) {
if s.Internal.EthGetTransactionByBlockHashAndIndex == nil {
return *new(eth.EthTx), ErrNotSupported
}
return s.Internal.EthGetTransactionByBlockHashAndIndex(p0, p1, p2)
}
func (s *FullNodeStub) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 eth.EthHash, p2 eth.EthUint64) (eth.EthTx, error) {
func (s *FullNodeStub) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (eth.EthTx, error) {
return *new(eth.EthTx), ErrNotSupported
}
func (s *FullNodeStruct) EthGetTransactionByBlockNumberAndIndex(p0 context.Context, p1 eth.EthUint64, p2 eth.EthUint64) (eth.EthTx, error) {
func (s *FullNodeStruct) EthGetTransactionByBlockNumberAndIndex(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (eth.EthTx, error) {
if s.Internal.EthGetTransactionByBlockNumberAndIndex == nil {
return *new(eth.EthTx), ErrNotSupported
}
return s.Internal.EthGetTransactionByBlockNumberAndIndex(p0, p1, p2)
}
func (s *FullNodeStub) EthGetTransactionByBlockNumberAndIndex(p0 context.Context, p1 eth.EthUint64, p2 eth.EthUint64) (eth.EthTx, error) {
func (s *FullNodeStub) EthGetTransactionByBlockNumberAndIndex(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (eth.EthTx, error) {
return *new(eth.EthTx), ErrNotSupported
}
func (s *FullNodeStruct) EthGetTransactionByHash(p0 context.Context, p1 *eth.EthHash) (*eth.EthTx, error) {
func (s *FullNodeStruct) EthGetTransactionByHash(p0 context.Context, p1 *ethtypes.EthHash) (*eth.EthTx, error) {
if s.Internal.EthGetTransactionByHash == nil {
return nil, ErrNotSupported
}
return s.Internal.EthGetTransactionByHash(p0, p1)
}
func (s *FullNodeStub) EthGetTransactionByHash(p0 context.Context, p1 *eth.EthHash) (*eth.EthTx, error) {
func (s *FullNodeStub) EthGetTransactionByHash(p0 context.Context, p1 *ethtypes.EthHash) (*eth.EthTx, error) {
return nil, ErrNotSupported
}
func (s *FullNodeStruct) EthGetTransactionCount(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthUint64, error) {
func (s *FullNodeStruct) EthGetTransactionCount(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthUint64, error) {
if s.Internal.EthGetTransactionCount == nil {
return *new(eth.EthUint64), ErrNotSupported
return *new(ethtypes.EthUint64), ErrNotSupported
}
return s.Internal.EthGetTransactionCount(p0, p1, p2)
}
func (s *FullNodeStub) EthGetTransactionCount(p0 context.Context, p1 eth.EthAddress, p2 string) (eth.EthUint64, error) {
return *new(eth.EthUint64), ErrNotSupported
func (s *FullNodeStub) EthGetTransactionCount(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthUint64, error) {
return *new(ethtypes.EthUint64), ErrNotSupported
}
func (s *FullNodeStruct) EthGetTransactionReceipt(p0 context.Context, p1 eth.EthHash) (*EthTxReceipt, error) {
func (s *FullNodeStruct) EthGetTransactionReceipt(p0 context.Context, p1 ethtypes.EthHash) (*EthTxReceipt, error) {
if s.Internal.EthGetTransactionReceipt == nil {
return nil, ErrNotSupported
}
return s.Internal.EthGetTransactionReceipt(p0, p1)
}
func (s *FullNodeStub) EthGetTransactionReceipt(p0 context.Context, p1 eth.EthHash) (*EthTxReceipt, error) {
func (s *FullNodeStub) EthGetTransactionReceipt(p0 context.Context, p1 ethtypes.EthHash) (*EthTxReceipt, error) {
return nil, ErrNotSupported
}
func (s *FullNodeStruct) EthMaxPriorityFeePerGas(p0 context.Context) (eth.EthBigInt, error) {
func (s *FullNodeStruct) EthMaxPriorityFeePerGas(p0 context.Context) (ethtypes.EthBigInt, error) {
if s.Internal.EthMaxPriorityFeePerGas == nil {
return *new(eth.EthBigInt), ErrNotSupported
return *new(ethtypes.EthBigInt), ErrNotSupported
}
return s.Internal.EthMaxPriorityFeePerGas(p0)
}
func (s *FullNodeStub) EthMaxPriorityFeePerGas(p0 context.Context) (eth.EthBigInt, error) {
return *new(eth.EthBigInt), ErrNotSupported
func (s *FullNodeStub) EthMaxPriorityFeePerGas(p0 context.Context) (ethtypes.EthBigInt, error) {
return *new(ethtypes.EthBigInt), ErrNotSupported
}
func (s *FullNodeStruct) EthProtocolVersion(p0 context.Context) (eth.EthUint64, error) {
func (s *FullNodeStruct) EthProtocolVersion(p0 context.Context) (ethtypes.EthUint64, error) {
if s.Internal.EthProtocolVersion == nil {
return *new(eth.EthUint64), ErrNotSupported
return *new(ethtypes.EthUint64), ErrNotSupported
}
return s.Internal.EthProtocolVersion(p0)
}
func (s *FullNodeStub) EthProtocolVersion(p0 context.Context) (eth.EthUint64, error) {
return *new(eth.EthUint64), ErrNotSupported
func (s *FullNodeStub) EthProtocolVersion(p0 context.Context) (ethtypes.EthUint64, error) {
return *new(ethtypes.EthUint64), ErrNotSupported
}
func (s *FullNodeStruct) EthSendRawTransaction(p0 context.Context, p1 eth.EthBytes) (eth.EthHash, error) {
func (s *FullNodeStruct) EthSendRawTransaction(p0 context.Context, p1 ethtypes.EthBytes) (ethtypes.EthHash, error) {
if s.Internal.EthSendRawTransaction == nil {
return *new(eth.EthHash), ErrNotSupported
return *new(ethtypes.EthHash), ErrNotSupported
}
return s.Internal.EthSendRawTransaction(p0, p1)
}
func (s *FullNodeStub) EthSendRawTransaction(p0 context.Context, p1 eth.EthBytes) (eth.EthHash, error) {
return *new(eth.EthHash), ErrNotSupported
func (s *FullNodeStub) EthSendRawTransaction(p0 context.Context, p1 ethtypes.EthBytes) (ethtypes.EthHash, error) {
return *new(ethtypes.EthHash), ErrNotSupported
}
func (s *FullNodeStruct) GasEstimateFeeCap(p0 context.Context, p1 *types.Message, p2 int64, p3 types.TipSetKey) (types.BigInt, error) {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -20,47 +20,48 @@ import (
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
)
const Eip1559TxType = 2
type EthTx struct {
ChainID EthUint64 `json:"chainId"`
Nonce EthUint64 `json:"nonce"`
Hash EthHash `json:"hash"`
BlockHash EthHash `json:"blockHash"`
BlockNumber EthUint64 `json:"blockNumber"`
TransactionIndex EthUint64 `json:"transactionIndex"`
From EthAddress `json:"from"`
To *EthAddress `json:"to"`
Value EthBigInt `json:"value"`
Type EthUint64 `json:"type"`
Input EthBytes `json:"input"`
Gas EthUint64 `json:"gas"`
MaxFeePerGas EthBigInt `json:"maxFeePerGas"`
MaxPriorityFeePerGas EthBigInt `json:"maxPriorityFeePerGas"`
V EthBytes `json:"v"`
R EthBytes `json:"r"`
S EthBytes `json:"s"`
ChainID ethtypes.EthUint64 `json:"chainId"`
Nonce ethtypes.EthUint64 `json:"nonce"`
Hash ethtypes.EthHash `json:"hash"`
BlockHash ethtypes.EthHash `json:"blockHash"`
BlockNumber ethtypes.EthUint64 `json:"blockNumber"`
TransactionIndex ethtypes.EthUint64 `json:"transactionIndex"`
From ethtypes.EthAddress `json:"from"`
To *ethtypes.EthAddress `json:"to"`
Value ethtypes.EthBigInt `json:"value"`
Type ethtypes.EthUint64 `json:"type"`
Input ethtypes.EthBytes `json:"input"`
Gas ethtypes.EthUint64 `json:"gas"`
MaxFeePerGas ethtypes.EthBigInt `json:"maxFeePerGas"`
MaxPriorityFeePerGas ethtypes.EthBigInt `json:"maxPriorityFeePerGas"`
V ethtypes.EthBytes `json:"v"`
R ethtypes.EthBytes `json:"r"`
S ethtypes.EthBytes `json:"s"`
}
type EthTxArgs struct {
ChainID int `json:"chainId"`
Nonce int `json:"nonce"`
To *EthAddress `json:"to"`
Value big.Int `json:"value"`
MaxFeePerGas big.Int `json:"maxFeePerGas"`
MaxPriorityFeePerGas big.Int `json:"maxPriorityFeePerGas"`
GasLimit int `json:"gasLimit"`
Input []byte `json:"input"`
V []byte `json:"v"`
R []byte `json:"r"`
S []byte `json:"s"`
ChainID int `json:"chainId"`
Nonce int `json:"nonce"`
To *ethtypes.EthAddress `json:"to"`
Value big.Int `json:"value"`
MaxFeePerGas big.Int `json:"maxFeePerGas"`
MaxPriorityFeePerGas big.Int `json:"maxPriorityFeePerGas"`
GasLimit int `json:"gasLimit"`
Input []byte `json:"input"`
V []byte `json:"v"`
R []byte `json:"r"`
S []byte `json:"s"`
}
func NewEthTxArgsFromMessage(msg *types.Message) (EthTxArgs, error) {
var (
to *EthAddress
to *ethtypes.EthAddress
decodedParams []byte
paramsReader = bytes.NewReader(msg.Params)
)
@ -83,7 +84,7 @@ func NewEthTxArgsFromMessage(msg *types.Message) (EthTxArgs, error) {
return EthTxArgs{}, fmt.Errorf("unsupported EAM method")
}
} else {
addr, err := EthAddressFromFilecoinAddress(msg.To)
addr, err := ethtypes.EthAddressFromFilecoinAddress(msg.To)
if err != nil {
return EthTxArgs{}, err
}
@ -441,7 +442,7 @@ func formatInt(val int) ([]byte, error) {
return removeLeadingZeros(buf.Bytes()), nil
}
func formatEthAddr(addr *EthAddress) []byte {
func formatEthAddr(addr *ethtypes.EthAddress) []byte {
if addr == nil {
return nil
}
@ -496,7 +497,7 @@ func parseBytes(v interface{}) ([]byte, error) {
return val, nil
}
func parseEthAddr(v interface{}) (*EthAddress, error) {
func parseEthAddr(v interface{}) (*ethtypes.EthAddress, error) {
b, err := parseBytes(v)
if err != nil {
return nil, err
@ -504,7 +505,7 @@ func parseEthAddr(v interface{}) (*EthAddress, error) {
if len(b) == 0 {
return nil, nil
}
addr, err := EthAddressFromBytes(b)
addr, err := ethtypes.EthAddressFromBytes(b)
if err != nil {
return nil, err
}

File diff suppressed because one or more lines are too long

View File

@ -9,10 +9,12 @@ import (
"github.com/stretchr/testify/require"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
)
func TestEncode(t *testing.T) {
testcases := []TestCase{
testcases := []ethtypes.TestCase{
{[]byte(""), mustDecodeHex("0x80")},
{mustDecodeHex("0x01"), mustDecodeHex("0x01")},
{mustDecodeHex("0xaa"), mustDecodeHex("0x81aa")},
@ -64,7 +66,7 @@ func TestEncode(t *testing.T) {
}
func TestDecodeString(t *testing.T) {
testcases := []TestCase{
testcases := []ethtypes.TestCase{
{"0x00", "0x00"},
{"0x80", "0x"},
{"0x0f", "0x0f"},
@ -96,7 +98,7 @@ func mustDecodeHex(s string) []byte {
}
func TestDecodeList(t *testing.T) {
testcases := []TestCase{
testcases := []ethtypes.TestCase{
{"0xc0", []interface{}{}},
{"0xc100", []interface{}{[]byte{0}}},
{"0xc3000102", []interface{}{[]byte{0}, []byte{1}, []byte{2}}},

View File

@ -1,4 +1,4 @@
package eth
package ethtypes
import (
"bytes"

View File

@ -1,5 +1,5 @@
// stm: #unit
package eth
package ethtypes
import (
"strings"

View File

@ -6,73 +6,74 @@ import (
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/eth"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
)
var ErrImplementMe = errors.New("Not implemented yet")
type EthModuleDummy struct{}
func (e *EthModuleDummy) EthBlockNumber(ctx context.Context) (eth.EthUint64, error) {
func (e *EthModuleDummy) EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error) {
return 0, ErrImplementMe
}
func (e *EthModuleDummy) EthAccounts(ctx context.Context) ([]eth.EthAddress, error) {
func (e *EthModuleDummy) EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error) {
return nil, ErrImplementMe
}
func (e *EthModuleDummy) EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum eth.EthUint64) (eth.EthUint64, error) {
func (e *EthModuleDummy) EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum ethtypes.EthUint64) (ethtypes.EthUint64, error) {
return 0, ErrImplementMe
}
func (e *EthModuleDummy) EthGetBlockTransactionCountByHash(ctx context.Context, blkHash eth.EthHash) (eth.EthUint64, error) {
func (e *EthModuleDummy) EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error) {
return 0, ErrImplementMe
}
func (e *EthModuleDummy) EthGetBlockByHash(ctx context.Context, blkHash eth.EthHash, fullTxInfo bool) (eth.EthBlock, error) {
return eth.EthBlock{}, ErrImplementMe
func (e *EthModuleDummy) EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) {
return ethtypes.EthBlock{}, ErrImplementMe
}
func (e *EthModuleDummy) EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (eth.EthBlock, error) {
return eth.EthBlock{}, ErrImplementMe
func (e *EthModuleDummy) EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (ethtypes.EthBlock, error) {
return ethtypes.EthBlock{}, ErrImplementMe
}
func (e *EthModuleDummy) EthGetTransactionByHash(ctx context.Context, txHash *eth.EthHash) (*eth.EthTx, error) {
func (e *EthModuleDummy) EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*eth.EthTx, error) {
return nil, ErrImplementMe
}
func (e *EthModuleDummy) EthGetTransactionCount(ctx context.Context, sender eth.EthAddress, blkOpt string) (eth.EthUint64, error) {
func (e *EthModuleDummy) EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, error) {
return 0, ErrImplementMe
}
func (e *EthModuleDummy) EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*api.EthTxReceipt, error) {
func (e *EthModuleDummy) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) {
return nil, ErrImplementMe
}
func (e *EthModuleDummy) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash eth.EthHash, txIndex eth.EthUint64) (eth.EthTx, error) {
func (e *EthModuleDummy) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (eth.EthTx, error) {
return eth.EthTx{}, ErrImplementMe
}
func (e *EthModuleDummy) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum eth.EthUint64, txIndex eth.EthUint64) (eth.EthTx, error) {
func (e *EthModuleDummy) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (eth.EthTx, error) {
return eth.EthTx{}, ErrImplementMe
}
func (e *EthModuleDummy) EthGetCode(ctx context.Context, address eth.EthAddress, blkOpt string) (eth.EthBytes, error) {
func (e *EthModuleDummy) EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) {
return nil, ErrImplementMe
}
func (e *EthModuleDummy) EthGetStorageAt(ctx context.Context, address eth.EthAddress, position eth.EthBytes, blkParam string) (eth.EthBytes, error) {
func (e *EthModuleDummy) EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam string) (ethtypes.EthBytes, error) {
return nil, ErrImplementMe
}
func (e *EthModuleDummy) EthGetBalance(ctx context.Context, address eth.EthAddress, blkParam string) (eth.EthBigInt, error) {
return eth.EthBigIntZero, ErrImplementMe
func (e *EthModuleDummy) EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam string) (ethtypes.EthBigInt, error) {
return ethtypes.EthBigIntZero, ErrImplementMe
}
func (e *EthModuleDummy) EthFeeHistory(ctx context.Context, blkCount eth.EthUint64, newestBlk string, rewardPercentiles []float64) (eth.EthFeeHistory, error) {
return eth.EthFeeHistory{}, ErrImplementMe
func (e *EthModuleDummy) EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint64, newestBlk string, rewardPercentiles []float64) (ethtypes.EthFeeHistory, error) {
return ethtypes.EthFeeHistory{}, ErrImplementMe
}
func (e *EthModuleDummy) EthChainId(ctx context.Context) (eth.EthUint64, error) {
func (e *EthModuleDummy) EthChainId(ctx context.Context) (ethtypes.EthUint64, error) {
return 0, ErrImplementMe
}
@ -84,26 +85,26 @@ func (e *EthModuleDummy) NetListening(ctx context.Context) (bool, error) {
return false, ErrImplementMe
}
func (e *EthModuleDummy) EthProtocolVersion(ctx context.Context) (eth.EthUint64, error) {
func (e *EthModuleDummy) EthProtocolVersion(ctx context.Context) (ethtypes.EthUint64, error) {
return 0, ErrImplementMe
}
func (e *EthModuleDummy) EthGasPrice(ctx context.Context) (eth.EthBigInt, error) {
return eth.EthBigIntZero, ErrImplementMe
func (e *EthModuleDummy) EthGasPrice(ctx context.Context) (ethtypes.EthBigInt, error) {
return ethtypes.EthBigIntZero, ErrImplementMe
}
func (e *EthModuleDummy) EthEstimateGas(ctx context.Context, tx eth.EthCall) (eth.EthUint64, error) {
func (e *EthModuleDummy) EthEstimateGas(ctx context.Context, tx ethtypes.EthCall) (ethtypes.EthUint64, error) {
return 0, ErrImplementMe
}
func (e *EthModuleDummy) EthCall(ctx context.Context, tx eth.EthCall, blkParam string) (eth.EthBytes, error) {
func (e *EthModuleDummy) EthCall(ctx context.Context, tx ethtypes.EthCall, blkParam string) (ethtypes.EthBytes, error) {
return nil, ErrImplementMe
}
func (e *EthModuleDummy) EthMaxPriorityFeePerGas(ctx context.Context) (eth.EthBigInt, error) {
return eth.EthBigIntZero, ErrImplementMe
func (e *EthModuleDummy) EthMaxPriorityFeePerGas(ctx context.Context) (ethtypes.EthBigInt, error) {
return ethtypes.EthBigIntZero, ErrImplementMe
}
func (e *EthModuleDummy) EthSendRawTransaction(ctx context.Context, rawTx eth.EthBytes) (eth.EthHash, error) {
return eth.EthHash{}, ErrImplementMe
func (e *EthModuleDummy) EthSendRawTransaction(ctx context.Context, rawTx ethtypes.EthBytes) (ethtypes.EthHash, error) {
return ethtypes.EthHash{}, ErrImplementMe
}

View File

@ -27,34 +27,35 @@ import (
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)
type EthModuleAPI interface {
EthBlockNumber(ctx context.Context) (eth.EthUint64, error)
EthAccounts(ctx context.Context) ([]eth.EthAddress, error)
EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum eth.EthUint64) (eth.EthUint64, error)
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash eth.EthHash) (eth.EthUint64, error)
EthGetBlockByHash(ctx context.Context, blkHash eth.EthHash, fullTxInfo bool) (eth.EthBlock, error)
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (eth.EthBlock, error)
EthGetTransactionByHash(ctx context.Context, txHash *eth.EthHash) (*eth.EthTx, error)
EthGetTransactionCount(ctx context.Context, sender eth.EthAddress, blkOpt string) (eth.EthUint64, error)
EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*api.EthTxReceipt, error)
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash eth.EthHash, txIndex eth.EthUint64) (eth.EthTx, error)
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum eth.EthUint64, txIndex eth.EthUint64) (eth.EthTx, error)
EthGetCode(ctx context.Context, address eth.EthAddress, blkOpt string) (eth.EthBytes, error)
EthGetStorageAt(ctx context.Context, address eth.EthAddress, position eth.EthBytes, blkParam string) (eth.EthBytes, error)
EthGetBalance(ctx context.Context, address eth.EthAddress, blkParam string) (eth.EthBigInt, error)
EthFeeHistory(ctx context.Context, blkCount eth.EthUint64, newestBlk string, rewardPercentiles []float64) (eth.EthFeeHistory, error)
EthChainId(ctx context.Context) (eth.EthUint64, error)
EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error)
EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error)
EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum ethtypes.EthUint64) (ethtypes.EthUint64, error)
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error)
EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error)
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (ethtypes.EthBlock, error)
EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*eth.EthTx, 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) (eth.EthTx, error)
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (eth.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)
EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint64, newestBlk string, rewardPercentiles []float64) (ethtypes.EthFeeHistory, error)
EthChainId(ctx context.Context) (ethtypes.EthUint64, error)
NetVersion(ctx context.Context) (string, error)
NetListening(ctx context.Context) (bool, error)
EthProtocolVersion(ctx context.Context) (eth.EthUint64, error)
EthGasPrice(ctx context.Context) (eth.EthBigInt, error)
EthEstimateGas(ctx context.Context, tx eth.EthCall) (eth.EthUint64, error)
EthCall(ctx context.Context, tx eth.EthCall, blkParam string) (eth.EthBytes, error)
EthMaxPriorityFeePerGas(ctx context.Context) (eth.EthBigInt, error)
EthSendRawTransaction(ctx context.Context, rawTx eth.EthBytes) (eth.EthHash, error)
EthProtocolVersion(ctx context.Context) (ethtypes.EthUint64, error)
EthGasPrice(ctx context.Context) (ethtypes.EthBigInt, error)
EthEstimateGas(ctx context.Context, tx ethtypes.EthCall) (ethtypes.EthUint64, error)
EthCall(ctx context.Context, tx ethtypes.EthCall, blkParam string) (ethtypes.EthBytes, error)
EthMaxPriorityFeePerGas(ctx context.Context) (ethtypes.EthBigInt, error)
EthSendRawTransaction(ctx context.Context, rawTx ethtypes.EthBytes) (ethtypes.EthHash, error)
}
var _ EthModuleAPI = *new(api.FullNode)
@ -88,14 +89,14 @@ func (a *EthModule) StateNetworkName(ctx context.Context) (dtypes.NetworkName, e
return stmgr.GetNetworkName(ctx, a.StateManager, a.Chain.GetHeaviestTipSet().ParentState())
}
func (a *EthModule) EthBlockNumber(context.Context) (eth.EthUint64, error) {
func (a *EthModule) EthBlockNumber(context.Context) (ethtypes.EthUint64, error) {
height := a.Chain.GetHeaviestTipSet().Height()
return eth.EthUint64(height), nil
return ethtypes.EthUint64(height), nil
}
func (a *EthModule) EthAccounts(context.Context) ([]eth.EthAddress, error) {
func (a *EthModule) EthAccounts(context.Context) ([]ethtypes.EthAddress, error) {
// The lotus node is not expected to hold manage accounts, so we'll always return an empty array
return []eth.EthAddress{}, nil
return []ethtypes.EthAddress{}, nil
}
func (a *EthModule) countTipsetMsgs(ctx context.Context, ts *types.TipSet) (int, error) {
@ -112,54 +113,54 @@ func (a *EthModule) countTipsetMsgs(ctx context.Context, ts *types.TipSet) (int,
return count, nil
}
func (a *EthModule) EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum eth.EthUint64) (eth.EthUint64, error) {
func (a *EthModule) EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum ethtypes.EthUint64) (ethtypes.EthUint64, error) {
ts, err := a.Chain.GetTipsetByHeight(ctx, abi.ChainEpoch(blkNum), nil, false)
if err != nil {
return eth.EthUint64(0), xerrors.Errorf("error loading tipset %s: %w", ts, err)
return ethtypes.EthUint64(0), xerrors.Errorf("error loading tipset %s: %w", ts, err)
}
count, err := a.countTipsetMsgs(ctx, ts)
return eth.EthUint64(count), err
return ethtypes.EthUint64(count), err
}
func (a *EthModule) EthGetBlockTransactionCountByHash(ctx context.Context, blkHash eth.EthHash) (eth.EthUint64, error) {
func (a *EthModule) EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error) {
ts, err := a.Chain.GetTipSetByCid(ctx, blkHash.ToCid())
if err != nil {
return eth.EthUint64(0), xerrors.Errorf("error loading tipset %s: %w", ts, err)
return ethtypes.EthUint64(0), xerrors.Errorf("error loading tipset %s: %w", ts, err)
}
count, err := a.countTipsetMsgs(ctx, ts)
return eth.EthUint64(count), err
return ethtypes.EthUint64(count), err
}
func (a *EthModule) EthGetBlockByHash(ctx context.Context, blkHash eth.EthHash, fullTxInfo bool) (eth.EthBlock, error) {
func (a *EthModule) EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) {
ts, err := a.Chain.GetTipSetByCid(ctx, blkHash.ToCid())
if err != nil {
return eth.EthBlock{}, xerrors.Errorf("error loading tipset %s: %w", ts, err)
return ethtypes.EthBlock{}, xerrors.Errorf("error loading tipset %s: %w", ts, err)
}
return a.newEthBlockFromFilecoinTipSet(ctx, ts, fullTxInfo)
}
func (a *EthModule) EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (eth.EthBlock, error) {
typ, num, err := eth.ParseBlkNumOption(blkNum)
func (a *EthModule) EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (ethtypes.EthBlock, error) {
typ, num, err := ethtypes.ParseBlkNumOption(blkNum)
if err != nil {
return eth.EthBlock{}, fmt.Errorf("cannot parse block number: %v", err)
return ethtypes.EthBlock{}, fmt.Errorf("cannot parse block number: %v", err)
}
switch typ {
case eth.BlkNumLatest:
num = eth.EthUint64(a.Chain.GetHeaviestTipSet().Height()) - 1
case eth.BlkNumPending:
num = eth.EthUint64(a.Chain.GetHeaviestTipSet().Height())
case ethtypes.BlkNumLatest:
num = ethtypes.EthUint64(a.Chain.GetHeaviestTipSet().Height()) - 1
case ethtypes.BlkNumPending:
num = ethtypes.EthUint64(a.Chain.GetHeaviestTipSet().Height())
}
ts, err := a.Chain.GetTipsetByHeight(ctx, abi.ChainEpoch(num), nil, false)
if err != nil {
return eth.EthBlock{}, xerrors.Errorf("error loading tipset %s: %w", ts, err)
return ethtypes.EthBlock{}, xerrors.Errorf("error loading tipset %s: %w", ts, err)
}
return a.newEthBlockFromFilecoinTipSet(ctx, ts, fullTxInfo)
}
func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *eth.EthHash) (*eth.EthTx, error) {
func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*eth.EthTx, error) {
// Ethereum's behavior is to return null when the txHash is invalid, so we use nil to check if txHash is valid
if txHash == nil {
return nil, nil
@ -179,19 +180,19 @@ func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *eth.Eth
return &tx, nil
}
func (a *EthModule) EthGetTransactionCount(ctx context.Context, sender eth.EthAddress, blkParam string) (eth.EthUint64, error) {
func (a *EthModule) EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkParam string) (ethtypes.EthUint64, error) {
addr, err := sender.ToFilecoinAddress()
if err != nil {
return eth.EthUint64(0), nil
return ethtypes.EthUint64(0), nil
}
nonce, err := a.Mpool.GetNonce(ctx, addr, types.EmptyTSK)
if err != nil {
return eth.EthUint64(0), nil
return ethtypes.EthUint64(0), nil
}
return eth.EthUint64(nonce), nil
return ethtypes.EthUint64(nonce), nil
}
func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*api.EthTxReceipt, error) {
func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) {
cid := txHash.ToCid()
msgLookup, err := a.StateAPI.StateSearchMsg(ctx, types.EmptyTSK, cid, api.LookbackNoLimit, true)
@ -216,16 +217,16 @@ func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash eth.Eth
return &receipt, nil
}
func (a *EthModule) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash eth.EthHash, txIndex eth.EthUint64) (eth.EthTx, error) {
func (a *EthModule) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (eth.EthTx, error) {
return eth.EthTx{}, nil
}
func (a *EthModule) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum eth.EthUint64, txIndex eth.EthUint64) (eth.EthTx, error) {
func (a *EthModule) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (eth.EthTx, error) {
return eth.EthTx{}, nil
}
// EthGetCode returns string value of the compiled bytecode
func (a *EthModule) EthGetCode(ctx context.Context, ethAddr eth.EthAddress, blkOpt string) (eth.EthBytes, error) {
func (a *EthModule) EthGetCode(ctx context.Context, ethAddr ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) {
to, err := ethAddr.ToFilecoinAddress()
if err != nil {
return nil, xerrors.Errorf("cannot get Filecoin address: %w", err)
@ -289,7 +290,7 @@ func (a *EthModule) EthGetCode(ctx context.Context, ethAddr eth.EthAddress, blkO
return blk.RawData(), nil
}
func (a *EthModule) EthGetStorageAt(ctx context.Context, ethAddr eth.EthAddress, position eth.EthBytes, blkParam string) (eth.EthBytes, error) {
func (a *EthModule) EthGetStorageAt(ctx context.Context, ethAddr ethtypes.EthAddress, position ethtypes.EthBytes, blkParam string) (ethtypes.EthBytes, error) {
l := len(position)
if l > 32 {
return nil, fmt.Errorf("supplied storage key is too long")
@ -363,35 +364,35 @@ func (a *EthModule) EthGetStorageAt(ctx context.Context, ethAddr eth.EthAddress,
return res.MsgRct.Return, nil
}
func (a *EthModule) EthGetBalance(ctx context.Context, address eth.EthAddress, blkParam string) (eth.EthBigInt, error) {
func (a *EthModule) EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam string) (ethtypes.EthBigInt, error) {
filAddr, err := address.ToFilecoinAddress()
if err != nil {
return eth.EthBigInt{}, err
return ethtypes.EthBigInt{}, err
}
actor, err := a.StateGetActor(ctx, filAddr, types.EmptyTSK)
if xerrors.Is(err, types.ErrActorNotFound) {
return eth.EthBigIntZero, nil
return ethtypes.EthBigIntZero, nil
} else if err != nil {
return eth.EthBigInt{}, err
return ethtypes.EthBigInt{}, err
}
return eth.EthBigInt{Int: actor.Balance.Int}, nil
return ethtypes.EthBigInt{Int: actor.Balance.Int}, nil
}
func (a *EthModule) EthChainId(ctx context.Context) (eth.EthUint64, error) {
return eth.EthUint64(build.Eip155ChainId), nil
func (a *EthModule) EthChainId(ctx context.Context) (ethtypes.EthUint64, error) {
return ethtypes.EthUint64(build.Eip155ChainId), nil
}
func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount eth.EthUint64, newestBlkNum string, rewardPercentiles []float64) (eth.EthFeeHistory, error) {
func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint64, newestBlkNum string, rewardPercentiles []float64) (ethtypes.EthFeeHistory, error) {
if blkCount > 1024 {
return eth.EthFeeHistory{}, fmt.Errorf("block count should be smaller than 1024")
return ethtypes.EthFeeHistory{}, fmt.Errorf("block count should be smaller than 1024")
}
newestBlkHeight := uint64(a.Chain.GetHeaviestTipSet().Height())
// TODO https://github.com/filecoin-project/ref-fvm/issues/1016
var blkNum eth.EthUint64
var blkNum ethtypes.EthUint64
err := blkNum.UnmarshalJSON([]byte(`"` + newestBlkNum + `"`))
if err == nil && uint64(blkNum) < newestBlkHeight {
newestBlkHeight = uint64(blkNum)
@ -406,13 +407,13 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount eth.EthUint64, n
ts, err := a.Chain.GetTipsetByHeight(ctx, abi.ChainEpoch(newestBlkHeight), nil, false)
if err != nil {
return eth.EthFeeHistory{}, fmt.Errorf("cannot load find block height: %v", newestBlkHeight)
return ethtypes.EthFeeHistory{}, fmt.Errorf("cannot load find block height: %v", newestBlkHeight)
}
// FIXME: baseFeePerGas should include the next block after the newest of the returned range, because this
// can be inferred from the newest block. we use the newest block's baseFeePerGas for now but need to fix it
// In other words, due to deferred execution, we might not be returning the most useful value here for the client.
baseFeeArray := []eth.EthBigInt{eth.EthBigInt(ts.Blocks()[0].ParentBaseFee)}
baseFeeArray := []ethtypes.EthBigInt{ethtypes.EthBigInt(ts.Blocks()[0].ParentBaseFee)}
gasUsedRatioArray := []float64{}
for ts.Height() >= abi.ChainEpoch(oldestBlkHeight) {
@ -420,17 +421,17 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount eth.EthUint64, n
// totalize gas used in the tipset.
block, err := a.newEthBlockFromFilecoinTipSet(ctx, ts, false)
if err != nil {
return eth.EthFeeHistory{}, fmt.Errorf("cannot create eth block: %v", err)
return ethtypes.EthFeeHistory{}, fmt.Errorf("cannot create eth block: %v", err)
}
// both arrays should be reversed at the end
baseFeeArray = append(baseFeeArray, eth.EthBigInt(ts.Blocks()[0].ParentBaseFee))
baseFeeArray = append(baseFeeArray, ethtypes.EthBigInt(ts.Blocks()[0].ParentBaseFee))
gasUsedRatioArray = append(gasUsedRatioArray, float64(block.GasUsed)/float64(build.BlockGasLimit))
parentTsKey := ts.Parents()
ts, err = a.Chain.LoadTipSet(ctx, parentTsKey)
if err != nil {
return eth.EthFeeHistory{}, fmt.Errorf("cannot load tipset key: %v", parentTsKey)
return ethtypes.EthFeeHistory{}, fmt.Errorf("cannot load tipset key: %v", parentTsKey)
}
}
@ -443,7 +444,7 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount eth.EthUint64, n
gasUsedRatioArray[i], gasUsedRatioArray[j] = gasUsedRatioArray[j], gasUsedRatioArray[i]
}
return eth.EthFeeHistory{
return ethtypes.EthFeeHistory{
OldestBlock: oldestBlkHeight,
BaseFeePerGas: baseFeeArray,
GasUsedRatio: gasUsedRatioArray,
@ -463,20 +464,20 @@ func (a *EthModule) NetListening(ctx context.Context) (bool, error) {
return true, nil
}
func (a *EthModule) EthProtocolVersion(ctx context.Context) (eth.EthUint64, error) {
func (a *EthModule) EthProtocolVersion(ctx context.Context) (ethtypes.EthUint64, error) {
height := a.Chain.GetHeaviestTipSet().Height()
return eth.EthUint64(a.StateManager.GetNetworkVersion(ctx, height)), nil
return ethtypes.EthUint64(a.StateManager.GetNetworkVersion(ctx, height)), nil
}
func (a *EthModule) EthMaxPriorityFeePerGas(ctx context.Context) (eth.EthBigInt, error) {
func (a *EthModule) EthMaxPriorityFeePerGas(ctx context.Context) (ethtypes.EthBigInt, error) {
gasPremium, err := a.GasAPI.GasEstimateGasPremium(ctx, 0, builtin.SystemActorAddr, 10000, types.EmptyTSK)
if err != nil {
return eth.EthBigInt(big.Zero()), err
return ethtypes.EthBigInt(big.Zero()), err
}
return eth.EthBigInt(gasPremium), nil
return ethtypes.EthBigInt(gasPremium), nil
}
func (a *EthModule) EthGasPrice(ctx context.Context) (eth.EthBigInt, error) {
func (a *EthModule) EthGasPrice(ctx context.Context) (ethtypes.EthBigInt, error) {
// According to Geth's implementation, eth_gasPrice should return base + tip
// Ref: https://github.com/ethereum/pm/issues/328#issuecomment-853234014
@ -485,22 +486,22 @@ func (a *EthModule) EthGasPrice(ctx context.Context) (eth.EthBigInt, error) {
premium, err := a.EthMaxPriorityFeePerGas(ctx)
if err != nil {
return eth.EthBigInt(big.Zero()), nil
return ethtypes.EthBigInt(big.Zero()), nil
}
gasPrice := big.Add(baseFee, big.Int(premium))
return eth.EthBigInt(gasPrice), nil
return ethtypes.EthBigInt(gasPrice), nil
}
func (a *EthModule) EthSendRawTransaction(ctx context.Context, rawTx eth.EthBytes) (eth.EthHash, error) {
func (a *EthModule) EthSendRawTransaction(ctx context.Context, rawTx ethtypes.EthBytes) (ethtypes.EthHash, error) {
txArgs, err := eth.ParseEthTxArgs(rawTx)
if err != nil {
return eth.EmptyEthHash, err
return ethtypes.EmptyEthHash, err
}
smsg, err := txArgs.ToSignedMessage()
if err != nil {
return eth.EmptyEthHash, err
return ethtypes.EmptyEthHash, err
}
_, err = a.StateAPI.StateGetActor(ctx, smsg.Message.To, types.EmptyTSK)
@ -512,17 +513,17 @@ func (a *EthModule) EthSendRawTransaction(ctx context.Context, rawTx eth.EthByte
cid, err := a.MpoolAPI.MpoolPush(ctx, smsg)
if err != nil {
return eth.EmptyEthHash, err
return ethtypes.EmptyEthHash, err
}
return eth.NewEthHashFromCid(cid)
return ethtypes.NewEthHashFromCid(cid)
}
func (a *EthModule) ethCallToFilecoinMessage(ctx context.Context, tx eth.EthCall) (*types.Message, error) {
func (a *EthModule) ethCallToFilecoinMessage(ctx context.Context, tx ethtypes.EthCall) (*types.Message, error) {
var err error
var from address.Address
if tx.From == nil {
// Send from the filecoin "system" address.
from, err = (eth.EthAddress{}).ToFilecoinAddress()
from, err = (ethtypes.EthAddress{}).ToFilecoinAddress()
if err != nil {
return nil, fmt.Errorf("failed to construct the ethereum system address: %w", err)
}
@ -612,10 +613,10 @@ func (a *EthModule) applyMessage(ctx context.Context, msg *types.Message) (res *
return res, nil
}
func (a *EthModule) EthEstimateGas(ctx context.Context, tx eth.EthCall) (eth.EthUint64, error) {
func (a *EthModule) EthEstimateGas(ctx context.Context, tx ethtypes.EthCall) (ethtypes.EthUint64, error) {
msg, err := a.ethCallToFilecoinMessage(ctx, tx)
if err != nil {
return eth.EthUint64(0), err
return ethtypes.EthUint64(0), err
}
// Set the gas limit to the zero sentinel value, which makes
@ -624,13 +625,13 @@ func (a *EthModule) EthEstimateGas(ctx context.Context, tx eth.EthCall) (eth.Eth
msg, err = a.GasAPI.GasEstimateMessageGas(ctx, msg, nil, types.EmptyTSK)
if err != nil {
return eth.EthUint64(0), err
return ethtypes.EthUint64(0), err
}
return eth.EthUint64(msg.GasLimit), nil
return ethtypes.EthUint64(msg.GasLimit), nil
}
func (a *EthModule) EthCall(ctx context.Context, tx eth.EthCall, blkParam string) (eth.EthBytes, error) {
func (a *EthModule) EthCall(ctx context.Context, tx ethtypes.EthCall, blkParam string) (ethtypes.EthBytes, error) {
msg, err := a.ethCallToFilecoinMessage(ctx, tx)
if err != nil {
return nil, err
@ -643,38 +644,38 @@ func (a *EthModule) EthCall(ctx context.Context, tx eth.EthCall, blkParam string
if len(invokeResult.MsgRct.Return) > 0 {
return cbg.ReadByteArray(bytes.NewReader(invokeResult.MsgRct.Return), uint64(len(invokeResult.MsgRct.Return)))
}
return eth.EthBytes{}, nil
return ethtypes.EthBytes{}, nil
}
func (a *EthModule) newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types.TipSet, fullTxInfo bool) (eth.EthBlock, error) {
func (a *EthModule) newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types.TipSet, fullTxInfo bool) (ethtypes.EthBlock, error) {
parent, err := a.Chain.LoadTipSet(ctx, ts.Parents())
if err != nil {
return eth.EthBlock{}, err
return ethtypes.EthBlock{}, err
}
parentKeyCid, err := parent.Key().Cid()
if err != nil {
return eth.EthBlock{}, err
return ethtypes.EthBlock{}, err
}
parentBlkHash, err := eth.NewEthHashFromCid(parentKeyCid)
parentBlkHash, err := ethtypes.NewEthHashFromCid(parentKeyCid)
if err != nil {
return eth.EthBlock{}, err
return ethtypes.EthBlock{}, err
}
blkCid, err := ts.Key().Cid()
if err != nil {
return eth.EthBlock{}, err
return ethtypes.EthBlock{}, err
}
blkHash, err := eth.NewEthHashFromCid(blkCid)
blkHash, err := ethtypes.NewEthHashFromCid(blkCid)
if err != nil {
return eth.EthBlock{}, err
return ethtypes.EthBlock{}, err
}
blkMsgs, err := a.Chain.BlockMsgsForTipset(ctx, ts)
if err != nil {
return eth.EthBlock{}, xerrors.Errorf("error loading messages for tipset: %v: %w", ts, err)
return ethtypes.EthBlock{}, xerrors.Errorf("error loading messages for tipset: %v: %w", ts, err)
}
block := eth.NewEthBlock()
block := ethtypes.NewEthBlock()
// this seems to be a very expensive way to get gasUsed of the block. may need to find an efficient way to do it
gasUsed := int64(0)
@ -682,20 +683,20 @@ func (a *EthModule) newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types
for _, msg := range append(blkMsg.BlsMessages, blkMsg.SecpkMessages...) {
msgLookup, err := a.StateAPI.StateSearchMsg(ctx, types.EmptyTSK, msg.Cid(), api.LookbackNoLimit, true)
if err != nil || msgLookup == nil {
return eth.EthBlock{}, nil
return ethtypes.EthBlock{}, nil
}
gasUsed += msgLookup.Receipt.GasUsed
if fullTxInfo {
tx, err := a.newEthTxFromFilecoinMessageLookup(ctx, msgLookup)
if err != nil {
return eth.EthBlock{}, nil
return ethtypes.EthBlock{}, nil
}
block.Transactions = append(block.Transactions, tx)
} else {
hash, err := eth.NewEthHashFromCid(msg.Cid())
hash, err := ethtypes.NewEthHashFromCid(msg.Cid())
if err != nil {
return eth.EthBlock{}, err
return ethtypes.EthBlock{}, err
}
block.Transactions = append(block.Transactions, hash.String())
}
@ -703,11 +704,11 @@ func (a *EthModule) newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types
}
block.Hash = blkHash
block.Number = eth.EthUint64(ts.Height())
block.Number = ethtypes.EthUint64(ts.Height())
block.ParentHash = parentBlkHash
block.Timestamp = eth.EthUint64(ts.Blocks()[0].Timestamp)
block.BaseFeePerGas = eth.EthBigInt{Int: ts.Blocks()[0].ParentBaseFee.Int}
block.GasUsed = eth.EthUint64(gasUsed)
block.Timestamp = ethtypes.EthUint64(ts.Blocks()[0].Timestamp)
block.BaseFeePerGas = ethtypes.EthBigInt{Int: ts.Blocks()[0].ParentBaseFee.Int}
block.GasUsed = ethtypes.EthUint64(gasUsed)
return block, nil
}
@ -719,10 +720,10 @@ func (a *EthModule) newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types
// 3. Otherwise, we fall back to returning a masked ID Ethereum address. If the supplied address is an f0 address, we
// use that ID to form the masked ID address.
// 4. Otherwise, we fetch the actor's ID from the state tree and form the masked ID with it.
func (a *EthModule) lookupEthAddress(ctx context.Context, addr address.Address) (eth.EthAddress, error) {
func (a *EthModule) lookupEthAddress(ctx context.Context, addr address.Address) (ethtypes.EthAddress, error) {
// Attempt to convert directly.
if ethAddr, ok, err := eth.TryEthAddressFromFilecoinAddress(addr, false); err != nil {
return eth.EthAddress{}, err
if ethAddr, ok, err := ethtypes.TryEthAddressFromFilecoinAddress(addr, false); err != nil {
return ethtypes.EthAddress{}, err
} else if ok {
return ethAddr, nil
}
@ -730,19 +731,19 @@ func (a *EthModule) lookupEthAddress(ctx context.Context, addr address.Address)
// Lookup on the target actor.
actor, err := a.StateAPI.StateGetActor(ctx, addr, types.EmptyTSK)
if err != nil {
return eth.EthAddress{}, err
return ethtypes.EthAddress{}, err
}
if actor.Address != nil {
if ethAddr, ok, err := eth.TryEthAddressFromFilecoinAddress(*actor.Address, false); err != nil {
return eth.EthAddress{}, err
if ethAddr, ok, err := ethtypes.TryEthAddressFromFilecoinAddress(*actor.Address, false); err != nil {
return ethtypes.EthAddress{}, err
} else if ok {
return ethAddr, nil
}
}
// Check if we already have an ID addr, and use it if possible.
if ethAddr, ok, err := eth.TryEthAddressFromFilecoinAddress(addr, true); err != nil {
return eth.EthAddress{}, err
if ethAddr, ok, err := ethtypes.TryEthAddressFromFilecoinAddress(addr, true); err != nil {
return ethtypes.EthAddress{}, err
} else if ok {
return ethAddr, nil
}
@ -750,9 +751,9 @@ func (a *EthModule) lookupEthAddress(ctx context.Context, addr address.Address)
// Otherwise, resolve the ID addr.
idAddr, err := a.StateAPI.StateLookupID(ctx, addr, types.EmptyTSK)
if err != nil {
return eth.EthAddress{}, err
return ethtypes.EthAddress{}, err
}
return eth.EthAddressFromFilecoinAddress(idAddr)
return ethtypes.EthAddressFromFilecoinAddress(idAddr)
}
func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLookup *api.MsgLookup) (eth.EthTx, error) {
@ -760,7 +761,7 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
return eth.EthTx{}, fmt.Errorf("msg does not exist")
}
cid := msgLookup.Message
txHash, err := eth.NewEthHashFromCid(cid)
txHash, err := ethtypes.NewEthHashFromCid(cid)
if err != nil {
return eth.EthTx{}, err
}
@ -796,7 +797,7 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
return eth.EthTx{}, fmt.Errorf("cannot find the msg in the tipset")
}
blkHash, err := eth.NewEthHashFromCid(parentTsCid)
blkHash, err := ethtypes.NewEthHashFromCid(parentTsCid)
if err != nil {
return eth.EthTx{}, err
}
@ -846,21 +847,21 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
}
tx := eth.EthTx{
ChainID: eth.EthUint64(build.Eip155ChainId),
ChainID: ethtypes.EthUint64(build.Eip155ChainId),
Hash: txHash,
BlockHash: blkHash,
BlockNumber: eth.EthUint64(parentTs.Height()),
BlockNumber: ethtypes.EthUint64(parentTs.Height()),
From: fromEthAddr,
To: toAddr,
Value: eth.EthBigInt(msg.Value),
Type: eth.EthUint64(2),
TransactionIndex: eth.EthUint64(txIdx),
Gas: eth.EthUint64(msg.GasLimit),
MaxFeePerGas: eth.EthBigInt(msg.GasFeeCap),
MaxPriorityFeePerGas: eth.EthBigInt(msg.GasPremium),
V: eth.EthBytes{},
R: eth.EthBytes{},
S: eth.EthBytes{},
Value: ethtypes.EthBigInt(msg.Value),
Type: ethtypes.EthUint64(2),
TransactionIndex: ethtypes.EthUint64(txIdx),
Gas: ethtypes.EthUint64(msg.GasLimit),
MaxFeePerGas: ethtypes.EthBigInt(msg.GasFeeCap),
MaxPriorityFeePerGas: ethtypes.EthBigInt(msg.GasPremium),
V: ethtypes.EthBytes{},
R: ethtypes.EthBytes{},
S: ethtypes.EthBytes{},
Input: input,
}
return tx, nil
@ -874,7 +875,7 @@ func NewEthTxReceipt(tx eth.EthTx, lookup *api.MsgLookup, replay *api.InvocResul
BlockNumber: tx.BlockNumber,
From: tx.From,
To: tx.To,
StateRoot: eth.EmptyEthHash,
StateRoot: ethtypes.EmptyEthHash,
LogsBloom: []byte{0},
Logs: []string{},
}
@ -885,7 +886,7 @@ func NewEthTxReceipt(tx eth.EthTx, lookup *api.MsgLookup, replay *api.InvocResul
if err := ret.UnmarshalCBOR(bytes.NewReader(lookup.Receipt.Return)); err != nil {
return api.EthTxReceipt{}, xerrors.Errorf("failed to parse contract creation result: %w", err)
}
addr := eth.EthAddress(ret.EthAddress)
addr := ethtypes.EthAddress(ret.EthAddress)
receipt.ContractAddress = &addr
}
@ -896,12 +897,12 @@ func NewEthTxReceipt(tx eth.EthTx, lookup *api.MsgLookup, replay *api.InvocResul
receipt.Status = 0
}
receipt.GasUsed = eth.EthUint64(lookup.Receipt.GasUsed)
receipt.GasUsed = ethtypes.EthUint64(lookup.Receipt.GasUsed)
// TODO: handle CumulativeGasUsed
receipt.CumulativeGasUsed = eth.EmptyEthInt
receipt.CumulativeGasUsed = ethtypes.EmptyEthInt
effectiveGasPrice := big.Div(replay.GasCost.TotalCost, big.NewInt(lookup.Receipt.GasUsed))
receipt.EffectiveGasPrice = eth.EthBigInt(effectiveGasPrice)
receipt.EffectiveGasPrice = ethtypes.EthBigInt(effectiveGasPrice)
return receipt, nil
}