Merge pull request #9872 from filecoin-project/gstuart/dont-depend-on-api-refactor-minimal
chore: Move eth functions out of api
This commit is contained in:
commit
0c305ed957
@ -30,7 +30,9 @@ 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/chain/types/ethtypes"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/repo/imports"
|
||||
)
|
||||
@ -763,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) ([]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) (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 EthUint64) (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 EthHash) (EthUint64, error) //perm:read
|
||||
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.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 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 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 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) (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) (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 EthBytes) (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
|
||||
@ -1288,3 +1290,22 @@ type PruneOpts struct {
|
||||
MovingGC bool
|
||||
RetainState int64
|
||||
}
|
||||
|
||||
type EthTxReceipt struct {
|
||||
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 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"`
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"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"
|
||||
@ -369,16 +370,16 @@ func init() {
|
||||
},
|
||||
})
|
||||
|
||||
ethint := api.EthUint64(5)
|
||||
ethint := ethtypes.EthUint64(5)
|
||||
|
||||
addExample(ethint)
|
||||
addExample(ðint)
|
||||
ethaddr, _ := api.EthAddressFromHex("0x5CbEeCF99d3fDB3f25E309Cc264f240bb0664031")
|
||||
ethaddr, _ := ethtypes.EthAddressFromHex("0x5CbEeCF99d3fDB3f25E309Cc264f240bb0664031")
|
||||
addExample(ðaddr)
|
||||
ethhash, _ := api.NewEthHashFromCid(c)
|
||||
ethhash, _ := ethtypes.NewEthHashFromCid(c)
|
||||
addExample(ðhash)
|
||||
|
||||
ethFeeHistoryReward := [][]api.EthBigInt{}
|
||||
ethFeeHistoryReward := [][]ethtypes.EthBigInt{}
|
||||
addExample(ðFeeHistoryReward)
|
||||
addExample(&uuid.UUID{})
|
||||
}
|
||||
|
@ -36,7 +36,9 @@ 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"
|
||||
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"
|
||||
@ -922,10 +924,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) ([]ethtypes.EthAddress, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthAccounts", arg0)
|
||||
ret0, _ := ret[0].([]api.EthAddress)
|
||||
ret0, _ := ret[0].([]ethtypes.EthAddress)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -937,10 +939,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) (ethtypes.EthUint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthBlockNumber", arg0)
|
||||
ret0, _ := ret[0].(api.EthUint64)
|
||||
ret0, _ := ret[0].(ethtypes.EthUint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -952,10 +954,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 ethtypes.EthCall, arg2 string) (ethtypes.EthBytes, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthCall", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(api.EthBytes)
|
||||
ret0, _ := ret[0].(ethtypes.EthBytes)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -967,10 +969,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) (ethtypes.EthUint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthChainId", arg0)
|
||||
ret0, _ := ret[0].(api.EthUint64)
|
||||
ret0, _ := ret[0].(ethtypes.EthUint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -982,10 +984,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 ethtypes.EthCall) (ethtypes.EthUint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthEstimateGas", arg0, arg1)
|
||||
ret0, _ := ret[0].(api.EthUint64)
|
||||
ret0, _ := ret[0].(ethtypes.EthUint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -997,10 +999,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 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].(api.EthFeeHistory)
|
||||
ret0, _ := ret[0].(ethtypes.EthFeeHistory)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1012,10 +1014,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) (ethtypes.EthBigInt, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthGasPrice", arg0)
|
||||
ret0, _ := ret[0].(api.EthBigInt)
|
||||
ret0, _ := ret[0].(ethtypes.EthBigInt)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1027,10 +1029,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 ethtypes.EthAddress, arg2 string) (ethtypes.EthBigInt, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthGetBalance", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(api.EthBigInt)
|
||||
ret0, _ := ret[0].(ethtypes.EthBigInt)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1042,10 +1044,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 ethtypes.EthHash, arg2 bool) (ethtypes.EthBlock, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthGetBlockByHash", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(api.EthBlock)
|
||||
ret0, _ := ret[0].(ethtypes.EthBlock)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1057,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) (api.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].(api.EthBlock)
|
||||
ret0, _ := ret[0].(ethtypes.EthBlock)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1072,10 +1074,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 ethtypes.EthHash) (ethtypes.EthUint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthGetBlockTransactionCountByHash", arg0, arg1)
|
||||
ret0, _ := ret[0].(api.EthUint64)
|
||||
ret0, _ := ret[0].(ethtypes.EthUint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1087,10 +1089,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 ethtypes.EthUint64) (ethtypes.EthUint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthGetBlockTransactionCountByNumber", arg0, arg1)
|
||||
ret0, _ := ret[0].(api.EthUint64)
|
||||
ret0, _ := ret[0].(ethtypes.EthUint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1102,10 +1104,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 ethtypes.EthAddress, arg2 string) (ethtypes.EthBytes, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthGetCode", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(api.EthBytes)
|
||||
ret0, _ := ret[0].(ethtypes.EthBytes)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1117,10 +1119,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 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].(api.EthBytes)
|
||||
ret0, _ := ret[0].(ethtypes.EthBytes)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1132,10 +1134,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 ethtypes.EthHash, arg2 ethtypes.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 +1149,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 ethtypes.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 +1164,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 *ethtypes.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 +1179,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 ethtypes.EthAddress, arg2 string) (ethtypes.EthUint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthGetTransactionCount", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(api.EthUint64)
|
||||
ret0, _ := ret[0].(ethtypes.EthUint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1192,7 +1194,7 @@ 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 ethtypes.EthHash) (*api.EthTxReceipt, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthGetTransactionReceipt", arg0, arg1)
|
||||
ret0, _ := ret[0].(*api.EthTxReceipt)
|
||||
@ -1207,10 +1209,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) (ethtypes.EthBigInt, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthMaxPriorityFeePerGas", arg0)
|
||||
ret0, _ := ret[0].(api.EthBigInt)
|
||||
ret0, _ := ret[0].(ethtypes.EthBigInt)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1222,10 +1224,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) (ethtypes.EthUint64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthProtocolVersion", arg0)
|
||||
ret0, _ := ret[0].(api.EthUint64)
|
||||
ret0, _ := ret[0].(ethtypes.EthUint64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -1237,10 +1239,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 ethtypes.EthBytes) (ethtypes.EthHash, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EthSendRawTransaction", arg0, arg1)
|
||||
ret0, _ := ret[0].(api.EthHash)
|
||||
ret0, _ := ret[0].(ethtypes.EthHash)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
215
api/proxy_gen.go
215
api/proxy_gen.go
@ -35,9 +35,10 @@ 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/chain/types/ethtypes"
|
||||
"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 +220,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) ([]ethtypes.EthAddress, error) `perm:"read"`
|
||||
|
||||
EthBlockNumber func(p0 context.Context) (EthUint64, error) `perm:"read"`
|
||||
EthBlockNumber func(p0 context.Context) (ethtypes.EthUint64, error) `perm:"read"`
|
||||
|
||||
EthCall func(p0 context.Context, p1 EthCall, p2 string) (EthBytes, error) `perm:"read"`
|
||||
EthCall func(p0 context.Context, p1 ethtypes.EthCall, p2 string) (ethtypes.EthBytes, error) `perm:"read"`
|
||||
|
||||
EthChainId func(p0 context.Context) (EthUint64, error) `perm:"read"`
|
||||
EthChainId func(p0 context.Context) (ethtypes.EthUint64, error) `perm:"read"`
|
||||
|
||||
EthEstimateGas func(p0 context.Context, p1 EthCall) (EthUint64, error) `perm:"read"`
|
||||
EthEstimateGas func(p0 context.Context, p1 ethtypes.EthCall) (ethtypes.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 ethtypes.EthUint64, p2 string, p3 []float64) (ethtypes.EthFeeHistory, error) `perm:"read"`
|
||||
|
||||
EthGasPrice func(p0 context.Context) (EthBigInt, error) `perm:"read"`
|
||||
EthGasPrice func(p0 context.Context) (ethtypes.EthBigInt, error) `perm:"read"`
|
||||
|
||||
EthGetBalance func(p0 context.Context, p1 EthAddress, p2 string) (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 EthHash, p2 bool) (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) (EthBlock, error) `perm:"read"`
|
||||
EthGetBlockByNumber func(p0 context.Context, p1 string, p2 bool) (ethtypes.EthBlock, error) `perm:"read"`
|
||||
|
||||
EthGetBlockTransactionCountByHash func(p0 context.Context, p1 EthHash) (EthUint64, error) `perm:"read"`
|
||||
EthGetBlockTransactionCountByHash func(p0 context.Context, p1 ethtypes.EthHash) (ethtypes.EthUint64, error) `perm:"read"`
|
||||
|
||||
EthGetBlockTransactionCountByNumber func(p0 context.Context, p1 EthUint64) (EthUint64, error) `perm:"read"`
|
||||
EthGetBlockTransactionCountByNumber func(p0 context.Context, p1 ethtypes.EthUint64) (ethtypes.EthUint64, error) `perm:"read"`
|
||||
|
||||
EthGetCode func(p0 context.Context, p1 EthAddress, p2 string) (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 EthAddress, p2 EthBytes, p3 string) (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 EthHash, p2 EthUint64) (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 EthUint64, p2 EthUint64) (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 *EthHash) (*EthTx, error) `perm:"read"`
|
||||
EthGetTransactionByHash func(p0 context.Context, p1 *ethtypes.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 ethtypes.EthAddress, p2 string) (ethtypes.EthUint64, error) `perm:"read"`
|
||||
|
||||
EthGetTransactionReceipt func(p0 context.Context, p1 EthHash) (*EthTxReceipt, error) `perm:"read"`
|
||||
EthGetTransactionReceipt func(p0 context.Context, p1 ethtypes.EthHash) (*EthTxReceipt, error) `perm:"read"`
|
||||
|
||||
EthMaxPriorityFeePerGas func(p0 context.Context) (EthBigInt, error) `perm:"read"`
|
||||
EthMaxPriorityFeePerGas func(p0 context.Context) (ethtypes.EthBigInt, error) `perm:"read"`
|
||||
|
||||
EthProtocolVersion func(p0 context.Context) (EthUint64, error) `perm:"read"`
|
||||
EthProtocolVersion func(p0 context.Context) (ethtypes.EthUint64, error) `perm:"read"`
|
||||
|
||||
EthSendRawTransaction func(p0 context.Context, p1 EthBytes) (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) ([]EthAddress, error) {
|
||||
func (s *FullNodeStruct) EthAccounts(p0 context.Context) ([]ethtypes.EthAddress, error) {
|
||||
if s.Internal.EthAccounts == nil {
|
||||
return *new([]EthAddress), ErrNotSupported
|
||||
return *new([]ethtypes.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) ([]ethtypes.EthAddress, error) {
|
||||
return *new([]ethtypes.EthAddress), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthBlockNumber(p0 context.Context) (EthUint64, error) {
|
||||
func (s *FullNodeStruct) EthBlockNumber(p0 context.Context) (ethtypes.EthUint64, error) {
|
||||
if s.Internal.EthBlockNumber == nil {
|
||||
return *new(EthUint64), ErrNotSupported
|
||||
return *new(ethtypes.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) (ethtypes.EthUint64, error) {
|
||||
return *new(ethtypes.EthUint64), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthCall(p0 context.Context, p1 EthCall, p2 string) (EthBytes, error) {
|
||||
func (s *FullNodeStruct) EthCall(p0 context.Context, p1 ethtypes.EthCall, p2 string) (ethtypes.EthBytes, error) {
|
||||
if s.Internal.EthCall == nil {
|
||||
return *new(EthBytes), ErrNotSupported
|
||||
return *new(ethtypes.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 ethtypes.EthCall, p2 string) (ethtypes.EthBytes, error) {
|
||||
return *new(ethtypes.EthBytes), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthChainId(p0 context.Context) (EthUint64, error) {
|
||||
func (s *FullNodeStruct) EthChainId(p0 context.Context) (ethtypes.EthUint64, error) {
|
||||
if s.Internal.EthChainId == nil {
|
||||
return *new(EthUint64), ErrNotSupported
|
||||
return *new(ethtypes.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) (ethtypes.EthUint64, error) {
|
||||
return *new(ethtypes.EthUint64), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthEstimateGas(p0 context.Context, p1 EthCall) (EthUint64, error) {
|
||||
func (s *FullNodeStruct) EthEstimateGas(p0 context.Context, p1 ethtypes.EthCall) (ethtypes.EthUint64, error) {
|
||||
if s.Internal.EthEstimateGas == nil {
|
||||
return *new(EthUint64), ErrNotSupported
|
||||
return *new(ethtypes.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 ethtypes.EthCall) (ethtypes.EthUint64, error) {
|
||||
return *new(ethtypes.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 ethtypes.EthUint64, p2 string, p3 []float64) (ethtypes.EthFeeHistory, error) {
|
||||
if s.Internal.EthFeeHistory == nil {
|
||||
return *new(EthFeeHistory), ErrNotSupported
|
||||
return *new(ethtypes.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 ethtypes.EthUint64, p2 string, p3 []float64) (ethtypes.EthFeeHistory, error) {
|
||||
return *new(ethtypes.EthFeeHistory), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthGasPrice(p0 context.Context) (EthBigInt, error) {
|
||||
func (s *FullNodeStruct) EthGasPrice(p0 context.Context) (ethtypes.EthBigInt, error) {
|
||||
if s.Internal.EthGasPrice == nil {
|
||||
return *new(EthBigInt), ErrNotSupported
|
||||
return *new(ethtypes.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) (ethtypes.EthBigInt, error) {
|
||||
return *new(ethtypes.EthBigInt), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthGetBalance(p0 context.Context, p1 EthAddress, p2 string) (EthBigInt, error) {
|
||||
func (s *FullNodeStruct) EthGetBalance(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthBigInt, error) {
|
||||
if s.Internal.EthGetBalance == nil {
|
||||
return *new(EthBigInt), ErrNotSupported
|
||||
return *new(ethtypes.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 ethtypes.EthAddress, p2 string) (ethtypes.EthBigInt, error) {
|
||||
return *new(ethtypes.EthBigInt), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthGetBlockByHash(p0 context.Context, p1 EthHash, p2 bool) (EthBlock, error) {
|
||||
func (s *FullNodeStruct) EthGetBlockByHash(p0 context.Context, p1 ethtypes.EthHash, p2 bool) (ethtypes.EthBlock, error) {
|
||||
if s.Internal.EthGetBlockByHash == nil {
|
||||
return *new(EthBlock), ErrNotSupported
|
||||
return *new(ethtypes.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 ethtypes.EthHash, p2 bool) (ethtypes.EthBlock, error) {
|
||||
return *new(ethtypes.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) (ethtypes.EthBlock, error) {
|
||||
if s.Internal.EthGetBlockByNumber == nil {
|
||||
return *new(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) (EthBlock, error) {
|
||||
return *new(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 EthHash) (EthUint64, error) {
|
||||
func (s *FullNodeStruct) EthGetBlockTransactionCountByHash(p0 context.Context, p1 ethtypes.EthHash) (ethtypes.EthUint64, error) {
|
||||
if s.Internal.EthGetBlockTransactionCountByHash == nil {
|
||||
return *new(EthUint64), ErrNotSupported
|
||||
return *new(ethtypes.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 ethtypes.EthHash) (ethtypes.EthUint64, error) {
|
||||
return *new(ethtypes.EthUint64), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthGetBlockTransactionCountByNumber(p0 context.Context, p1 EthUint64) (EthUint64, error) {
|
||||
func (s *FullNodeStruct) EthGetBlockTransactionCountByNumber(p0 context.Context, p1 ethtypes.EthUint64) (ethtypes.EthUint64, error) {
|
||||
if s.Internal.EthGetBlockTransactionCountByNumber == nil {
|
||||
return *new(EthUint64), ErrNotSupported
|
||||
return *new(ethtypes.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 ethtypes.EthUint64) (ethtypes.EthUint64, error) {
|
||||
return *new(ethtypes.EthUint64), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthGetCode(p0 context.Context, p1 EthAddress, p2 string) (EthBytes, error) {
|
||||
func (s *FullNodeStruct) EthGetCode(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthBytes, error) {
|
||||
if s.Internal.EthGetCode == nil {
|
||||
return *new(EthBytes), ErrNotSupported
|
||||
return *new(ethtypes.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 ethtypes.EthAddress, p2 string) (ethtypes.EthBytes, error) {
|
||||
return *new(ethtypes.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 ethtypes.EthAddress, p2 ethtypes.EthBytes, p3 string) (ethtypes.EthBytes, error) {
|
||||
if s.Internal.EthGetStorageAt == nil {
|
||||
return *new(EthBytes), ErrNotSupported
|
||||
return *new(ethtypes.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 ethtypes.EthAddress, p2 ethtypes.EthBytes, p3 string) (ethtypes.EthBytes, error) {
|
||||
return *new(ethtypes.EthBytes), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 EthHash, p2 EthUint64) (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(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 ethtypes.EthHash, p2 ethtypes.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 ethtypes.EthUint64, p2 ethtypes.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 ethtypes.EthUint64, p2 ethtypes.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 *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 *EthHash) (*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 EthAddress, p2 string) (EthUint64, error) {
|
||||
func (s *FullNodeStruct) EthGetTransactionCount(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthUint64, error) {
|
||||
if s.Internal.EthGetTransactionCount == nil {
|
||||
return *new(EthUint64), ErrNotSupported
|
||||
return *new(ethtypes.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 ethtypes.EthAddress, p2 string) (ethtypes.EthUint64, error) {
|
||||
return *new(ethtypes.EthUint64), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthGetTransactionReceipt(p0 context.Context, p1 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 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) (EthBigInt, error) {
|
||||
func (s *FullNodeStruct) EthMaxPriorityFeePerGas(p0 context.Context) (ethtypes.EthBigInt, error) {
|
||||
if s.Internal.EthMaxPriorityFeePerGas == nil {
|
||||
return *new(EthBigInt), ErrNotSupported
|
||||
return *new(ethtypes.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) (ethtypes.EthBigInt, error) {
|
||||
return *new(ethtypes.EthBigInt), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthProtocolVersion(p0 context.Context) (EthUint64, error) {
|
||||
func (s *FullNodeStruct) EthProtocolVersion(p0 context.Context) (ethtypes.EthUint64, error) {
|
||||
if s.Internal.EthProtocolVersion == nil {
|
||||
return *new(EthUint64), ErrNotSupported
|
||||
return *new(ethtypes.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) (ethtypes.EthUint64, error) {
|
||||
return *new(ethtypes.EthUint64), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) EthSendRawTransaction(p0 context.Context, p1 EthBytes) (EthHash, error) {
|
||||
func (s *FullNodeStruct) EthSendRawTransaction(p0 context.Context, p1 ethtypes.EthBytes) (ethtypes.EthHash, error) {
|
||||
if s.Internal.EthSendRawTransaction == nil {
|
||||
return *new(EthHash), ErrNotSupported
|
||||
return *new(ethtypes.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 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.
@ -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
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package api
|
||||
package eth
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -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
@ -1,4 +1,4 @@
|
||||
package api
|
||||
package eth
|
||||
|
||||
import (
|
||||
"bytes"
|
@ -1,4 +1,4 @@
|
||||
package api
|
||||
package eth
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
@ -11,6 +11,11 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
)
|
||||
|
||||
type TestCase struct {
|
||||
Input interface{}
|
||||
Output interface{}
|
||||
}
|
||||
|
||||
func TestEncode(t *testing.T) {
|
||||
testcases := []TestCase{
|
||||
{[]byte(""), mustDecodeHex("0x80")},
|
@ -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
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package api
|
||||
package ethtypes
|
||||
|
||||
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"
|
||||
)
|
||||
@ -179,65 +178,6 @@ func (c *EthCall) UnmarshalJSON(b []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type EthTxReceipt struct {
|
||||
TransactionHash EthHash `json:"transactionHash"`
|
||||
TransactionIndex EthUint64 `json:"transactionIndex"`
|
||||
BlockHash EthHash `json:"blockHash"`
|
||||
BlockNumber EthUint64 `json:"blockNumber"`
|
||||
From EthAddress `json:"from"`
|
||||
To *EthAddress `json:"to"`
|
||||
// Logs
|
||||
// LogsBloom
|
||||
StateRoot EthHash `json:"root"`
|
||||
Status EthUint64 `json:"status"`
|
||||
ContractAddress *EthAddress `json:"contractAddress"`
|
||||
CumulativeGasUsed EthUint64 `json:"cumulativeGasUsed"`
|
||||
GasUsed EthUint64 `json:"gasUsed"`
|
||||
EffectiveGasPrice EthBigInt `json:"effectiveGasPrice"`
|
||||
LogsBloom EthBytes `json:"logsBloom"`
|
||||
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
|
@ -1,5 +1,4 @@
|
||||
// stm: #unit
|
||||
package api
|
||||
package ethtypes
|
||||
|
||||
import (
|
||||
"strings"
|
@ -5,73 +5,75 @@ import (
|
||||
"errors"
|
||||
|
||||
"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) (api.EthUint64, error) {
|
||||
func (e *EthModuleDummy) EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error) {
|
||||
return 0, ErrImplementMe
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthAccounts(ctx context.Context) ([]api.EthAddress, error) {
|
||||
func (e *EthModuleDummy) EthAccounts(ctx context.Context) ([]ethtypes.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 ethtypes.EthUint64) (ethtypes.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 ethtypes.EthHash) (ethtypes.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 ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) {
|
||||
return ethtypes.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) (ethtypes.EthBlock, error) {
|
||||
return ethtypes.EthBlock{}, ErrImplementMe
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetTransactionByHash(ctx context.Context, txHash *api.EthHash) (*api.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 api.EthAddress, blkOpt string) (api.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 api.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 api.EthHash, txIndex api.EthUint64) (api.EthTx, error) {
|
||||
return api.EthTx{}, ErrImplementMe
|
||||
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 api.EthUint64, txIndex api.EthUint64) (api.EthTx, error) {
|
||||
return api.EthTx{}, ErrImplementMe
|
||||
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 api.EthAddress, blkOpt string) (api.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 api.EthAddress, position api.EthBytes, blkParam string) (api.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 api.EthAddress, blkParam string) (api.EthBigInt, error) {
|
||||
return api.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 api.EthUint64, newestBlk string, rewardPercentiles []float64) (api.EthFeeHistory, error) {
|
||||
return api.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) (api.EthUint64, error) {
|
||||
func (e *EthModuleDummy) EthChainId(ctx context.Context) (ethtypes.EthUint64, error) {
|
||||
return 0, ErrImplementMe
|
||||
}
|
||||
|
||||
@ -83,26 +85,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) (ethtypes.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) (ethtypes.EthBigInt, error) {
|
||||
return ethtypes.EthBigIntZero, ErrImplementMe
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthEstimateGas(ctx context.Context, tx api.EthCall) (api.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 api.EthCall, blkParam string) (api.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) (api.EthBigInt, error) {
|
||||
return api.EthBigIntZero, ErrImplementMe
|
||||
func (e *EthModuleDummy) EthMaxPriorityFeePerGas(ctx context.Context) (ethtypes.EthBigInt, error) {
|
||||
return ethtypes.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 ethtypes.EthBytes) (ethtypes.EthHash, error) {
|
||||
return ethtypes.EthHash{}, ErrImplementMe
|
||||
}
|
||||
|
@ -22,38 +22,40 @@ 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"
|
||||
"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) (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) (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) (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) (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)
|
||||
@ -87,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) (api.EthUint64, error) {
|
||||
func (a *EthModule) EthBlockNumber(context.Context) (ethtypes.EthUint64, error) {
|
||||
height := a.Chain.GetHeaviestTipSet().Height()
|
||||
return api.EthUint64(height), nil
|
||||
return ethtypes.EthUint64(height), nil
|
||||
}
|
||||
|
||||
func (a *EthModule) EthAccounts(context.Context) ([]api.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 []api.EthAddress{}, nil
|
||||
return []ethtypes.EthAddress{}, nil
|
||||
}
|
||||
|
||||
func (a *EthModule) countTipsetMsgs(ctx context.Context, ts *types.TipSet) (int, error) {
|
||||
@ -111,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 api.EthUint64) (api.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 api.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 api.EthUint64(count), err
|
||||
return ethtypes.EthUint64(count), err
|
||||
}
|
||||
|
||||
func (a *EthModule) EthGetBlockTransactionCountByHash(ctx context.Context, blkHash api.EthHash) (api.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 api.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 api.EthUint64(count), err
|
||||
return ethtypes.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 ethtypes.EthHash, fullTxInfo bool) (ethtypes.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 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) (api.EthBlock, error) {
|
||||
typ, num, err := api.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 api.EthBlock{}, fmt.Errorf("cannot parse block number: %v", err)
|
||||
return ethtypes.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 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 api.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 *api.EthHash) (*api.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
|
||||
@ -178,19 +180,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 ethtypes.EthAddress, blkParam string) (ethtypes.EthUint64, error) {
|
||||
addr, err := sender.ToFilecoinAddress()
|
||||
if err != nil {
|
||||
return api.EthUint64(0), nil
|
||||
return ethtypes.EthUint64(0), nil
|
||||
}
|
||||
nonce, err := a.Mpool.GetNonce(ctx, addr, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return api.EthUint64(0), nil
|
||||
return ethtypes.EthUint64(0), nil
|
||||
}
|
||||
return api.EthUint64(nonce), nil
|
||||
return ethtypes.EthUint64(nonce), nil
|
||||
}
|
||||
|
||||
func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash api.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)
|
||||
@ -208,23 +210,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 ethtypes.EthHash, txIndex ethtypes.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 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 api.EthAddress, blkOpt string) (api.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)
|
||||
@ -288,7 +290,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 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")
|
||||
@ -362,35 +364,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 ethtypes.EthAddress, blkParam string) (ethtypes.EthBigInt, error) {
|
||||
filAddr, err := address.ToFilecoinAddress()
|
||||
if err != nil {
|
||||
return api.EthBigInt{}, err
|
||||
return ethtypes.EthBigInt{}, err
|
||||
}
|
||||
|
||||
actor, err := a.StateGetActor(ctx, filAddr, types.EmptyTSK)
|
||||
if xerrors.Is(err, types.ErrActorNotFound) {
|
||||
return api.EthBigIntZero, nil
|
||||
return ethtypes.EthBigIntZero, nil
|
||||
} else if err != nil {
|
||||
return api.EthBigInt{}, err
|
||||
return ethtypes.EthBigInt{}, err
|
||||
}
|
||||
|
||||
return api.EthBigInt{Int: actor.Balance.Int}, nil
|
||||
return ethtypes.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) (ethtypes.EthUint64, error) {
|
||||
return ethtypes.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 ethtypes.EthUint64, newestBlkNum string, rewardPercentiles []float64) (ethtypes.EthFeeHistory, error) {
|
||||
if blkCount > 1024 {
|
||||
return api.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 api.EthUint64
|
||||
var blkNum ethtypes.EthUint64
|
||||
err := blkNum.UnmarshalJSON([]byte(`"` + newestBlkNum + `"`))
|
||||
if err == nil && uint64(blkNum) < newestBlkHeight {
|
||||
newestBlkHeight = uint64(blkNum)
|
||||
@ -405,13 +407,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 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 := []api.EthBigInt{api.EthBigInt(ts.Blocks()[0].ParentBaseFee)}
|
||||
baseFeeArray := []ethtypes.EthBigInt{ethtypes.EthBigInt(ts.Blocks()[0].ParentBaseFee)}
|
||||
gasUsedRatioArray := []float64{}
|
||||
|
||||
for ts.Height() >= abi.ChainEpoch(oldestBlkHeight) {
|
||||
@ -419,17 +421,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 ethtypes.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, 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 api.EthFeeHistory{}, fmt.Errorf("cannot load tipset key: %v", parentTsKey)
|
||||
return ethtypes.EthFeeHistory{}, fmt.Errorf("cannot load tipset key: %v", parentTsKey)
|
||||
}
|
||||
}
|
||||
|
||||
@ -442,7 +444,7 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount api.EthUint64, n
|
||||
gasUsedRatioArray[i], gasUsedRatioArray[j] = gasUsedRatioArray[j], gasUsedRatioArray[i]
|
||||
}
|
||||
|
||||
return api.EthFeeHistory{
|
||||
return ethtypes.EthFeeHistory{
|
||||
OldestBlock: oldestBlkHeight,
|
||||
BaseFeePerGas: baseFeeArray,
|
||||
GasUsedRatio: gasUsedRatioArray,
|
||||
@ -462,20 +464,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) (ethtypes.EthUint64, error) {
|
||||
height := a.Chain.GetHeaviestTipSet().Height()
|
||||
return api.EthUint64(a.StateManager.GetNetworkVersion(ctx, height)), nil
|
||||
return ethtypes.EthUint64(a.StateManager.GetNetworkVersion(ctx, height)), nil
|
||||
}
|
||||
|
||||
func (a *EthModule) EthMaxPriorityFeePerGas(ctx context.Context) (api.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 api.EthBigInt(big.Zero()), err
|
||||
return ethtypes.EthBigInt(big.Zero()), err
|
||||
}
|
||||
return api.EthBigInt(gasPremium), nil
|
||||
return ethtypes.EthBigInt(gasPremium), nil
|
||||
}
|
||||
|
||||
func (a *EthModule) EthGasPrice(ctx context.Context) (api.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
|
||||
|
||||
@ -484,22 +486,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 ethtypes.EthBigInt(big.Zero()), nil
|
||||
}
|
||||
|
||||
gasPrice := big.Add(baseFee, big.Int(premium))
|
||||
return api.EthBigInt(gasPrice), nil
|
||||
return ethtypes.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 ethtypes.EthBytes) (ethtypes.EthHash, error) {
|
||||
txArgs, err := eth.ParseEthTxArgs(rawTx)
|
||||
if err != nil {
|
||||
return api.EmptyEthHash, err
|
||||
return ethtypes.EmptyEthHash, err
|
||||
}
|
||||
|
||||
smsg, err := txArgs.ToSignedMessage()
|
||||
if err != nil {
|
||||
return api.EmptyEthHash, err
|
||||
return ethtypes.EmptyEthHash, err
|
||||
}
|
||||
|
||||
_, err = a.StateAPI.StateGetActor(ctx, smsg.Message.To, types.EmptyTSK)
|
||||
@ -511,17 +513,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 ethtypes.EmptyEthHash, err
|
||||
}
|
||||
return api.NewEthHashFromCid(cid)
|
||||
return ethtypes.NewEthHashFromCid(cid)
|
||||
}
|
||||
|
||||
func (a *EthModule) ethCallToFilecoinMessage(ctx context.Context, tx api.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 = (api.EthAddress{}).ToFilecoinAddress()
|
||||
from, err = (ethtypes.EthAddress{}).ToFilecoinAddress()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to construct the ethereum system address: %w", err)
|
||||
}
|
||||
@ -611,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 api.EthCall) (api.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 api.EthUint64(0), err
|
||||
return ethtypes.EthUint64(0), err
|
||||
}
|
||||
|
||||
// Set the gas limit to the zero sentinel value, which makes
|
||||
@ -623,13 +625,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 ethtypes.EthUint64(0), err
|
||||
}
|
||||
|
||||
return api.EthUint64(msg.GasLimit), nil
|
||||
return ethtypes.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 ethtypes.EthCall, blkParam string) (ethtypes.EthBytes, error) {
|
||||
msg, err := a.ethCallToFilecoinMessage(ctx, tx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -642,38 +644,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 ethtypes.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) (ethtypes.EthBlock, error) {
|
||||
parent, err := a.Chain.LoadTipSet(ctx, ts.Parents())
|
||||
if err != nil {
|
||||
return api.EthBlock{}, err
|
||||
return ethtypes.EthBlock{}, err
|
||||
}
|
||||
parentKeyCid, err := parent.Key().Cid()
|
||||
if err != nil {
|
||||
return api.EthBlock{}, err
|
||||
return ethtypes.EthBlock{}, err
|
||||
}
|
||||
parentBlkHash, err := api.NewEthHashFromCid(parentKeyCid)
|
||||
parentBlkHash, err := ethtypes.NewEthHashFromCid(parentKeyCid)
|
||||
if err != nil {
|
||||
return api.EthBlock{}, err
|
||||
return ethtypes.EthBlock{}, err
|
||||
}
|
||||
|
||||
blkCid, err := ts.Key().Cid()
|
||||
if err != nil {
|
||||
return api.EthBlock{}, err
|
||||
return ethtypes.EthBlock{}, err
|
||||
}
|
||||
blkHash, err := api.NewEthHashFromCid(blkCid)
|
||||
blkHash, err := ethtypes.NewEthHashFromCid(blkCid)
|
||||
if err != nil {
|
||||
return api.EthBlock{}, err
|
||||
return ethtypes.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 ethtypes.EthBlock{}, xerrors.Errorf("error loading messages for tipset: %v: %w", ts, err)
|
||||
}
|
||||
|
||||
block := api.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)
|
||||
@ -681,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 api.EthBlock{}, nil
|
||||
return ethtypes.EthBlock{}, nil
|
||||
}
|
||||
gasUsed += msgLookup.Receipt.GasUsed
|
||||
|
||||
if fullTxInfo {
|
||||
tx, err := a.newEthTxFromFilecoinMessageLookup(ctx, msgLookup)
|
||||
if err != nil {
|
||||
return api.EthBlock{}, nil
|
||||
return ethtypes.EthBlock{}, nil
|
||||
}
|
||||
block.Transactions = append(block.Transactions, tx)
|
||||
} else {
|
||||
hash, err := api.NewEthHashFromCid(msg.Cid())
|
||||
hash, err := ethtypes.NewEthHashFromCid(msg.Cid())
|
||||
if err != nil {
|
||||
return api.EthBlock{}, err
|
||||
return ethtypes.EthBlock{}, err
|
||||
}
|
||||
block.Transactions = append(block.Transactions, hash.String())
|
||||
}
|
||||
@ -702,11 +704,11 @@ func (a *EthModule) newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types
|
||||
}
|
||||
|
||||
block.Hash = blkHash
|
||||
block.Number = api.EthUint64(ts.Height())
|
||||
block.Number = ethtypes.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 = ethtypes.EthUint64(ts.Blocks()[0].Timestamp)
|
||||
block.BaseFeePerGas = ethtypes.EthBigInt{Int: ts.Blocks()[0].ParentBaseFee.Int}
|
||||
block.GasUsed = ethtypes.EthUint64(gasUsed)
|
||||
return block, nil
|
||||
}
|
||||
|
||||
@ -718,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) (api.EthAddress, error) {
|
||||
func (a *EthModule) lookupEthAddress(ctx context.Context, addr address.Address) (ethtypes.EthAddress, error) {
|
||||
// Attempt to convert directly.
|
||||
if ethAddr, ok, err := api.TryEthAddressFromFilecoinAddress(addr, false); err != nil {
|
||||
return api.EthAddress{}, err
|
||||
if ethAddr, ok, err := ethtypes.TryEthAddressFromFilecoinAddress(addr, false); err != nil {
|
||||
return ethtypes.EthAddress{}, err
|
||||
} else if ok {
|
||||
return ethAddr, nil
|
||||
}
|
||||
@ -729,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 api.EthAddress{}, err
|
||||
return ethtypes.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 := 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 := api.TryEthAddressFromFilecoinAddress(addr, true); err != nil {
|
||||
return api.EthAddress{}, err
|
||||
if ethAddr, ok, err := ethtypes.TryEthAddressFromFilecoinAddress(addr, true); err != nil {
|
||||
return ethtypes.EthAddress{}, err
|
||||
} else if ok {
|
||||
return ethAddr, nil
|
||||
}
|
||||
@ -749,42 +751,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 ethtypes.EthAddress{}, err
|
||||
}
|
||||
return api.EthAddressFromFilecoinAddress(idAddr)
|
||||
return ethtypes.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 := ethtypes.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 +794,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 := ethtypes.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 +835,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 +846,63 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
|
||||
}
|
||||
}
|
||||
|
||||
tx := api.EthTx{
|
||||
ChainID: api.EthUint64(build.Eip155ChainId),
|
||||
tx := eth.EthTx{
|
||||
ChainID: ethtypes.EthUint64(build.Eip155ChainId),
|
||||
Hash: txHash,
|
||||
BlockHash: blkHash,
|
||||
BlockNumber: api.EthUint64(parentTs.Height()),
|
||||
BlockNumber: ethtypes.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: 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
|
||||
}
|
||||
|
||||
func NewEthTxReceipt(tx eth.EthTx, lookup *api.MsgLookup, replay *api.InvocResult) (api.EthTxReceipt, error) {
|
||||
receipt := api.EthTxReceipt{
|
||||
TransactionHash: tx.Hash,
|
||||
TransactionIndex: tx.TransactionIndex,
|
||||
BlockHash: tx.BlockHash,
|
||||
BlockNumber: tx.BlockNumber,
|
||||
From: tx.From,
|
||||
To: tx.To,
|
||||
StateRoot: ethtypes.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 api.EthTxReceipt{}, xerrors.Errorf("failed to parse contract creation result: %w", err)
|
||||
}
|
||||
addr := ethtypes.EthAddress(ret.EthAddress)
|
||||
receipt.ContractAddress = &addr
|
||||
}
|
||||
|
||||
if lookup.Receipt.ExitCode.IsSuccess() {
|
||||
receipt.Status = 1
|
||||
}
|
||||
if lookup.Receipt.ExitCode.IsError() {
|
||||
receipt.Status = 0
|
||||
}
|
||||
|
||||
receipt.GasUsed = ethtypes.EthUint64(lookup.Receipt.GasUsed)
|
||||
|
||||
// TODO: handle CumulativeGasUsed
|
||||
receipt.CumulativeGasUsed = ethtypes.EmptyEthInt
|
||||
|
||||
effectiveGasPrice := big.Div(replay.GasCost.TotalCost, big.NewInt(lookup.Receipt.GasUsed))
|
||||
receipt.EffectiveGasPrice = ethtypes.EthBigInt(effectiveGasPrice)
|
||||
return receipt, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user