Move eth functions out of api

This commit is contained in:
Geoff Stuart 2022-12-14 01:12:52 -05:00
parent 0026ad8c09
commit 855c35cb88
15 changed files with 414 additions and 410 deletions

View File

@ -30,6 +30,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin"
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"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/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo/imports"
@ -763,37 +764,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) ([]EthAddress, error) //perm:read
EthAccounts(ctx context.Context) ([]eth.EthAddress, error) //perm:read
// EthBlockNumber returns the height of the latest (heaviest) TipSet
EthBlockNumber(ctx context.Context) (EthUint64, error) //perm:read
EthBlockNumber(ctx context.Context) (eth.EthUint64, error) //perm:read
// EthGetBlockTransactionCountByNumber returns the number of messages in the TipSet
EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum EthUint64) (EthUint64, error) //perm:read
EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum eth.EthUint64) (eth.EthUint64, error) //perm:read
// EthGetBlockTransactionCountByHash returns the number of messages in the TipSet
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash EthHash) (EthUint64, error) //perm:read
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash eth.EthHash) (eth.EthUint64, error) //perm:read
EthGetBlockByHash(ctx context.Context, blkHash EthHash, fullTxInfo bool) (EthBlock, error) //perm:read
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (EthBlock, error) //perm:read
EthGetTransactionByHash(ctx context.Context, txHash *EthHash) (*EthTx, error) //perm:read
EthGetTransactionCount(ctx context.Context, sender EthAddress, blkOpt string) (EthUint64, error) //perm:read
EthGetTransactionReceipt(ctx context.Context, txHash EthHash) (*EthTxReceipt, error) //perm:read
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash EthHash, txIndex EthUint64) (EthTx, error) //perm:read
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum EthUint64, txIndex EthUint64) (EthTx, 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) (*eth.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
EthGetCode(ctx context.Context, address EthAddress, blkOpt string) (EthBytes, error) //perm:read
EthGetStorageAt(ctx context.Context, address EthAddress, position EthBytes, blkParam string) (EthBytes, error) //perm:read
EthGetBalance(ctx context.Context, address EthAddress, blkParam string) (EthBigInt, error) //perm:read
EthChainId(ctx context.Context) (EthUint64, error) //perm:read
NetVersion(ctx context.Context) (string, error) //perm:read
NetListening(ctx context.Context) (bool, error) //perm:read
EthProtocolVersion(ctx context.Context) (EthUint64, error) //perm:read
EthGasPrice(ctx context.Context) (EthBigInt, error) //perm:read
EthFeeHistory(ctx context.Context, blkCount EthUint64, newestBlk string, rewardPercentiles []float64) (EthFeeHistory, 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
EthMaxPriorityFeePerGas(ctx context.Context) (EthBigInt, error) //perm:read
EthEstimateGas(ctx context.Context, tx EthCall) (EthUint64, error) //perm:read
EthCall(ctx context.Context, tx EthCall, blkParam string) (EthBytes, 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
EthSendRawTransaction(ctx context.Context, rawTx EthBytes) (EthHash, error) //perm:read
EthSendRawTransaction(ctx context.Context, rawTx eth.EthBytes) (eth.EthHash, error) //perm:read
// CreateBackup creates node backup onder the specified file name. The
// method requires that the lotus daemon is running with the

View File

@ -42,6 +42,7 @@ 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/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo/imports"
@ -369,16 +370,16 @@ func init() {
},
})
ethint := api.EthUint64(5)
ethint := eth.EthUint64(5)
addExample(ethint)
addExample(&ethint)
ethaddr, _ := api.EthAddressFromHex("0x5CbEeCF99d3fDB3f25E309Cc264f240bb0664031")
ethaddr, _ := eth.EthAddressFromHex("0x5CbEeCF99d3fDB3f25E309Cc264f240bb0664031")
addExample(&ethaddr)
ethhash, _ := api.NewEthHashFromCid(c)
ethhash, _ := eth.NewEthHashFromCid(c)
addExample(&ethhash)
ethFeeHistoryReward := [][]api.EthBigInt{}
ethFeeHistoryReward := [][]eth.EthBigInt{}
addExample(&ethFeeHistoryReward)
addExample(&uuid.UUID{})
}

View File

