Move all eth stuff into ethtypes
This commit is contained in:
parent
7ea690d4be
commit
bc7c190db0
@ -30,7 +30,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
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/actors/builtin/power"
|
||||||
"github.com/filecoin-project/lotus/chain/eth"
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
@ -773,13 +772,13 @@ type FullNode interface {
|
|||||||
// EthGetBlockTransactionCountByHash returns the number of messages in the TipSet
|
// EthGetBlockTransactionCountByHash returns the number of messages in the TipSet
|
||||||
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error) //perm:read
|
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error) //perm:read
|
||||||
|
|
||||||
EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, 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
|
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
|
EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error) //perm:read
|
||||||
EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, 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
|
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
|
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) //perm:read
|
||||||
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (eth.EthTx, error) //perm:read
|
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) //perm:read
|
||||||
|
|
||||||
EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, 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
|
EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam string) (ethtypes.EthBytes, error) //perm:read
|
||||||
|
@ -36,7 +36,6 @@ import (
|
|||||||
api "github.com/filecoin-project/lotus/api"
|
api "github.com/filecoin-project/lotus/api"
|
||||||
apitypes "github.com/filecoin-project/lotus/api/types"
|
apitypes "github.com/filecoin-project/lotus/api/types"
|
||||||
miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
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"
|
types "github.com/filecoin-project/lotus/chain/types"
|
||||||
ethtypes "github.com/filecoin-project/lotus/chain/types/ethtypes"
|
ethtypes "github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||||
alerting "github.com/filecoin-project/lotus/journal/alerting"
|
alerting "github.com/filecoin-project/lotus/journal/alerting"
|
||||||
@ -1134,10 +1133,10 @@ func (mr *MockFullNodeMockRecorder) EthGetStorageAt(arg0, arg1, arg2, arg3 inter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EthGetTransactionByBlockHashAndIndex mocks base method.
|
// EthGetTransactionByBlockHashAndIndex mocks base method.
|
||||||
func (m *MockFullNode) EthGetTransactionByBlockHashAndIndex(arg0 context.Context, arg1 ethtypes.EthHash, arg2 ethtypes.EthUint64) (eth.EthTx, error) {
|
func (m *MockFullNode) EthGetTransactionByBlockHashAndIndex(arg0 context.Context, arg1 ethtypes.EthHash, arg2 ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "EthGetTransactionByBlockHashAndIndex", arg0, arg1, arg2)
|
ret := m.ctrl.Call(m, "EthGetTransactionByBlockHashAndIndex", arg0, arg1, arg2)
|
||||||
ret0, _ := ret[0].(eth.EthTx)
|
ret0, _ := ret[0].(ethtypes.EthTx)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
@ -1149,10 +1148,10 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionByBlockHashAndIndex(arg0, a
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EthGetTransactionByBlockNumberAndIndex mocks base method.
|
// EthGetTransactionByBlockNumberAndIndex mocks base method.
|
||||||
func (m *MockFullNode) EthGetTransactionByBlockNumberAndIndex(arg0 context.Context, arg1, arg2 ethtypes.EthUint64) (eth.EthTx, error) {
|
func (m *MockFullNode) EthGetTransactionByBlockNumberAndIndex(arg0 context.Context, arg1, arg2 ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "EthGetTransactionByBlockNumberAndIndex", arg0, arg1, arg2)
|
ret := m.ctrl.Call(m, "EthGetTransactionByBlockNumberAndIndex", arg0, arg1, arg2)
|
||||||
ret0, _ := ret[0].(eth.EthTx)
|
ret0, _ := ret[0].(ethtypes.EthTx)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
@ -1164,10 +1163,10 @@ func (mr *MockFullNodeMockRecorder) EthGetTransactionByBlockNumberAndIndex(arg0,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EthGetTransactionByHash mocks base method.
|
// EthGetTransactionByHash mocks base method.
|
||||||
func (m *MockFullNode) EthGetTransactionByHash(arg0 context.Context, arg1 *ethtypes.EthHash) (*eth.EthTx, error) {
|
func (m *MockFullNode) EthGetTransactionByHash(arg0 context.Context, arg1 *ethtypes.EthHash) (*ethtypes.EthTx, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "EthGetTransactionByHash", arg0, arg1)
|
ret := m.ctrl.Call(m, "EthGetTransactionByHash", arg0, arg1)
|
||||||
ret0, _ := ret[0].(*eth.EthTx)
|
ret0, _ := ret[0].(*ethtypes.EthTx)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ import (
|
|||||||
apitypes "github.com/filecoin-project/lotus/api/types"
|
apitypes "github.com/filecoin-project/lotus/api/types"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
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"
|
||||||
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||||
"github.com/filecoin-project/lotus/journal/alerting"
|
"github.com/filecoin-project/lotus/journal/alerting"
|
||||||
@ -248,11 +247,11 @@ type FullNodeStruct struct {
|
|||||||
|
|
||||||
EthGetStorageAt func(p0 context.Context, p1 ethtypes.EthAddress, p2 ethtypes.EthBytes, p3 string) (ethtypes.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 ethtypes.EthHash, p2 ethtypes.EthUint64) (eth.EthTx, error) `perm:"read"`
|
EthGetTransactionByBlockHashAndIndex func(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) `perm:"read"`
|
||||||
|
|
||||||
EthGetTransactionByBlockNumberAndIndex func(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (eth.EthTx, error) `perm:"read"`
|
EthGetTransactionByBlockNumberAndIndex func(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) `perm:"read"`
|
||||||
|
|
||||||
EthGetTransactionByHash func(p0 context.Context, p1 *ethtypes.EthHash) (*eth.EthTx, error) `perm:"read"`
|
EthGetTransactionByHash func(p0 context.Context, p1 *ethtypes.EthHash) (*ethtypes.EthTx, error) `perm:"read"`
|
||||||
|
|
||||||
EthGetTransactionCount func(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthUint64, error) `perm:"read"`
|
EthGetTransactionCount func(p0 context.Context, p1 ethtypes.EthAddress, p2 string) (ethtypes.EthUint64, error) `perm:"read"`
|
||||||
|
|
||||||
@ -1999,36 +1998,36 @@ func (s *FullNodeStub) EthGetStorageAt(p0 context.Context, p1 ethtypes.EthAddres
|
|||||||
return *new(ethtypes.EthBytes), ErrNotSupported
|
return *new(ethtypes.EthBytes), ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStruct) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (eth.EthTx, error) {
|
func (s *FullNodeStruct) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||||
if s.Internal.EthGetTransactionByBlockHashAndIndex == nil {
|
if s.Internal.EthGetTransactionByBlockHashAndIndex == nil {
|
||||||
return *new(eth.EthTx), ErrNotSupported
|
return *new(ethtypes.EthTx), ErrNotSupported
|
||||||
}
|
}
|
||||||
return s.Internal.EthGetTransactionByBlockHashAndIndex(p0, p1, p2)
|
return s.Internal.EthGetTransactionByBlockHashAndIndex(p0, p1, p2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStub) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (eth.EthTx, error) {
|
func (s *FullNodeStub) EthGetTransactionByBlockHashAndIndex(p0 context.Context, p1 ethtypes.EthHash, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||||
return *new(eth.EthTx), ErrNotSupported
|
return *new(ethtypes.EthTx), ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStruct) EthGetTransactionByBlockNumberAndIndex(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (eth.EthTx, error) {
|
func (s *FullNodeStruct) EthGetTransactionByBlockNumberAndIndex(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||||
if s.Internal.EthGetTransactionByBlockNumberAndIndex == nil {
|
if s.Internal.EthGetTransactionByBlockNumberAndIndex == nil {
|
||||||
return *new(eth.EthTx), ErrNotSupported
|
return *new(ethtypes.EthTx), ErrNotSupported
|
||||||
}
|
}
|
||||||
return s.Internal.EthGetTransactionByBlockNumberAndIndex(p0, p1, p2)
|
return s.Internal.EthGetTransactionByBlockNumberAndIndex(p0, p1, p2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStub) EthGetTransactionByBlockNumberAndIndex(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (eth.EthTx, error) {
|
func (s *FullNodeStub) EthGetTransactionByBlockNumberAndIndex(p0 context.Context, p1 ethtypes.EthUint64, p2 ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||||
return *new(eth.EthTx), ErrNotSupported
|
return *new(ethtypes.EthTx), ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStruct) EthGetTransactionByHash(p0 context.Context, p1 *ethtypes.EthHash) (*eth.EthTx, error) {
|
func (s *FullNodeStruct) EthGetTransactionByHash(p0 context.Context, p1 *ethtypes.EthHash) (*ethtypes.EthTx, error) {
|
||||||
if s.Internal.EthGetTransactionByHash == nil {
|
if s.Internal.EthGetTransactionByHash == nil {
|
||||||
return nil, ErrNotSupported
|
return nil, ErrNotSupported
|
||||||
}
|
}
|
||||||
return s.Internal.EthGetTransactionByHash(p0, p1)
|
return s.Internal.EthGetTransactionByHash(p0, p1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStub) EthGetTransactionByHash(p0 context.Context, p1 *ethtypes.EthHash) (*eth.EthTx, error) {
|
func (s *FullNodeStub) EthGetTransactionByHash(p0 context.Context, p1 *ethtypes.EthHash) (*ethtypes.EthTx, error) {
|
||||||
return nil, ErrNotSupported
|
return nil, ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -35,12 +35,12 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
|
||||||
"github.com/filecoin-project/lotus/chain/beacon"
|
"github.com/filecoin-project/lotus/chain/beacon"
|
||||||
"github.com/filecoin-project/lotus/chain/consensus"
|
"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/rand"
|
||||||
"github.com/filecoin-project/lotus/chain/state"
|
"github.com/filecoin-project/lotus/chain/state"
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
"github.com/filecoin-project/lotus/lib/async"
|
"github.com/filecoin-project/lotus/lib/async"
|
||||||
"github.com/filecoin-project/lotus/lib/sigs"
|
"github.com/filecoin-project/lotus/lib/sigs"
|
||||||
@ -577,7 +577,7 @@ func (filec *FilecoinEC) checkBlockMessages(ctx context.Context, b *types.FullBl
|
|||||||
|
|
||||||
digest := m.Message.Cid().Bytes()
|
digest := m.Message.Cid().Bytes()
|
||||||
if m.Signature.Type == crypto.SigTypeDelegated {
|
if m.Signature.Type == crypto.SigTypeDelegated {
|
||||||
txArgs, err := eth.NewEthTxArgsFromMessage(&m.Message)
|
txArgs, err := ethtypes.NewEthTxArgsFromMessage(&m.Message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,10 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/consensus/filcns"
|
"github.com/filecoin-project/lotus/chain/consensus/filcns"
|
||||||
"github.com/filecoin-project/lotus/chain/eth"
|
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
"github.com/filecoin-project/lotus/journal"
|
"github.com/filecoin-project/lotus/journal"
|
||||||
"github.com/filecoin-project/lotus/lib/sigs"
|
"github.com/filecoin-project/lotus/lib/sigs"
|
||||||
@ -778,7 +778,7 @@ func sigCacheKey(m *types.SignedMessage) (string, error) {
|
|||||||
case crypto.SigTypeSecp256k1:
|
case crypto.SigTypeSecp256k1:
|
||||||
return string(m.Cid().Bytes()), nil
|
return string(m.Cid().Bytes()), nil
|
||||||
case crypto.SigTypeDelegated:
|
case crypto.SigTypeDelegated:
|
||||||
txArgs, err := eth.NewEthTxArgsFromMessage(&m.Message)
|
txArgs, err := ethtypes.NewEthTxArgsFromMessage(&m.Message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -805,7 +805,7 @@ func (mp *MessagePool) VerifyMsgSig(m *types.SignedMessage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if m.Signature.Type == crypto.SigTypeDelegated {
|
if m.Signature.Type == crypto.SigTypeDelegated {
|
||||||
txArgs, err := eth.NewEthTxArgsFromMessage(&m.Message)
|
txArgs, err := ethtypes.NewEthTxArgsFromMessage(&m.Message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("failed to convert to eth tx args: %w", err)
|
return xerrors.Errorf("failed to convert to eth tx args: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package eth
|
package ethtypes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -20,48 +20,47 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const Eip1559TxType = 2
|
const Eip1559TxType = 2
|
||||||
|
|
||||||
type EthTx struct {
|
type EthTx struct {
|
||||||
ChainID ethtypes.EthUint64 `json:"chainId"`
|
ChainID EthUint64 `json:"chainId"`
|
||||||
Nonce ethtypes.EthUint64 `json:"nonce"`
|
Nonce EthUint64 `json:"nonce"`
|
||||||
Hash ethtypes.EthHash `json:"hash"`
|
Hash EthHash `json:"hash"`
|
||||||
BlockHash ethtypes.EthHash `json:"blockHash"`
|
BlockHash EthHash `json:"blockHash"`
|
||||||
BlockNumber ethtypes.EthUint64 `json:"blockNumber"`
|
BlockNumber EthUint64 `json:"blockNumber"`
|
||||||
TransactionIndex ethtypes.EthUint64 `json:"transactionIndex"`
|
TransactionIndex EthUint64 `json:"transactionIndex"`
|
||||||
From ethtypes.EthAddress `json:"from"`
|
From EthAddress `json:"from"`
|
||||||
To *ethtypes.EthAddress `json:"to"`
|
To *EthAddress `json:"to"`
|
||||||
Value ethtypes.EthBigInt `json:"value"`
|
Value EthBigInt `json:"value"`
|
||||||
Type ethtypes.EthUint64 `json:"type"`
|
Type EthUint64 `json:"type"`
|
||||||
Input ethtypes.EthBytes `json:"input"`
|
Input EthBytes `json:"input"`
|
||||||
Gas ethtypes.EthUint64 `json:"gas"`
|
Gas EthUint64 `json:"gas"`
|
||||||
MaxFeePerGas ethtypes.EthBigInt `json:"maxFeePerGas"`
|
MaxFeePerGas EthBigInt `json:"maxFeePerGas"`
|
||||||
MaxPriorityFeePerGas ethtypes.EthBigInt `json:"maxPriorityFeePerGas"`
|
MaxPriorityFeePerGas EthBigInt `json:"maxPriorityFeePerGas"`
|
||||||
V ethtypes.EthBytes `json:"v"`
|
V EthBytes `json:"v"`
|
||||||
R ethtypes.EthBytes `json:"r"`
|
R EthBytes `json:"r"`
|
||||||
S ethtypes.EthBytes `json:"s"`
|
S EthBytes `json:"s"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EthTxArgs struct {
|
type EthTxArgs struct {
|
||||||
ChainID int `json:"chainId"`
|
ChainID int `json:"chainId"`
|
||||||
Nonce int `json:"nonce"`
|
Nonce int `json:"nonce"`
|
||||||
To *ethtypes.EthAddress `json:"to"`
|
To *EthAddress `json:"to"`
|
||||||
Value big.Int `json:"value"`
|
Value big.Int `json:"value"`
|
||||||
MaxFeePerGas big.Int `json:"maxFeePerGas"`
|
MaxFeePerGas big.Int `json:"maxFeePerGas"`
|
||||||
MaxPriorityFeePerGas big.Int `json:"maxPriorityFeePerGas"`
|
MaxPriorityFeePerGas big.Int `json:"maxPriorityFeePerGas"`
|
||||||
GasLimit int `json:"gasLimit"`
|
GasLimit int `json:"gasLimit"`
|
||||||
Input []byte `json:"input"`
|
Input []byte `json:"input"`
|
||||||
V []byte `json:"v"`
|
V []byte `json:"v"`
|
||||||
R []byte `json:"r"`
|
R []byte `json:"r"`
|
||||||
S []byte `json:"s"`
|
S []byte `json:"s"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEthTxArgsFromMessage(msg *types.Message) (EthTxArgs, error) {
|
func NewEthTxArgsFromMessage(msg *types.Message) (EthTxArgs, error) {
|
||||||
var (
|
var (
|
||||||
to *ethtypes.EthAddress
|
to *EthAddress
|
||||||
decodedParams []byte
|
decodedParams []byte
|
||||||
paramsReader = bytes.NewReader(msg.Params)
|
paramsReader = bytes.NewReader(msg.Params)
|
||||||
)
|
)
|
||||||
@ -84,7 +83,7 @@ func NewEthTxArgsFromMessage(msg *types.Message) (EthTxArgs, error) {
|
|||||||
return EthTxArgs{}, fmt.Errorf("unsupported EAM method")
|
return EthTxArgs{}, fmt.Errorf("unsupported EAM method")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addr, err := ethtypes.EthAddressFromFilecoinAddress(msg.To)
|
addr, err := EthAddressFromFilecoinAddress(msg.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return EthTxArgs{}, err
|
return EthTxArgs{}, err
|
||||||
}
|
}
|
||||||
@ -442,7 +441,7 @@ func formatInt(val int) ([]byte, error) {
|
|||||||
return removeLeadingZeros(buf.Bytes()), nil
|
return removeLeadingZeros(buf.Bytes()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatEthAddr(addr *ethtypes.EthAddress) []byte {
|
func formatEthAddr(addr *EthAddress) []byte {
|
||||||
if addr == nil {
|
if addr == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -497,7 +496,7 @@ func parseBytes(v interface{}) ([]byte, error) {
|
|||||||
return val, nil
|
return val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseEthAddr(v interface{}) (*ethtypes.EthAddress, error) {
|
func parseEthAddr(v interface{}) (*EthAddress, error) {
|
||||||
b, err := parseBytes(v)
|
b, err := parseBytes(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -505,7 +504,7 @@ func parseEthAddr(v interface{}) (*ethtypes.EthAddress, error) {
|
|||||||
if len(b) == 0 {
|
if len(b) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
addr, err := ethtypes.EthAddressFromBytes(b)
|
addr, err := EthAddressFromBytes(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
|||||||
package eth
|
package ethtypes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -1,4 +1,4 @@
|
|||||||
package eth
|
package ethtypes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
@ -11,11 +11,6 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TestCase struct {
|
|
||||||
Input interface{}
|
|
||||||
Output interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEncode(t *testing.T) {
|
func TestEncode(t *testing.T) {
|
||||||
testcases := []TestCase{
|
testcases := []TestCase{
|
||||||
{[]byte(""), mustDecodeHex("0x80")},
|
{[]byte(""), mustDecodeHex("0x80")},
|
@ -1119,31 +1119,21 @@ var sectorsExtendCmd = &cli.Command{
|
|||||||
ArgsUsage: "<sectorNumbers...>",
|
ArgsUsage: "<sectorNumbers...>",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.Int64Flag{
|
&cli.Int64Flag{
|
||||||
Name: "new-expiration",
|
Name: "new-expiration",
|
||||||
Usage: "new expiration epoch",
|
Usage: "new expiration epoch",
|
||||||
Required: false,
|
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "v1-sectors",
|
Name: "v1-sectors",
|
||||||
Usage: "renews all v1 sectors up to the maximum possible lifetime",
|
Usage: "renews all v1 sectors up to the maximum possible lifetime",
|
||||||
Required: false,
|
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.Int64Flag{
|
||||||
Name: "tolerance",
|
Name: "expiration-ignore",
|
||||||
Value: 20160,
|
Value: 120,
|
||||||
Usage: "when extending v1 sectors, don't try to extend sectors by fewer than this number of epochs",
|
Usage: "when extending v1 sectors, skip sectors whose current expiration is less than <ignore> epochs from now",
|
||||||
Required: false,
|
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.Int64Flag{
|
||||||
Name: "expiration-ignore",
|
Name: "expiration-cutoff",
|
||||||
Value: 120,
|
Usage: "when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified)",
|
||||||
Usage: "when extending v1 sectors, skip sectors whose current expiration is less than <ignore> epochs from now",
|
|
||||||
Required: false,
|
|
||||||
},
|
|
||||||
&cli.Int64Flag{
|
|
||||||
Name: "expiration-cutoff",
|
|
||||||
Usage: "when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified)",
|
|
||||||
Required: false,
|
|
||||||
},
|
},
|
||||||
&cli.StringFlag{},
|
&cli.StringFlag{},
|
||||||
},
|
},
|
||||||
|
@ -1919,7 +1919,6 @@ OPTIONS:
|
|||||||
--expiration-cutoff value when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified) (default: 0)
|
--expiration-cutoff value when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified) (default: 0)
|
||||||
--expiration-ignore value when extending v1 sectors, skip sectors whose current expiration is less than <ignore> epochs from now (default: 120)
|
--expiration-ignore value when extending v1 sectors, skip sectors whose current expiration is less than <ignore> epochs from now (default: 120)
|
||||||
--new-expiration value new expiration epoch (default: 0)
|
--new-expiration value new expiration epoch (default: 0)
|
||||||
--tolerance value when extending v1 sectors, don't try to extend sectors by fewer than this number of epochs (default: 20160)
|
|
||||||
--v1-sectors renews all v1 sectors up to the maximum possible lifetime (default: false)
|
--v1-sectors renews all v1 sectors up to the maximum possible lifetime (default: false)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
"github.com/filecoin-project/lotus/chain/eth"
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet/key"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/itests/kit"
|
"github.com/filecoin-project/lotus/itests/kit"
|
||||||
)
|
)
|
||||||
@ -67,7 +67,7 @@ func TestEthAccountAbstraction(t *testing.T) {
|
|||||||
msgFromEmbryo, err = client.GasEstimateMessageGas(ctx, msgFromEmbryo, nil, types.EmptyTSK)
|
msgFromEmbryo, err = client.GasEstimateMessageGas(ctx, msgFromEmbryo, nil, types.EmptyTSK)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
txArgs, err := eth.NewEthTxArgsFromMessage(msgFromEmbryo)
|
txArgs, err := ethtypes.NewEthTxArgsFromMessage(msgFromEmbryo)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
digest, err := txArgs.OriginalRlpMsg()
|
digest, err := txArgs.OriginalRlpMsg()
|
||||||
@ -101,7 +101,7 @@ func TestEthAccountAbstraction(t *testing.T) {
|
|||||||
msgFromEmbryo, err = client.GasEstimateMessageGas(ctx, msgFromEmbryo, nil, types.EmptyTSK)
|
msgFromEmbryo, err = client.GasEstimateMessageGas(ctx, msgFromEmbryo, nil, types.EmptyTSK)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
txArgs, err = eth.NewEthTxArgsFromMessage(msgFromEmbryo)
|
txArgs, err = ethtypes.NewEthTxArgsFromMessage(msgFromEmbryo)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
digest, err = txArgs.OriginalRlpMsg()
|
digest, err = txArgs.OriginalRlpMsg()
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/eth"
|
|
||||||
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ func (e *EthModuleDummy) EthGetBlockByNumber(ctx context.Context, blkNum string,
|
|||||||
return ethtypes.EthBlock{}, ErrImplementMe
|
return ethtypes.EthBlock{}, ErrImplementMe
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EthModuleDummy) EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*eth.EthTx, error) {
|
func (e *EthModuleDummy) EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error) {
|
||||||
return nil, ErrImplementMe
|
return nil, ErrImplementMe
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,12 +48,12 @@ func (e *EthModuleDummy) EthGetTransactionReceipt(ctx context.Context, txHash et
|
|||||||
return nil, ErrImplementMe
|
return nil, ErrImplementMe
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EthModuleDummy) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (eth.EthTx, error) {
|
func (e *EthModuleDummy) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||||
return eth.EthTx{}, ErrImplementMe
|
return ethtypes.EthTx{}, ErrImplementMe
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EthModuleDummy) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (eth.EthTx, error) {
|
func (e *EthModuleDummy) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||||
return eth.EthTx{}, ErrImplementMe
|
return ethtypes.EthTx{}, ErrImplementMe
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EthModuleDummy) EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) {
|
func (e *EthModuleDummy) EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) {
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"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/messagepool"
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
@ -38,11 +37,11 @@ type EthModuleAPI interface {
|
|||||||
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (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)
|
EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error)
|
||||||
EthGetBlockByNumber(ctx context.Context, blkNum string, 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)
|
EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error)
|
||||||
EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, error)
|
EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, error)
|
||||||
EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error)
|
EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error)
|
||||||
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (eth.EthTx, error)
|
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error)
|
||||||
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (eth.EthTx, error)
|
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error)
|
||||||
EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, 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)
|
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)
|
EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam string) (ethtypes.EthBigInt, error)
|
||||||
@ -160,7 +159,7 @@ func (a *EthModule) EthGetBlockByNumber(ctx context.Context, blkNum string, full
|
|||||||
return a.newEthBlockFromFilecoinTipSet(ctx, ts, fullTxInfo)
|
return a.newEthBlockFromFilecoinTipSet(ctx, ts, fullTxInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*eth.EthTx, error) {
|
func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error) {
|
||||||
// Ethereum's behavior is to return null when the txHash is invalid, so we use nil to check if txHash is valid
|
// 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 {
|
if txHash == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@ -217,12 +216,12 @@ func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash ethtype
|
|||||||
return &receipt, nil
|
return &receipt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *EthModule) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (eth.EthTx, error) {
|
func (a *EthModule) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||||
return eth.EthTx{}, nil
|
return ethtypes.EthTx{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *EthModule) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (eth.EthTx, error) {
|
func (a *EthModule) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||||
return eth.EthTx{}, nil
|
return ethtypes.EthTx{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EthGetCode returns string value of the compiled bytecode
|
// EthGetCode returns string value of the compiled bytecode
|
||||||
@ -494,7 +493,7 @@ func (a *EthModule) EthGasPrice(ctx context.Context) (ethtypes.EthBigInt, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *EthModule) EthSendRawTransaction(ctx context.Context, rawTx ethtypes.EthBytes) (ethtypes.EthHash, error) {
|
func (a *EthModule) EthSendRawTransaction(ctx context.Context, rawTx ethtypes.EthBytes) (ethtypes.EthHash, error) {
|
||||||
txArgs, err := eth.ParseEthTxArgs(rawTx)
|
txArgs, err := ethtypes.ParseEthTxArgs(rawTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ethtypes.EmptyEthHash, err
|
return ethtypes.EmptyEthHash, err
|
||||||
}
|
}
|
||||||
@ -756,37 +755,37 @@ func (a *EthModule) lookupEthAddress(ctx context.Context, addr address.Address)
|
|||||||
return ethtypes.EthAddressFromFilecoinAddress(idAddr)
|
return ethtypes.EthAddressFromFilecoinAddress(idAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLookup *api.MsgLookup) (eth.EthTx, error) {
|
func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLookup *api.MsgLookup) (ethtypes.EthTx, error) {
|
||||||
if msgLookup == nil {
|
if msgLookup == nil {
|
||||||
return eth.EthTx{}, fmt.Errorf("msg does not exist")
|
return ethtypes.EthTx{}, fmt.Errorf("msg does not exist")
|
||||||
}
|
}
|
||||||
cid := msgLookup.Message
|
cid := msgLookup.Message
|
||||||
txHash, err := ethtypes.NewEthHashFromCid(cid)
|
txHash, err := ethtypes.NewEthHashFromCid(cid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return eth.EthTx{}, err
|
return ethtypes.EthTx{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ts, err := a.Chain.LoadTipSet(ctx, msgLookup.TipSet)
|
ts, err := a.Chain.LoadTipSet(ctx, msgLookup.TipSet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return eth.EthTx{}, err
|
return ethtypes.EthTx{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// This tx is located in the parent tipset
|
// This tx is located in the parent tipset
|
||||||
parentTs, err := a.Chain.LoadTipSet(ctx, ts.Parents())
|
parentTs, err := a.Chain.LoadTipSet(ctx, ts.Parents())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return eth.EthTx{}, err
|
return ethtypes.EthTx{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
parentTsCid, err := parentTs.Key().Cid()
|
parentTsCid, err := parentTs.Key().Cid()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return eth.EthTx{}, err
|
return ethtypes.EthTx{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// lookup the transactionIndex
|
// lookup the transactionIndex
|
||||||
txIdx := -1
|
txIdx := -1
|
||||||
msgs, err := a.Chain.MessagesForTipset(ctx, parentTs)
|
msgs, err := a.Chain.MessagesForTipset(ctx, parentTs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return eth.EthTx{}, err
|
return ethtypes.EthTx{}, err
|
||||||
}
|
}
|
||||||
for i, msg := range msgs {
|
for i, msg := range msgs {
|
||||||
if msg.Cid() == msgLookup.Message {
|
if msg.Cid() == msgLookup.Message {
|
||||||
@ -794,27 +793,27 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if txIdx == -1 {
|
if txIdx == -1 {
|
||||||
return eth.EthTx{}, fmt.Errorf("cannot find the msg in the tipset")
|
return ethtypes.EthTx{}, fmt.Errorf("cannot find the msg in the tipset")
|
||||||
}
|
}
|
||||||
|
|
||||||
blkHash, err := ethtypes.NewEthHashFromCid(parentTsCid)
|
blkHash, err := ethtypes.NewEthHashFromCid(parentTsCid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return eth.EthTx{}, err
|
return ethtypes.EthTx{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := a.ChainAPI.ChainGetMessage(ctx, msgLookup.Message)
|
msg, err := a.ChainAPI.ChainGetMessage(ctx, msgLookup.Message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return eth.EthTx{}, err
|
return ethtypes.EthTx{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
fromEthAddr, err := a.lookupEthAddress(ctx, msg.From)
|
fromEthAddr, err := a.lookupEthAddress(ctx, msg.From)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return eth.EthTx{}, err
|
return ethtypes.EthTx{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
toEthAddr, err := a.lookupEthAddress(ctx, msg.To)
|
toEthAddr, err := a.lookupEthAddress(ctx, msg.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return eth.EthTx{}, err
|
return ethtypes.EthTx{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
toAddr := &toEthAddr
|
toAddr := &toEthAddr
|
||||||
@ -835,7 +834,7 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
|
|||||||
input = params.Initcode
|
input = params.Initcode
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return eth.EthTx{}, err
|
return ethtypes.EthTx{}, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Otherwise, try to decode as a cbor byte array.
|
// Otherwise, try to decode as a cbor byte array.
|
||||||
@ -846,7 +845,7 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tx := eth.EthTx{
|
tx := ethtypes.EthTx{
|
||||||
ChainID: ethtypes.EthUint64(build.Eip155ChainId),
|
ChainID: ethtypes.EthUint64(build.Eip155ChainId),
|
||||||
Hash: txHash,
|
Hash: txHash,
|
||||||
BlockHash: blkHash,
|
BlockHash: blkHash,
|
||||||
@ -867,7 +866,7 @@ func (a *EthModule) newEthTxFromFilecoinMessageLookup(ctx context.Context, msgLo
|
|||||||
return tx, nil
|
return tx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEthTxReceipt(tx eth.EthTx, lookup *api.MsgLookup, replay *api.InvocResult) (api.EthTxReceipt, error) {
|
func NewEthTxReceipt(tx ethtypes.EthTx, lookup *api.MsgLookup, replay *api.InvocResult) (api.EthTxReceipt, error) {
|
||||||
receipt := api.EthTxReceipt{
|
receipt := api.EthTxReceipt{
|
||||||
TransactionHash: tx.Hash,
|
TransactionHash: tx.Hash,
|
||||||
TransactionIndex: tx.TransactionIndex,
|
TransactionIndex: tx.TransactionIndex,
|
||||||
|
Loading…
Reference in New Issue
Block a user