@ -36,6 +36,7 @@ import (
api "github.com/filecoin-project/lotus/api"
apitypes "github.com/filecoin-project/lotus/api/types"
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"
alerting "github.com/filecoin-project/lotus/journal/alerting"
dtypes "github.com/filecoin-project/lotus/node/modules/dtypes"
@ -922,10 +923,10 @@ func (mr *MockFullNodeMockRecorder) Discover(arg0 interface{}) *gomock.Call {
}
// EthAccounts mocks base method.
func (m *MockFullNode) EthAccounts(arg0 context.Context) ([]api.EthAddress, error) {
func (m *MockFullNode) EthAccounts(arg0 context.Context) ([]eth.EthAddress, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthAccounts", arg0)
ret0, _ := ret[0].([]api.EthAddress)
ret0, _ := ret[0].([]eth.EthAddress)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -937,10 +938,10 @@ func (mr *MockFullNodeMockRecorder) EthAccounts(arg0 interface{}) *gomock.Call {
}
// EthBlockNumber mocks base method.
func (m *MockFullNode) EthBlockNumber(arg0 context.Context) (api.EthUint64, error) {
func (m *MockFullNode) EthBlockNumber(arg0 context.Context) (eth.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthBlockNumber", arg0)
ret0, _ := ret[0].(api.EthUint64)
ret0, _ := ret[0].(eth.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -952,10 +953,10 @@ func (mr *MockFullNodeMockRecorder) EthBlockNumber(arg0 interface{}) *gomock.Cal
}
// EthCall mocks base method.
func (m *MockFullNode) EthCall(arg0 context.Context, arg1 api.EthCall, arg2 string) (api.EthBytes, error) {
func (m *MockFullNode) EthCall(arg0 context.Context, arg1 eth.EthCall, arg2 string) (eth.EthBytes, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthCall", arg0, arg1, arg2)
ret0, _ := ret[0].(api.EthBytes)
ret0, _ := ret[0].(eth.EthBytes)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -967,10 +968,10 @@ func (mr *MockFullNodeMockRecorder) EthCall(arg0, arg1, arg2 interface{}) *gomoc
}
// EthChainId mocks base method.
func (m *MockFullNode) EthChainId(arg0 context.Context) (api.EthUint64, error) {
func (m *MockFullNode) EthChainId(arg0 context.Context) (eth.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthChainId", arg0)
ret0, _ := ret[0].(api.EthUint64)
ret0, _ := ret[0].(eth.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -982,10 +983,10 @@ func (mr *MockFullNodeMockRecorder) EthChainId(arg0 interface{}) *gomock.Call {
}
// EthEstimateGas mocks base method.
func (m *MockFullNode) EthEstimateGas(arg0 context.Context, arg1 api.EthCall) (api.EthUint64, error) {
func (m *MockFullNode) EthEstimateGas(arg0 context.Context, arg1 eth.EthCall) (eth.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthEstimateGas", arg0, arg1)
ret0, _ := ret[0].(api.EthUint64)
ret0, _ := ret[0].(eth.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -997,10 +998,10 @@ func (mr *MockFullNodeMockRecorder) EthEstimateGas(arg0, arg1 interface{}) *gomo
}
// EthFeeHistory mocks base method.
func (m *MockFullNode) EthFeeHistory(arg0 context.Context, arg1 api.EthUint64, arg2 string, arg3 []float64) (api.EthFeeHistory, error) {
func (m *MockFullNode) EthFeeHistory(arg0 context.Context, arg1 eth.EthUint64, arg2 string, arg3 []float64) (eth.EthFeeHistory, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthFeeHistory", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(api.EthFeeHistory)
ret0, _ := ret[0].(eth.EthFeeHistory)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1012,10 +1013,10 @@ func (mr *MockFullNodeMockRecorder) EthFeeHistory(arg0, arg1, arg2, arg3 interfa
}
// EthGasPrice mocks base method.
func (m *MockFullNode) EthGasPrice(arg0 context.Context) (api.EthBigInt, error) {
func (m *MockFullNode) EthGasPrice(arg0 context.Context) (eth.EthBigInt, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGasPrice", arg0)
ret0, _ := ret[0].(api.EthBigInt)
ret0, _ := ret[0].(eth.EthBigInt)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1027,10 +1028,10 @@ func (mr *MockFullNodeMockRecorder) EthGasPrice(arg0 interface{}) *gomock.Call {
}
// EthGetBalance mocks base method.
func (m *MockFullNode) EthGetBalance(arg0 context.Context, arg1 api.EthAddress, arg2 string) (api.EthBigInt, error) {
func (m *MockFullNode) EthGetBalance(arg0 context.Context, arg1 eth.EthAddress, arg2 string) (eth.EthBigInt, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetBalance", arg0, arg1, arg2)
ret0, _ := ret[0].(api.EthBigInt)
ret0, _ := ret[0].(eth.EthBigInt)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1042,10 +1043,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBalance(arg0, arg1, arg2 interface{})
}
// EthGetBlockByHash mocks base method.
func (m *MockFullNode) EthGetBlockByHash(arg0 context.Context, arg1 api.EthHash, arg2 bool) (api.EthBlock, error) {
func (m *MockFullNode) EthGetBlockByHash(arg0 context.Context, arg1 eth.EthHash, arg2 bool) (eth.EthBlock, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetBlockByHash", arg0, arg1, arg2)
ret0, _ := ret[0].(api.EthBlock)
ret0, _ := ret[0].(eth.EthBlock)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1057,10 +1058,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBlockByHash(arg0, arg1, arg2 interface
}
// EthGetBlockByNumber mocks base method.
func (m *MockFullNode) EthGetBlockByNumber(arg0 context.Context, arg1 string, arg2 bool) (api.EthBlock, error) {
func (m *MockFullNode) EthGetBlockByNumber(arg0 context.Context, arg1 string, arg2 bool) (eth.EthBlock, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetBlockByNumber", arg0, arg1, arg2)
ret0, _ := ret[0].(api.EthBlock)
ret0, _ := ret[0].(eth.EthBlock)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1072,10 +1073,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBlockByNumber(arg0, arg1, arg2 interfa
}
// EthGetBlockTransactionCountByHash mocks base method.
func (m *MockFullNode) EthGetBlockTransactionCountByHash(arg0 context.Context, arg1 api.EthHash) (api.EthUint64, error) {
func (m *MockFullNode) EthGetBlockTransactionCountByHash(arg0 context.Context, arg1 eth.EthHash) (eth.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetBlockTransactionCountByHash", arg0, arg1)
ret0, _ := ret[0].(api.EthUint64)
ret0, _ := ret[0].(eth.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1087,10 +1088,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBlockTransactionCountByHash(arg0, arg1
}
// EthGetBlockTransactionCountByNumber mocks base method.
func (m *MockFullNode) EthGetBlockTransactionCountByNumber(arg0 context.Context, arg1 api.EthUint64) (api.EthUint64, error) {
func (m *MockFullNode) EthGetBlockTransactionCountByNumber(arg0 context.Context, arg1 eth.EthUint64) (eth.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetBlockTransactionCountByNumber", arg0, arg1)
ret0, _ := ret[0].(api.EthUint64)
ret0, _ := ret[0].(eth.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1102,10 +1103,10 @@ func (mr *MockFullNodeMockRecorder) EthGetBlockTransactionCountByNumber(arg0, ar
}
// EthGetCode mocks base method.
func (m *MockFullNode) EthGetCode(arg0 context.Context, arg1 api.EthAddress, arg2 string) (api.EthBytes, error) {
func (m *MockFullNode) EthGetCode(arg0 context.Context, arg1 eth.EthAddress, arg2 string) (eth.EthBytes, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetCode", arg0, arg1, arg2)
ret0, _ := ret[0].(api.EthBytes)
ret0, _ := ret[0].(eth.EthBytes)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1117,10 +1118,10 @@ func (mr *MockFullNodeMockRecorder) EthGetCode(arg0, arg1, arg2 interface{}) *go
}
// EthGetStorageAt mocks base method.
func (m *MockFullNode) EthGetStorageAt(arg0 context.Context, arg1 api.EthAddress, arg2 api.EthBytes, arg3 string) (api.EthBytes, error) {
func (m *MockFullNode) EthGetStorageAt(arg0 context.Context, arg1 eth.EthAddress, arg2 eth.EthBytes, arg3 string) (eth.EthBytes, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetStorageAt", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(api.EthBytes)
ret0, _ := ret[0].(eth.EthBytes)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1132,10 +1133,10 @@ func (mr *MockFullNodeMockRecorder) EthGetStorageAt(arg0, arg1, arg2, arg3 inter
}
// EthGetTransactionByBlockHashAndIndex mocks base method.
func (m *MockFullNode) EthGetTransactionByBlockHashAndIndex(arg0 context.Context, arg1 api.EthHash, arg2 api.EthUint64) (api.EthTx, error) {
func (m *MockFullNode) EthGetTransactionByBlockHashAndIndex(arg0 context.Context, arg1 eth.EthHash, arg2 eth.EthUint64) (eth.EthTx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetTransactionByBlockHashAndIndex", arg0, arg1, arg2)
ret0, _ := ret[0].(api.EthTx)
ret0, _ := ret[0].(eth.EthTx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1147,10 +1148,10 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionByBlockHashAndIndex(arg0, a
}
// EthGetTransactionByBlockNumberAndIndex mocks base method.
func (m *MockFullNode) EthGetTransactionByBlockNumberAndIndex(arg0 context.Context, arg1, arg2 api.EthUint64) (api.EthTx, error) {
func (m *MockFullNode) EthGetTransactionByBlockNumberAndIndex(arg0 context.Context, arg1, arg2 eth.EthUint64) (eth.EthTx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetTransactionByBlockNumberAndIndex", arg0, arg1, arg2)
ret0, _ := ret[0].(api.EthTx)
ret0, _ := ret[0].(eth.EthTx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1162,10 +1163,10 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionByBlockNumberAndIndex(arg0,
}
// EthGetTransactionByHash mocks base method.
func (m *MockFullNode) EthGetTransactionByHash(arg0 context.Context, arg1 *api.EthHash) (*api.EthTx, error) {
func (m *MockFullNode) EthGetTransactionByHash(arg0 context.Context, arg1 *eth.EthHash) (*eth.EthTx, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetTransactionByHash", arg0, arg1)
ret0, _ := ret[0].(*api.EthTx)
ret0, _ := ret[0].(*eth.EthTx)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1177,10 +1178,10 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionByHash(arg0, arg1 interface
}
// EthGetTransactionCount mocks base method.
func (m *MockFullNode) EthGetTransactionCount(arg0 context.Context, arg1 api.EthAddress, arg2 string) (api.EthUint64, error) {
func (m *MockFullNode) EthGetTransactionCount(arg0 context.Context, arg1 eth.EthAddress, arg2 string) (eth.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetTransactionCount", arg0, arg1, arg2)
ret0, _ := ret[0].(api.EthUint64)
ret0, _ := ret[0].(eth.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1192,10 +1193,10 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionCount(arg0, arg1, arg2 inte
}
// EthGetTransactionReceipt mocks base method.
func (m *MockFullNode) EthGetTransactionReceipt(arg0 context.Context, arg1 api.EthHash) (*api.EthTxReceipt, error) {
func (m *MockFullNode) EthGetTransactionReceipt(arg0 context.Context, arg1 eth.EthHash) (*eth.EthTxReceipt, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthGetTransactionReceipt", arg0, arg1)
ret0, _ := ret[0].(*api.EthTxReceipt)
ret0, _ := ret[0].(*eth.EthTxReceipt)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1207,10 +1208,10 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionReceipt(arg0, arg1 interfac
}
// EthMaxPriorityFeePerGas mocks base method.
func (m *MockFullNode) EthMaxPriorityFeePerGas(arg0 context.Context) (api.EthBigInt, error) {
func (m *MockFullNode) EthMaxPriorityFeePerGas(arg0 context.Context) (eth.EthBigInt, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthMaxPriorityFeePerGas", arg0)
ret0, _ := ret[0].(api.EthBigInt)
ret0, _ := ret[0].(eth.EthBigInt)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1222,10 +1223,10 @@ func (mr *MockFullNodeMockRecorder) EthMaxPriorityFeePerGas(arg0 interface{}) *g
}
// EthProtocolVersion mocks base method.
func (m *MockFullNode) EthProtocolVersion(arg0 context.Context) (api.EthUint64, error) {
func (m *MockFullNode) EthProtocolVersion(arg0 context.Context) (eth.EthUint64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthProtocolVersion", arg0)
ret0, _ := ret[0].(api.EthUint64)
ret0, _ := ret[0].(eth.EthUint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -1237,10 +1238,10 @@ func (mr *MockFullNodeMockRecorder) EthProtocolVersion(arg0 interface{}) *gomock
}
// EthSendRawTransaction mocks base method.
func (m *MockFullNode) EthSendRawTransaction(arg0 context.Context, arg1 api.EthBytes) (api.EthHash, error) {
func (m *MockFullNode) EthSendRawTransaction(arg0 context.Context, arg1 eth.EthBytes) (eth.EthHash, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthSendRawTransaction", arg0, arg1)
ret0, _ := ret[0].(api.EthHash)
ret0, _ := ret[0].(eth.EthHash)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View File

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

Binary file not shown.

View File

@ -28,7 +28,6 @@ import (
blockadt "github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
"github.com/filecoin-project/lotus/api"
bstore "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain"
@ -36,6 +35,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/consensus"
"github.com/filecoin-project/lotus/chain/eth"
"github.com/filecoin-project/lotus/chain/rand"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/stmgr"
@ -577,7 +577,7 @@ func (filec *FilecoinEC) checkBlockMessages(ctx context.Context, b *types.FullBl
digest := m.Message.Cid().Bytes()
if m.Signature.Type == crypto.SigTypeDelegated {
txArgs, err := api.NewEthTxArgsFromMessage(&m.Message)
txArgs, err := eth.NewEthTxArgsFromMessage(&m.Message)
if err != nil {
return err
}

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package api
package eth
import (
"bytes"
@ -18,7 +18,6 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/builtin/v10/eam"
"github.com/filecoin-project/lotus/build"
)
@ -198,46 +197,6 @@ type EthTxReceipt struct {
Logs []string `json:"logs"`
}
func NewEthTxReceipt(tx EthTx, lookup *MsgLookup, replay *InvocResult) (EthTxReceipt, error) {
receipt := EthTxReceipt{
TransactionHash: tx.Hash,
TransactionIndex: tx.TransactionIndex,
BlockHash: tx.BlockHash,
BlockNumber: tx.BlockNumber,
From: tx.From,
To: tx.To,
StateRoot: EmptyEthHash,
LogsBloom: []byte{0},
Logs: []string{},
}
if receipt.To == nil && lookup.Receipt.ExitCode.IsSuccess() {
// Create and Create2 return the same things.
var ret eam.CreateReturn
if err := ret.UnmarshalCBOR(bytes.NewReader(lookup.Receipt.Return)); err != nil {
return EthTxReceipt{}, xerrors.Errorf("failed to parse contract creation result: %w", err)
}
addr := EthAddress(ret.EthAddress)
receipt.ContractAddress = &addr
}
if lookup.Receipt.ExitCode.IsSuccess() {
receipt.Status = 1
}
if lookup.Receipt.ExitCode.IsError() {
receipt.Status = 0
}
receipt.GasUsed = EthUint64(lookup.Receipt.GasUsed)
// TODO: handle CumulativeGasUsed
receipt.CumulativeGasUsed = EmptyEthInt
effectiveGasPrice := big.Div(replay.GasCost.TotalCost, big.NewInt(lookup.Receipt.GasUsed))
receipt.EffectiveGasPrice = EthBigInt(effectiveGasPrice)
return receipt, nil
}
const (
EthAddressLength = 20
EthHashLength = 32

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package api
package eth
import (
"encoding/hex"

View File

@ -34,6 +34,7 @@ import (
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/eth"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
@ -776,7 +777,7 @@ func sigCacheKey(m *types.SignedMessage) (string, error) {
case crypto.SigTypeSecp256k1:
return string(m.Cid().Bytes()), nil
case crypto.SigTypeDelegated:
txArgs, err := api.NewEthTxArgsFromMessage(&m.Message)
txArgs, err := eth.NewEthTxArgsFromMessage(&m.Message)
if err != nil {
return "", err
}
@ -803,7 +804,7 @@ func (mp *MessagePool) VerifyMsgSig(m *types.SignedMessage) error {
}
if m.Signature.Type == crypto.SigTypeDelegated {
txArgs, err := api.NewEthTxArgsFromMessage(&m.Message)
txArgs, err := eth.NewEthTxArgsFromMessage(&m.Message)
if err != nil {
return err
}

View File

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

View File

@ -22,6 +22,7 @@ import (
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/eth"
"github.com/filecoin-project/lotus/chain/messagepool"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
@ -30,30 +31,30 @@ import (
)
type EthModuleAPI interface {
EthBlockNumber(ctx context.Context) (api.EthUint64, error)
EthAccounts(ctx context.Context) ([]api.EthAddress, error)
EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum api.EthUint64) (api.EthUint64, error)
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash api.EthHash) (api.EthUint64, error)
EthGetBlockByHash(ctx context.Context, blkHash api.EthHash, fullTxInfo bool) (api.EthBlock, error)
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (api.EthBlock, error)
EthGetTransactionByHash(ctx context.Context, txHash *api.EthHash) (*api.EthTx, error)
EthGetTransactionCount(ctx context.Context, sender api.EthAddress, blkOpt string) (api.EthUint64, error)
EthGetTransactionReceipt(ctx context.Context, txHash api.EthHash) (*api.EthTxReceipt, error)
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash api.EthHash, txIndex api.EthUint64) (api.EthTx, error)
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum api.EthUint64, txIndex api.EthUint64) (api.EthTx, error)
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 api.EthUint64, newestBlk string, rewardPercentiles []float64) (api.EthFeeHistory, error)
EthChainId(ctx context.Context) (api.EthUint64, error)
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) (*eth.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)
NetVersion(ctx context.Context) (string, error)
NetListening(ctx context.Context) (bool, error)
EthProtocolVersion(ctx context.Context) (api.EthUint64, error)
EthGasPrice(ctx context.Context) (api.EthBigInt, error)
EthEstimateGas(ctx context.Context, tx api.EthCall) (api.EthUint64, error)
EthCall(ctx context.Context, tx api.EthCall, blkParam string) (api.EthBytes, error)
EthMaxPriorityFeePerGas(ctx context.Context) (api.EthBigInt, error)
EthSendRawTransaction(ctx context.Context, rawTx api.EthBytes) (api.EthHash, 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)
}
var _ EthModuleAPI = *new(api.FullNode)
@ -87,14 +88,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) (api.EthUint64, error) {
func (a *EthModule) EthBlockNumber(context.Context) (eth.EthUint64, error) {
height := a.Chain.GetHeaviestTipSet().Height()
return api.EthUint64(height), nil
return eth.EthUint64(height), nil
}
func (a *EthModule) EthAccounts(context.Context) ([]api.EthAddress, error) {
func (a *EthModule) EthAccounts(context.Context) ([]eth.EthAddress, error) {
// The lotus node is not expected to hold manage accounts, so we'll always return an empty array
return []api.EthAddress{}, nil
return []eth.EthAddress{}, nil
}
func (a *EthModule) countTipsetMsgs(ctx context.Context, ts *types.TipSet) (int, error) {
@ -111,54 +112,54 @@ func (a *EthModule) countTipsetMsgs(ctx context.Context, ts *types.TipSet) (int,
return count, nil
}
func (a *EthModule) EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum api.EthUint64) (api.EthUint64, error) {
func (a *EthModule) EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum eth.EthUint64) (eth.EthUint64, error) {
ts, err := a.Chain.GetTipsetByHeight(ctx, abi.ChainEpoch(blkNum), nil, false)
if err != nil {
return api.EthUint64(0), xerrors.Errorf("error loading tipset %s: %w", ts, err)
return eth.EthUint64(0), xerrors.Errorf("error loading tipset %s: %w", ts, err)
}
count, err := a.countTipsetMsgs(ctx, ts)
return api.EthUint64(count), err
return eth.EthUint64(count), err
}
func (a *EthModule) EthGetBlockTransactionCountByHash(ctx context.Context, blkHash api.EthHash) (api.EthUint64, error) {
func (a *EthModule) EthGetBlockTransactionCountByHash(ctx context.Context, blkHash eth.EthHash) (eth.EthUint64, error) {
ts, err := a.Chain.GetTipSetByCid(ctx, blkHash.ToCid())
if err != nil {
return api.EthUint64(0), xerrors.Errorf("error loading tipset %s: %w", ts, err)
return eth.EthUint64(0), xerrors.Errorf("error loading tipset %s: %w", ts, err)
}
count, err := a.countTipsetMsgs(ctx, ts)
return api.EthUint64(count), err
return eth.EthUint64(count), err
}
func (a *EthModule) EthGetBlockByHash(ctx context.Context, blkHash api.EthHash, fullTxInfo bool) (api.EthBlock, error) {
func (a *EthModule) EthGetBlockByHash(ctx context.Context, blkHash eth.EthHash, fullTxInfo bool) (eth.EthBlock, error) {
ts, err := a.Chain.GetTipSetByCid(ctx, blkHash.ToCid())
if err != nil {
return api.EthBlock{}, xerrors.Errorf("error loading tipset %s: %w", ts, err)
return eth.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) (api.EthBlock, error) {
typ, num, err := api.ParseBlkNumOption(blkNum)
func (a *EthModule) EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (eth.EthBlock, error) {
typ, num, err := eth.ParseBlkNumOption(blkNum)
if err != nil {
return api.EthBlock{}, fmt.Errorf("cannot parse block number: %v", err)
return eth.EthBlock{}, fmt.Errorf("cannot parse block number: %v", err)
}
switch typ {
case api.BlkNumLatest:
num = api.EthUint64(a.Chain.GetHeaviestTipSet().Height()) - 1
case api.BlkNumPending:
num = api.EthUint64(a.Chain.GetHeaviestTipSet().Height())
case eth.BlkNumLatest:
num = eth.EthUint64(a.Chain.GetHeaviestTipSet().Height()) - 1
case eth.BlkNumPending:
num = eth.EthUint64(a.Chain.GetHeaviestTipSet().Height())
}
ts, err := a.Chain.GetTipsetByHeight(ctx, abi.ChainEpoch(num), nil, false)
if err != nil {
return api.EthBlock{}, xerrors.Errorf("error loading tipset %s: %w", ts, err)
return eth.EthBlock{}, xerrors.Errorf("error loading tipset %s: %w", ts, err)
}
return a.newEthBlockFromFilecoinTipSet(ctx, ts, fullTxInfo)
}
func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *api.EthHash) (*api.EthTx, error) {
func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *eth.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
@ -178,19 +179,19 @@ func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *api.Eth
return &tx, nil
}
func (a *EthModule) EthGetTransactionCount(ctx context.Context, sender api.EthAddress, blkParam string) (api.EthUint64, error) {
func (a *EthModule) EthGetTransactionCount(ctx context.Context, sender eth.EthAddress, blkParam string) (eth.EthUint64, error) {
addr, err := sender.ToFilecoinAddress()
if err != nil {
return api.EthUint64(0), nil
return eth.EthUint64(0), nil
}
nonce, err := a.Mpool.GetNonce(ctx, addr, types.EmptyTSK)
if err != nil {
return api.EthUint64(0), nil
return eth.EthUint64(0), nil
}
return api.EthUint64(nonce), nil
return eth.EthUint64(nonce), nil
}
func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash api.EthHash) (*api.EthTxReceipt, error) {
func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash eth.EthHash) (*eth.EthTxReceipt, error) {
cid := txHash.ToCid()
msgLookup, err := a.StateAPI.StateSearchMsg(ctx, types.EmptyTSK, cid, api.LookbackNoLimit, true)
@ -208,23 +209,23 @@ func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash api.Eth
return nil, nil
}
receipt, err := api.NewEthTxReceipt(tx, msgLookup, replay)
receipt, err := NewEthTxReceipt(tx, msgLookup, replay)
if err != nil {
return nil, nil
}
return &receipt, nil
}
func (a *EthModule) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash api.EthHash, txIndex api.EthUint64) (api.EthTx, error) {
return api.EthTx{}, nil
func (a *EthModule) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash eth.EthHash, txIndex eth.EthUint64) (eth.EthTx, error) {
return eth.EthTx{}, nil
}
func (a *EthModule) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum api.EthUint64, txIndex api.EthUint64) (api.EthTx, error) {
return api.EthTx{}, nil
func (a *EthModule) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum eth.EthUint64, txIndex eth.EthUint64) (eth.EthTx, error) {
return eth.EthTx{}, nil
}
// EthGetCode returns string value of the compiled bytecode
func (a *EthModule) EthGetCode(ctx context.Context, ethAddr api.EthAddress, blkOpt string) (api.EthBytes, error) {
func (a *EthModule) EthGetCode(ctx context.Context, ethAddr eth.EthAddress, blkOpt string) (eth.EthBytes, error) {
to, err := ethAddr.ToFilecoinAddress()
if err != nil {
return nil, xerrors.Errorf("cannot get Filecoin address: %w", err)
@ -288,7 +289,7 @@ func (a *EthModule) EthGetCode(ctx context.Context, ethAddr api.EthAddress, blkO
return blk.RawData(), nil
}
func (a *EthModule) EthGetStorageAt(ctx context.Context, ethAddr api.EthAddress, position api.EthBytes, blkParam string) (api.EthBytes, error) {
func (a *EthModule) EthGetStorageAt(ctx context.Context, ethAddr eth.EthAddress, position eth.EthBytes, blkParam string) (eth.EthBytes, error) {
l := len(position)
if l > 32 {
return nil, fmt.Errorf("supplied storage key is too long")
@ -362,35 +363,35 @@ func (a *EthModule) EthGetStorageAt(ctx context.Context, ethAddr api.EthAddress,
return res.MsgRct.Return, nil
}
func (a *EthModule) EthGetBalance(ctx context.Context, address api.EthAddress, blkParam string) (api.EthBigInt, error) {
func (a *EthModule) EthGetBalance(ctx context.Context, address eth.EthAddress, blkParam string) (eth.EthBigInt, error) {
filAddr, err := address.ToFilecoinAddress()
if err != nil {
return api.EthBigInt{}, err
return eth.EthBigInt{}, err
}
actor, err := a.StateGetActor(ctx, filAddr, types.EmptyTSK)
if xerrors.Is(err, types.ErrActorNotFound) {
return api.EthBigIntZero, nil
return eth.EthBigIntZero, nil
} else if err != nil {
return api.EthBigInt{}, err
return eth.EthBigInt{}, err
}
return api.EthBigInt{Int: actor.Balance.Int}, nil
return eth.EthBigInt{Int: actor.Balance.Int}, nil
}
func (a *EthModule) EthChainId(ctx context.Context) (api.EthUint64, error) {
return api.EthUint64(build.Eip155ChainId), nil
func (a *EthModule) EthChainId(ctx context.Context) (eth.EthUint64, error) {
return eth.EthUint64(build.Eip155ChainId), nil
}
func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount api.EthUint64, newestBlkNum string, rewardPercentiles []float64) (api.EthFeeHistory, error) {
func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount eth.EthUint64, newestBlkNum string, rewardPercentiles []float64) (eth.EthFeeHistory, error) {
if blkCount > 1024 {
return api.EthFeeHistory{}, fmt.Errorf("block count should be smaller than 1024")
return eth.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 api.EthUint64
var blkNum eth.EthUint64
err := blkNum.UnmarshalJSON([]byte(`"` + newestBlkNum + `"`))
if err == nil && uint64(blkNum) < newestBlkHeight {
newestBlkHeight = uint64(blkNum)
@ -405,13 +406,13 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount api.EthUint64, n
ts, err := a.Chain.GetTipsetByHeight(ctx, abi.ChainEpoch(newestBlkHeight), nil, false)
if err != nil {
return api.EthFeeHistory{}, fmt.Errorf("cannot load find block height: %v", newestBlkHeight)
return eth.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 := []api.EthBigInt{api.EthBigInt(ts.Blocks()[0].ParentBaseFee)}
baseFeeArray := []eth.EthBigInt{eth.EthBigInt(ts.Blocks()[0].ParentBaseFee)}
gasUsedRatioArray := []float64{}
for ts.Height() >= abi.ChainEpoch(oldestBlkHeight) {
@ -419,17 +420,17 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount api.EthUint64, n
// totalize gas used in the tipset.
block, err := a.newEthBlockFromFilecoinTipSet(ctx, ts, false)
if err != nil {
return api.EthFeeHistory{}, fmt.Errorf("cannot create eth block: %v", err)
return eth.EthFeeHistory{}, fmt.Errorf("cannot create eth block: %v", err)
}
// both arrays should be reversed at the end
baseFeeArray = append(baseFeeArray, api.EthBigInt(ts.Blocks()[0].ParentBaseFee))
baseFeeArray = append(baseFeeArray, eth.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 api.EthFeeHistory{}, fmt.Errorf("cannot load tipset key: %v", parentTsKey)
return eth.EthFeeHistory{}, fmt.Errorf("cannot load tipset key: %v", parentTsKey)
}
}
@ -442,7 +443,7 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount api.EthUint64, n
gasUsedRatioArray[i], gasUsedRatioArray[j] = gasUsedRatioArray[j], gasUsedRatioArray[i]
}
return api.EthFeeHistory{
return eth.EthFeeHistory{
OldestBlock: oldestBlkHeight,
BaseFeePerGas: baseFeeArray,
GasUsedRatio: gasUsedRatioArray,
@ -462,20 +463,20 @@ func (a *EthModule) NetListening(ctx context.Context) (bool, error) {
return true, nil
}
func (a *EthModule) EthProtocolVersion(ctx context.Context) (api.EthUint64, error) {
func (a *EthModule) EthProtocolVersion(ctx context.Context) (eth.EthUint64, error) {
height := a.Chain.GetHeaviestTipSet().Height()
return api.EthUint64(a.StateManager.GetNetworkVersion(ctx, height)), nil
return eth.EthUint64(a.StateManager.GetNetworkVersion(ctx, height)), nil
}
func (a *EthModule) EthMaxPriorityFeePerGas(ctx context.Context) (api.EthBigInt, error) {
func (a *EthModule) EthMaxPriorityFeePerGas(ctx context.Context) (eth.EthBigInt, error) {
gasPremium, err := a.GasAPI.GasEstimateGasPremium(ctx, 0, builtin.SystemActorAddr, 10000, types.EmptyTSK)
if err != nil {
return api.EthBigInt(big.Zero()), err
return eth.EthBigInt(big.Zero()), err
}
return api.EthBigInt(gasPremium), nil
return eth.EthBigInt(gasPremium), nil
}
func (a *EthModule) EthGasPrice(ctx context.Context) (api.EthBigInt, error) {
func (a *EthModule) EthGasPrice(ctx context.Context) (eth.EthBigInt, error) {
// According to Geth's implementation, eth_gasPrice should return base + tip
// Ref: https://github.com/ethereum/pm/issues/328#issuecomment-853234014
@ -484,22 +485,22 @@ func (a *EthModule) EthGasPrice(ctx context.Context) (api.EthBigInt, error) {
premium, err := a.EthMaxPriorityFeePerGas(ctx)
if err != nil {
return api.EthBigInt(big.Zero()), nil
return eth.EthBigInt(big.Zero()), nil
}
gasPrice := big.Add(baseFee, big.Int(premium))
return api.EthBigInt(gasPrice), nil
return eth.EthBigInt(gasPrice), nil
}
func (a *EthModule) EthSendRawTransaction(ctx context.Context, rawTx api.EthBytes) (api.EthHash, error) {
txArgs, err := api.ParseEthTxArgs(rawTx)
func (a *EthModule) EthSendRawTransaction(ctx context.Context, rawTx eth.EthBytes) (eth.EthHash, error) {
txArgs, err := eth.ParseEthTxArgs(rawTx)
if err != nil {
return api.EmptyEthHash, err
return eth.EmptyEthHash, err
}
smsg, err := txArgs.ToSignedMessage()
if err != nil {
return api.EmptyEthHash, err
return eth.EmptyEthHash, err
}
_, err = a.StateAPI.StateGetActor(ctx, smsg.Message.To, types.EmptyTSK)
@ -511,17 +512,17 @@ func (a *EthModule) EthSendRawTransaction(ctx context.Context, rawTx api.EthByte
cid, err := a.MpoolAPI.MpoolPush(ctx, smsg)
if err != nil {
return api.EmptyEthHash, err
return eth.EmptyEthHash, err
}
return api.NewEthHashFromCid(cid)
return eth.NewEthHashFromCid(cid)
}
func (a *EthModule) ethCallToFilecoinMessage(ctx context.Context, tx api.EthCall) (*types.Message, error) {
func (a *EthModule) ethCallToFilecoinMessage(ctx context.Context, tx eth.EthCall) (*types.Message, error) {
var err error
var from address.Address
if tx.From == nil {
// Send from the filecoin "system" address.
from, err = (api.EthAddress{}).ToFilecoinAddress()
from, err = (eth.EthAddress{}).ToFilecoinAddress()
if err != nil {
return nil, fmt.Errorf("failed to construct the ethereum system address: %w", err)
}
@ -611,10 +612,10 @@ func (a *EthModule) applyMessage(ctx context.Context, msg *types.Message) (res *
return res, nil
}
func (a *EthModule) EthEstimateGas(ctx context.Context, tx api.EthCall) (api.EthUint64, error) {
func (a *EthModule) EthEstimateGas(ctx context.Context, tx eth.EthCall) (eth.EthUint64, error) {
msg, err := a.ethCallToFilecoinMessage(ctx, tx)
if err != nil {
return api.EthUint64(0), err
return eth.EthUint64(0), err
}
// Set the gas limit to the zero sentinel value, which makes
@ -623,13 +624,13 @@ func (a *EthModule) EthEstimateGas(ctx context.Context, tx api.EthCall) (api.Eth
msg, err = a.GasAPI.GasEstimateMessageGas(ctx, msg, nil, types.EmptyTSK)
if err != nil {
return api.EthUint64(0), err
return eth.EthUint64(0), err
}
return api.EthUint64(msg.GasLimit), nil
return eth.EthUint64(msg.GasLimit), nil
}
func (a *EthModule) EthCall(ctx context.Context, tx api.EthCall, blkParam string) (api.EthBytes, error) {
func (a *EthModule) EthCall(ctx context.Context, tx eth.EthCall, blkParam string) (eth.EthBytes, error) {
msg, err := a.ethCallToFilecoinMessage(ctx, tx)
if err != nil {
return nil, err
@ -642,38 +643,38 @@ func (a *EthModule) EthCall(ctx context.Context, tx api.EthCall, blkParam string
if len(invokeResult.MsgRct.Return) > 0 {
return cbg.ReadByteArray(bytes.NewReader(invokeResult.MsgRct.Return), uint64(len(invokeResult.MsgRct.Return)))
}
return api.EthBytes{}, nil
return eth.EthBytes{}, nil
}
func (a *EthModule) newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types.TipSet, fullTxInfo bool) (api.EthBlock, error) {
func (a *EthModule) newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types.TipSet, fullTxInfo bool) (eth.EthBlock, error) {
parent, err := a.Chain.LoadTipSet(ctx, ts.Parents())
if err != nil {
return api.EthBlock{}, err
return eth.EthBlock{}, err
}
parentKeyCid, err := parent.Key().Cid()
if err != nil {
return api.EthBlock{}, err
return eth.EthBlock{}, err
}
parentBlkHash, err := api.NewEthHashFromCid(parentKeyCid)
parentBlkHash, err := eth.NewEthHashFromCid(parentKeyCid)
if err != nil {
return api.EthBlock{}, err
return eth.EthBlock{}, err
}
blkCid, err := ts.Key().Cid()
if err != nil {
return api.EthBlock{}, err
return eth.EthBlock{}, err
}
blkHash, err := api.NewEthHashFromCid(blkCid)
blkHash, err := eth.NewEthHashFromCid(blkCid)
if err != nil {
return api.EthBlock{}, err
return eth.EthBlock{}, err
}
blkMsgs, err := a.Chain.BlockMsgsForTipset(ctx, ts)
if err != nil {
return api.EthBlock{}, xerrors.Errorf("error loading messages for tipset: %v: %w", ts, err)
return eth.EthBlock{}, xerrors.Errorf("error loading messages for tipset: %v: %w", ts, err)
}
block := api.NewEthBlock()
block := eth.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)
@ -681,20 +682,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 api.EthBlock{}, nil
return eth.EthBlock{}, nil
}
gasUsed += msgLookup.Receipt.GasUsed
if fullTxInfo {
tx, err := a.newEthTxFromFilecoinMessageLookup(ctx, msgLookup)
if err != nil {
return api.EthBlock{}, nil
return eth.EthBlock{}, nil
}
block.Transactions = append(block.Transactions, tx)
} else {
hash, err := api.NewEthHashFromCid(msg.Cid())
hash, err := eth.NewEthHashFromCid(msg.Cid())
if err != nil {
return api.EthBlock{}, err
return eth.EthBlock{}, err
}
block.Transactions = append(block.Transactions, hash.String())
}
@ -702,11 +703,11 @@ func (a *EthModule) newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types
}
block.Hash = blkHash
block.Number = api.EthUint64(ts.Height())
block.Number = eth.EthUint64(ts.Height())
block.ParentHash = parentBlkHash
block.Timestamp = api.EthUint64(ts.Blocks()[0].Timestamp)
block.BaseFeePerGas = api.EthBigInt{Int: ts.Blocks()[0].ParentBaseFee.Int}
block.GasUsed = api.EthUint64(gasUsed)
block.Timestamp = eth.EthUint64(ts.Blocks()[0].Timestamp)
block.BaseFeePerGas = eth.EthBigInt{Int: ts.Blocks()[0].ParentBaseFee.Int}
block.GasUsed = eth.EthUint64(gasUsed)
return block, nil
}
@ -718,10 +719,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) (api.EthAddress, error) {
func (a *EthModule) lookupEthAddress(ctx context.Context, addr address.Address) (eth.EthAddress, error) {
// Attempt to convert directly.
if ethAddr, ok, err := api.TryEthAddressFromFilecoinAddress(addr, false); err != nil {
return api.EthAddress{}, err
if ethAddr, ok, err := eth.TryEthAddressFromFilecoinAddress(addr, false); err != nil {
return eth.EthAddress{}, err
} else if ok {
return ethAddr, nil
}
@ -729,19 +730,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 api.EthAddress{}, err
return eth.EthAddress{}, err
}
if actor.Address != nil {
if ethAddr, ok, err := api.TryEthAddressFromFilecoinAddress(*actor.Address, false); err != nil {
return api.EthAddress{}, err
if ethAddr, ok, err := eth.TryEthAddressFromFilecoinAddress(*actor.Address, false); err != nil {
return eth.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 := api.TryEthAddressFromFilecoinAddress(addr, true); err != nil {
return api.EthAddress{}, err
if ethAddr, ok, err := eth.TryEthAddressFromFilecoinAddress(addr, true); err != nil {
return eth.EthAddress{}, err
} else if ok {
return ethAddr, nil
}
@ -749,42 +750,42 @@ 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 api.EthAddress{}, err
return eth.EthAddress{}, err
}
return api.EthAddressFromFilecoinAddress(idAddr)
return eth.EthAddressFromFilecoinAddress(idAddr)
}
func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLookup *api.MsgLookup) (api.EthTx, error) {
func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLookup *api.MsgLookup) (eth.EthTx, error) {
if msgLookup == nil {
return api.EthTx{}, fmt.Errorf("msg does not exist")
return eth.EthTx{}, fmt.Errorf("msg does not exist")
}
cid := msgLookup.Message
txHash, err := api.NewEthHashFromCid(cid)
txHash, err := eth.NewEthHashFromCid(cid)
if err != nil {
return api.EthTx{}, err
return eth.EthTx{}, err
}
ts, err := a.Chain.LoadTipSet(ctx, msgLookup.TipSet)
if err != nil {
return api.EthTx{}, err
return eth.EthTx{}, err
}
// This tx is located in the parent tipset
parentTs, err := a.Chain.LoadTipSet(ctx, ts.Parents())
if err != nil {
return api.EthTx{}, err
return eth.EthTx{}, err
}
parentTsCid, err := parentTs.Key().Cid()
if err != nil {
return api.EthTx{}, err
return eth.EthTx{}, err
}
// lookup the transactionIndex
txIdx := -1
msgs, err := a.Chain.MessagesForTipset(ctx, parentTs)
if err != nil {
return api.EthTx{}, err
return eth.EthTx{}, err
}
for i, msg := range msgs {
if msg.Cid() == msgLookup.Message {
@ -792,27 +793,27 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
}
}
if txIdx == -1 {
return api.EthTx{}, fmt.Errorf("cannot find the msg in the tipset")
return eth.EthTx{}, fmt.Errorf("cannot find the msg in the tipset")
}
blkHash, err := api.NewEthHashFromCid(parentTsCid)
blkHash, err := eth.NewEthHashFromCid(parentTsCid)
if err != nil {
return api.EthTx{}, err
return eth.EthTx{}, err
}
msg, err := a.ChainAPI.ChainGetMessage(ctx, msgLookup.Message)
if err != nil {
return api.EthTx{}, err
return eth.EthTx{}, err
}
fromEthAddr, err := a.lookupEthAddress(ctx, msg.From)
if err != nil {
return api.EthTx{}, err
return eth.EthTx{}, err
}
toEthAddr, err := a.lookupEthAddress(ctx, msg.To)
if err != nil {
return api.EthTx{}, err
return eth.EthTx{}, err
}
toAddr := &toEthAddr
@ -833,7 +834,7 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
input = params.Initcode
}
if err != nil {
return api.EthTx{}, err
return eth.EthTx{}, err
}
}
// Otherwise, try to decode as a cbor byte array.
@ -844,23 +845,63 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
}
}
tx := api.EthTx{
ChainID: api.EthUint64(build.Eip155ChainId),
tx := eth.EthTx{
ChainID: eth.EthUint64(build.Eip155ChainId),
Hash: txHash,
BlockHash: blkHash,
BlockNumber: api.EthUint64(parentTs.Height()),
BlockNumber: eth.EthUint64(parentTs.Height()),
From: fromEthAddr,
To: toAddr,
Value: api.EthBigInt(msg.Value),
Type: api.EthUint64(2),
TransactionIndex: api.EthUint64(txIdx),
Gas: api.EthUint64(msg.GasLimit),
MaxFeePerGas: api.EthBigInt(msg.GasFeeCap),
MaxPriorityFeePerGas: api.EthBigInt(msg.GasPremium),
V: api.EthBytes{},
R: api.EthBytes{},
S: api.EthBytes{},
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{},
Input: input,
}
return tx, nil
}
func NewEthTxReceipt(tx eth.EthTx, lookup *api.MsgLookup, replay *api.InvocResult) (eth.EthTxReceipt, error) {
receipt := eth.EthTxReceipt{
TransactionHash: tx.Hash,
TransactionIndex: tx.TransactionIndex,
BlockHash: tx.BlockHash,
BlockNumber: tx.BlockNumber,
From: tx.From,
To: tx.To,
StateRoot: eth.EmptyEthHash,
LogsBloom: []byte{0},
Logs: []string{},
}
if receipt.To == nil && lookup.Receipt.ExitCode.IsSuccess() {
// Create and Create2 return the same things.
var ret eam.CreateReturn
if err := ret.UnmarshalCBOR(bytes.NewReader(lookup.Receipt.Return)); err != nil {
return eth.EthTxReceipt{}, xerrors.Errorf("failed to parse contract creation result: %w", err)
}
addr := eth.EthAddress(ret.EthAddress)
receipt.ContractAddress = &addr
}
if lookup.Receipt.ExitCode.IsSuccess() {
receipt.Status = 1
}
if lookup.Receipt.ExitCode.IsError() {
receipt.Status = 0
}
receipt.GasUsed = eth.EthUint64(lookup.Receipt.GasUsed)
// TODO: handle CumulativeGasUsed
receipt.CumulativeGasUsed = eth.EmptyEthInt
effectiveGasPrice := big.Div(replay.GasCost.TotalCost, big.NewInt(lookup.Receipt.GasUsed))
receipt.EffectiveGasPrice = eth.EthBigInt(effectiveGasPrice)
return receipt, nil
}