From 5408f5024c2a5b8bb127373aae5aa893967dfa3d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 7 Nov 2023 16:04:26 -0800 Subject: [PATCH 1/9] feat: eth: encode eth tx input as solidity ABI --- node/impl/full/eth_utils.go | 44 ++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/node/impl/full/eth_utils.go b/node/impl/full/eth_utils.go index 8bbb58b9bbd..7b5a35b403f 100644 --- a/node/impl/full/eth_utils.go +++ b/node/impl/full/eth_utils.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/ipfs/go-cid" + "github.com/multiformats/go-multicodec" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -465,19 +466,23 @@ func newEthTxFromSignedMessage(smsg *types.SignedMessage, st *state.StateTree) ( tx = ethTxFromNativeMessage(smsg.VMMessage(), st) tx.Hash, err = ethtypes.EthHashFromCid(smsg.Cid()) if err != nil { - return tx, err + return ethtypes.EthTx{}, err } } else { // BLS Filecoin message tx = ethTxFromNativeMessage(smsg.VMMessage(), st) tx.Hash, err = ethtypes.EthHashFromCid(smsg.Message.Cid()) if err != nil { - return tx, err + return ethtypes.EthTx{}, err } } return tx, nil } +// Convert a native message to an eth transaction. +// +// - The state-tree must be from after the message was applied (ideally the following tipset). +// // ethTxFromNativeMessage does NOT populate: // - BlockHash // - BlockNumber @@ -487,9 +492,42 @@ func ethTxFromNativeMessage(msg *types.Message, st *state.StateTree) ethtypes.Et // We don't care if we error here, conversion is best effort for non-eth transactions from, _ := lookupEthAddress(msg.From, st) to, _ := lookupEthAddress(msg.To, st) + toPtr := &to + + // Convert the input parameters to "solidity ABI". + + // For empty, we use "0" as the codec. Otherwise, we use CBOR for message + // parameters. + var codec uint64 + if len(msg.Params) > 0 { + codec = uint64(multicodec.Cbor) + } + + // We try to decode the input as an EVM method invocation and/or a contract creation. If + // that fails, we encode the "native" parameters as Solidity ABI. + var input []byte + switch msg.Method { + case builtintypes.MethodsEVM.InvokeContract, builtintypes.MethodsEAM.CreateExternal: + inp, err := decodePayload(msg.Params, codec) + if err == nil { + // If this is a valid "create external", unset the "to" address. + if msg.Method == builtintypes.MethodsEAM.CreateExternal { + toPtr = nil + } + input = []byte(inp) + break + } + // Yeah, we're going to ignore errors here because the user can send whatever they + // want and may send garbage. + fallthrough + default: + input = encodeFilecoinParamsAsABI(msg.Method, codec, msg.Params) + } + return ethtypes.EthTx{ - To: &to, + To: toPtr, From: from, + Input: input, Nonce: ethtypes.EthUint64(msg.Nonce), ChainID: ethtypes.EthUint64(build.Eip155ChainId), Value: ethtypes.EthBigInt(msg.Value), From d49ff11cb3dd6f10f4dbc818c25450e923af4ca3 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 16 Nov 2023 15:36:20 +0100 Subject: [PATCH 2/9] test: eth: create from native account produces correct receipt --- itests/eth_transactions_test.go | 18 ++++++++---------- itests/fevm_address_test.go | 33 +++++++++++++++++---------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/itests/eth_transactions_test.go b/itests/eth_transactions_test.go index 6d60f678636..4be8f3399c9 100644 --- a/itests/eth_transactions_test.go +++ b/itests/eth_transactions_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/stretchr/testify/require" + "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/manifest" @@ -377,15 +378,12 @@ func deployContractTx(ctx context.Context, client *kit.TestFullNode, ethAddr eth } func waitForEthTxReceipt(ctx context.Context, client *kit.TestFullNode, hash ethtypes.EthHash) (*api.EthTxReceipt, error) { - var receipt *api.EthTxReceipt - var err error - for i := 0; i < 10000000000; i++ { - receipt, err = client.EthGetTransactionReceipt(ctx, hash) - if err != nil || receipt == nil { - time.Sleep(500 * time.Millisecond) - continue - } - break + if mcid, err := client.EthGetMessageCidByTransactionHash(ctx, &hash); err != nil { + return nil, err + } else if mcid == nil { + return nil, xerrors.Errorf("couldn't find message CID for txn hash: %s", hash) + } else { + client.WaitMsg(ctx, *mcid) + return client.EthGetTransactionReceipt(ctx, hash) } - return receipt, err } diff --git a/itests/fevm_address_test.go b/itests/fevm_address_test.go index 9eaac464773..ca8baaf000f 100644 --- a/itests/fevm_address_test.go +++ b/itests/fevm_address_test.go @@ -15,7 +15,6 @@ import ( "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/go-state-types/exitcode" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors" @@ -43,7 +42,7 @@ func effectiveEthAddressForCreate(t *testing.T, sender address.Address) ethtypes panic("unreachable") } -func createAndDeploy(ctx context.Context, t *testing.T, client *kit.TestFullNode, fromAddr address.Address, contract []byte) *api.MsgLookup { +func createAndDeploy(ctx context.Context, t *testing.T, client *kit.TestFullNode, fromAddr address.Address, contract []byte) *api.EthTxReceipt { // Create and deploy evm actor method := builtintypes.MethodsEAM.CreateExternal @@ -61,10 +60,13 @@ func createAndDeploy(ctx context.Context, t *testing.T, client *kit.TestFullNode smsg, err := client.MpoolPushMessage(ctx, createMsg, nil) require.NoError(t, err) - wait, err := client.StateWaitMsg(ctx, smsg.Cid(), 0, 0, false) + txHash, err := client.EthGetTransactionHashByCid(ctx, smsg.Cid()) require.NoError(t, err) - require.Equal(t, exitcode.Ok, wait.Receipt.ExitCode) - return wait + + receipt, err := waitForEthTxReceipt(ctx, client, *txHash) + require.NoError(t, err) + require.EqualValues(t, ethtypes.EthUint64(0x1), receipt.Status) + return receipt } func getEthAddressTX(ctx context.Context, t *testing.T, client *kit.TestFullNode, wait *api.MsgLookup, ethAddr ethtypes.EthAddress) ethtypes.EthAddress { @@ -112,11 +114,11 @@ func TestAddressCreationBeforeDeploy(t *testing.T) { require.True(t, builtin.IsPlaceholderActor(actor.Code)) // Create and deploy evm actor - wait := createAndDeploy(ctx, t, client, fromAddr, contract) + receipt := createAndDeploy(ctx, t, client, fromAddr, contract) - // Check if eth address returned from CreateExternal is the same as eth address predicted at the start - createdEthAddr := getEthAddressTX(ctx, t, client, wait, ethAddr) - require.Equal(t, ethAddr, createdEthAddr) + // Check if eth address returned from CreateExternal is the same as eth address predicted at + // the start + require.Equal(t, ðAddr, receipt.ContractAddress) // Check if newly deployed actor still has funds actorPostCreate, err := client.StateGetActor(ctx, contractFilAddr, types.EmptyTSK) @@ -158,11 +160,11 @@ func TestDeployAddressMultipleTimes(t *testing.T) { require.True(t, builtin.IsPlaceholderActor(actor.Code)) // Create and deploy evm actor - wait := createAndDeploy(ctx, t, client, fromAddr, contract) + receipt := createAndDeploy(ctx, t, client, fromAddr, contract) - // Check if eth address returned from CreateExternal is the same as eth address predicted at the start - createdEthAddr := getEthAddressTX(ctx, t, client, wait, ethAddr) - require.Equal(t, ethAddr, createdEthAddr) + // Check if eth address returned from CreateExternal is the same as eth address predicted at + // the start + require.Equal(t, ðAddr, receipt.ContractAddress) // Check if newly deployed actor still has funds actorPostCreate, err := client.StateGetActor(ctx, contractFilAddr, types.EmptyTSK) @@ -171,10 +173,9 @@ func TestDeployAddressMultipleTimes(t *testing.T) { require.True(t, builtin.IsEvmActor(actorPostCreate.Code)) // Create and deploy evm actor - wait = createAndDeploy(ctx, t, client, fromAddr, contract) + receipt = createAndDeploy(ctx, t, client, fromAddr, contract) // Check that this time eth address returned from CreateExternal is not the same as eth address predicted at the start - createdEthAddr = getEthAddressTX(ctx, t, client, wait, ethAddr) - require.NotEqual(t, ethAddr, createdEthAddr) + require.NotEqual(t, ðAddr, receipt.ContractAddress) } From a354787725ffed6b98dc3485e267f2481ad2ba5e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 17 Nov 2023 10:52:56 +0100 Subject: [PATCH 3/9] fix compile on CI --- itests/eth_hash_lookup_test.go | 6 ++++++ itests/eth_transactions_test.go | 21 ++++----------------- itests/fevm_address_test.go | 2 +- itests/kit/evm.go | 12 ++++++++++++ 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/itests/eth_hash_lookup_test.go b/itests/eth_hash_lookup_test.go index 0bf32108852..00378e6eaf3 100644 --- a/itests/eth_hash_lookup_test.go +++ b/itests/eth_hash_lookup_test.go @@ -266,6 +266,12 @@ func TestTransactionHashLookupSecpFilecoinMessage(t *testing.T) { toEth, err := client.FilecoinAddressToEthAddress(ctx, toId) require.NoError(t, err) require.Equal(t, &toEth, chainTx.To) + + // verify that the params are correctly encoded. + expected, err := hex.DecodeString("868e10c40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000") + require.NoError(t, err) + + require.Equal(t, expected, chainTx.Input) } // TestTransactionHashLookupSecpFilecoinMessage tests to see if lotus can find a Secp Filecoin Message using the transaction hash diff --git a/itests/eth_transactions_test.go b/itests/eth_transactions_test.go index 4be8f3399c9..916e3ef829c 100644 --- a/itests/eth_transactions_test.go +++ b/itests/eth_transactions_test.go @@ -8,12 +8,10 @@ import ( "time" "github.com/stretchr/testify/require" - "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/manifest" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" @@ -79,7 +77,7 @@ func TestValueTransferValidSignature(t *testing.T) { client.EVM().SignTransaction(&tx, key.PrivateKey) hash := client.EVM().SubmitTransaction(ctx, &tx) - receipt, err := waitForEthTxReceipt(ctx, client, hash) + receipt, err := client.EVM().WaitTransaction(ctx, hash) require.NoError(t, err) require.NotNil(t, receipt) require.EqualValues(t, ethAddr, receipt.From) @@ -167,7 +165,7 @@ func TestContractDeploymentValidSignature(t *testing.T) { client.EVM().SignTransaction(tx, key.PrivateKey) hash := client.EVM().SubmitTransaction(ctx, tx) - receipt, err := waitForEthTxReceipt(ctx, client, hash) + receipt, err := client.EVM().WaitTransaction(ctx, hash) require.NoError(t, err) require.NotNil(t, receipt) @@ -214,7 +212,7 @@ func TestContractInvocation(t *testing.T) { client.EVM().SignTransaction(tx, key.PrivateKey) hash := client.EVM().SubmitTransaction(ctx, tx) - receipt, err := waitForEthTxReceipt(ctx, client, hash) + receipt, err := client.EVM().WaitTransaction(ctx, hash) require.NoError(t, err) require.NotNil(t, receipt) require.EqualValues(t, ethtypes.EthUint64(0x1), receipt.Status) @@ -268,7 +266,7 @@ func TestContractInvocation(t *testing.T) { client.EVM().SignTransaction(&invokeTx, key.PrivateKey) hash = client.EVM().SubmitTransaction(ctx, &invokeTx) - receipt, err = waitForEthTxReceipt(ctx, client, hash) + receipt, err = client.EVM().WaitTransaction(ctx, hash) require.NoError(t, err) require.NotNil(t, receipt) @@ -376,14 +374,3 @@ func deployContractTx(ctx context.Context, client *kit.TestFullNode, ethAddr eth S: big.Zero(), }, nil } - -func waitForEthTxReceipt(ctx context.Context, client *kit.TestFullNode, hash ethtypes.EthHash) (*api.EthTxReceipt, error) { - if mcid, err := client.EthGetMessageCidByTransactionHash(ctx, &hash); err != nil { - return nil, err - } else if mcid == nil { - return nil, xerrors.Errorf("couldn't find message CID for txn hash: %s", hash) - } else { - client.WaitMsg(ctx, *mcid) - return client.EthGetTransactionReceipt(ctx, hash) - } -} diff --git a/itests/fevm_address_test.go b/itests/fevm_address_test.go index ca8baaf000f..b3cbd393320 100644 --- a/itests/fevm_address_test.go +++ b/itests/fevm_address_test.go @@ -63,7 +63,7 @@ func createAndDeploy(ctx context.Context, t *testing.T, client *kit.TestFullNode txHash, err := client.EthGetTransactionHashByCid(ctx, smsg.Cid()) require.NoError(t, err) - receipt, err := waitForEthTxReceipt(ctx, client, *txHash) + receipt, err := client.EVM().WaitTransaction(ctx, *txHash) require.NoError(t, err) require.EqualValues(t, ethtypes.EthUint64(0x1), receipt.Status) return receipt diff --git a/itests/kit/evm.go b/itests/kit/evm.go index 99844ca3097..0d7af25782b 100644 --- a/itests/kit/evm.go +++ b/itests/kit/evm.go @@ -17,6 +17,7 @@ import ( "github.com/stretchr/testify/require" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/crypto/sha3" + "golang.org/x/xerrors" "github.com/filecoin-project/go-address" amt4 "github.com/filecoin-project/go-amt-ipld/v4" @@ -291,6 +292,17 @@ func (e *EVM) InvokeContractByFuncNameExpectExit(ctx context.Context, fromAddr a require.Equal(e.t, exit, wait.Receipt.ExitCode) } +func (e *EVM) WaitTransaction(ctx context.Context, hash ethtypes.EthHash) (*api.EthTxReceipt, error) { + if mcid, err := e.EthGetMessageCidByTransactionHash(ctx, &hash); err != nil { + return nil, err + } else if mcid == nil { + return nil, xerrors.Errorf("couldn't find message CID for txn hash: %s", hash) + } else { + e.WaitMsg(ctx, *mcid) + return e.EthGetTransactionReceipt(ctx, hash) + } +} + // function signatures are the first 4 bytes of the hash of the function name and types func CalcFuncSignature(funcName string) []byte { hasher := sha3.NewLegacyKeccak256() From ba571b976b3bb770efb804413d1612e0212d2160 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 17 Nov 2023 11:04:08 +0100 Subject: [PATCH 4/9] test empty txn --- itests/eth_hash_lookup_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itests/eth_hash_lookup_test.go b/itests/eth_hash_lookup_test.go index 00378e6eaf3..7699d688523 100644 --- a/itests/eth_hash_lookup_test.go +++ b/itests/eth_hash_lookup_test.go @@ -271,7 +271,7 @@ func TestTransactionHashLookupSecpFilecoinMessage(t *testing.T) { expected, err := hex.DecodeString("868e10c40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000") require.NoError(t, err) - require.Equal(t, expected, chainTx.Input) + require.Equal(t, ethtypes.EthBytes(expected), chainTx.Input) } // TestTransactionHashLookupSecpFilecoinMessage tests to see if lotus can find a Secp Filecoin Message using the transaction hash From 80bfc796753d8c62281d4ede3cd9566f26a57f8a Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 17 Nov 2023 13:03:29 +0100 Subject: [PATCH 5/9] more tests --- itests/eth_hash_lookup_test.go | 20 +++++- itests/eth_transactions_test.go | 109 ++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 1 deletion(-) diff --git a/itests/eth_hash_lookup_test.go b/itests/eth_hash_lookup_test.go index 7699d688523..e1474a90d10 100644 --- a/itests/eth_hash_lookup_test.go +++ b/itests/eth_hash_lookup_test.go @@ -187,6 +187,18 @@ func TestTransactionHashLookupBlsFilecoinMessage(t *testing.T) { toEth, err := client.FilecoinAddressToEthAddress(ctx, toId) require.NoError(t, err) require.Equal(t, &toEth, chainTx.To) + + const expectedHex = "868e10c4" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000060" + + "0000000000000000000000000000000000000000000000000000000000000000" + + // verify that the params are correctly encoded. + expected, err := hex.DecodeString(expectedHex) + require.NoError(t, err) + + require.Equal(t, ethtypes.EthBytes(expected), chainTx.Input) } // TestTransactionHashLookupSecpFilecoinMessage tests to see if lotus can find a Secp Filecoin Message using the transaction hash @@ -267,8 +279,14 @@ func TestTransactionHashLookupSecpFilecoinMessage(t *testing.T) { require.NoError(t, err) require.Equal(t, &toEth, chainTx.To) + const expectedHex = "868e10c4" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000000" + + "0000000000000000000000000000000000000000000000000000000000000060" + + "0000000000000000000000000000000000000000000000000000000000000000" + // verify that the params are correctly encoded. - expected, err := hex.DecodeString("868e10c40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000") + expected, err := hex.DecodeString(expectedHex) require.NoError(t, err) require.Equal(t, ethtypes.EthBytes(expected), chainTx.Input) diff --git a/itests/eth_transactions_test.go b/itests/eth_transactions_test.go index 916e3ef829c..488691f704b 100644 --- a/itests/eth_transactions_test.go +++ b/itests/eth_transactions_test.go @@ -9,10 +9,13 @@ import ( "github.com/stretchr/testify/require" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" + builtin2 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types/ethtypes" @@ -374,3 +377,109 @@ func deployContractTx(ctx context.Context, client *kit.TestFullNode, ethAddr eth S: big.Zero(), }, nil } + +func TestEthTxFromNativeAccount(t *testing.T) { + blockTime := 10 * time.Millisecond + client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC()) + + ens.InterconnectAll().BeginMining(blockTime) + + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + + msg := &types.Message{ + From: client.DefaultKey.Address, + To: client.DefaultKey.Address, + Value: abi.TokenAmount(types.MustParseFIL("100")), + Method: builtin2.MethodsEVM.InvokeContract, + } + + // Send a message with no input. + + sMsg, err := client.MpoolPushMessage(ctx, msg, nil) + require.NoError(t, err) + client.WaitMsg(ctx, sMsg.Cid()) + + hash, err := client.EthGetTransactionHashByCid(ctx, sMsg.Cid()) + require.NoError(t, err) + tx, err := client.EthGetTransactionByHash(ctx, hash) + require.NoError(t, err) + + // Expect empty input params given that we "invoked" the contract (well, invoked ourselves). + require.Equal(t, ethtypes.EthBytes{}, tx.Input) + + // Send a message with some input. + + input := abi.CborBytes([]byte{0x1, 0x2, 0x3, 0x4}) + msg.Params, err = actors.SerializeParams(&input) + require.NoError(t, err) + + sMsg, err = client.MpoolPushMessage(ctx, msg, nil) + require.NoError(t, err) + client.WaitMsg(ctx, sMsg.Cid()) + hash, err = client.EthGetTransactionHashByCid(ctx, sMsg.Cid()) + require.NoError(t, err) + tx, err = client.EthGetTransactionByHash(ctx, hash) + require.NoError(t, err) + + // Expect the decoded input. + require.EqualValues(t, input, tx.Input) + + // Invoke the contract, but with incorrectly encoded input. We expect this to be abi-encoded + // as if it were any other method call. + + msg.Params = input + require.NoError(t, err) + + sMsg, err = client.MpoolPushMessage(ctx, msg, nil) + require.NoError(t, err) + client.WaitMsg(ctx, sMsg.Cid()) + hash, err = client.EthGetTransactionHashByCid(ctx, sMsg.Cid()) + require.NoError(t, err) + tx, err = client.EthGetTransactionByHash(ctx, hash) + require.NoError(t, err) + + const expectedHex1 = "868e10c4" + // "handle filecoin method" function selector + // InvokeEVM method number + "00000000000000000000000000000000000000000000000000000000e525aa15" + + // CBOR multicodec (0x51) + "0000000000000000000000000000000000000000000000000000000000000051" + + // Offset + "0000000000000000000000000000000000000000000000000000000000000060" + + // Number of bytes in the input (4) + "0000000000000000000000000000000000000000000000000000000000000004" + + // Input: 1, 2, 3, 4 + "0102030400000000000000000000000000000000000000000000000000000000" + + input, err = hex.DecodeString(expectedHex1) + require.NoError(t, err) + require.EqualValues(t, input, tx.Input) + + // Invoke a random method with the same input. We expect the same result as above, but with + // a different method number. + + msg.Method += 1 + + sMsg, err = client.MpoolPushMessage(ctx, msg, nil) + require.NoError(t, err) + client.WaitMsg(ctx, sMsg.Cid()) + hash, err = client.EthGetTransactionHashByCid(ctx, sMsg.Cid()) + require.NoError(t, err) + tx, err = client.EthGetTransactionByHash(ctx, hash) + require.NoError(t, err) + + const expectedHex2 = "868e10c4" + // "handle filecoin method" function selector + // InvokeEVM+1 + "00000000000000000000000000000000000000000000000000000000e525aa16" + + // CBOR multicodec (0x51) + "0000000000000000000000000000000000000000000000000000000000000051" + + // Offset + "0000000000000000000000000000000000000000000000000000000000000060" + + // Number of bytes in the input (4) + "0000000000000000000000000000000000000000000000000000000000000004" + + // Input: 1, 2, 3, 4 + "0102030400000000000000000000000000000000000000000000000000000000" + input, err = hex.DecodeString(expectedHex2) + require.NoError(t, err) + require.EqualValues(t, input, tx.Input) +} From e114b9a9e40f7dcd2a1b491097451a6173bc8c3d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 17 Nov 2023 13:33:10 +0100 Subject: [PATCH 6/9] remove dead code --- itests/fevm_address_test.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/itests/fevm_address_test.go b/itests/fevm_address_test.go index b3cbd393320..4ac90db7a33 100644 --- a/itests/fevm_address_test.go +++ b/itests/fevm_address_test.go @@ -69,17 +69,6 @@ func createAndDeploy(ctx context.Context, t *testing.T, client *kit.TestFullNode return receipt } -func getEthAddressTX(ctx context.Context, t *testing.T, client *kit.TestFullNode, wait *api.MsgLookup, ethAddr ethtypes.EthAddress) ethtypes.EthAddress { - // Check if eth address returned from CreateExternal is the same as eth address predicted at the start - var createExternalReturn eam.CreateExternalReturn - err := createExternalReturn.UnmarshalCBOR(bytes.NewReader(wait.Receipt.Return)) - require.NoError(t, err) - - createdEthAddr, err := ethtypes.CastEthAddress(createExternalReturn.EthAddress[:]) - require.NoError(t, err) - return createdEthAddr -} - func TestAddressCreationBeforeDeploy(t *testing.T) { ctx, cancel, client := kit.SetupFEVMTest(t) defer cancel() From ccb501cb90952dfe4970b56616266b8f92515a2b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 17 Nov 2023 13:47:19 +0100 Subject: [PATCH 7/9] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cb54b5f3d6..aa7535df533 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ - feat: Added instructions on how to setup Prometheus/Grafana for monitoring a local Lotus node [filecoin-project/lotus#11276](https://github.com/filecoin-project/lotus/pull/11276) - fix: Exclude reverted events in `eth_getLogs` results [filecoin-project/lotus#11318](https://github.com/filecoin-project/lotus/pull/11318) - fix: The Ethereum API will now use the correct state-tree when resolving "native" addresses into masked ID addresses. Additionally, pending messages from native account types won't be visible in the Ethereum API because there is no "correct" state-tree to pick in this case. However, pending _Ethereum_ transactions and native messages that have landed on-chain will still be visible through the Ethereum API. +- feat: Unambiguously translate native messages to Ethereum transactions by: + - Detecting native messages that "look" like Ethereum transactions (creating smart contracts, invoking a smart contract, etc.), and decoding them as such. + - Otherwise, ABI-encoding the inputs as if they were calls to a `handle_filecoin_method` Solidity method. ## New features - feat: Add move-partition command ([filecoin-project/lotus#11290](https://github.com/filecoin-project/lotus/pull/11290)) From e107dabf5e1a36d1501c30be482761d7cf7446b9 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 17 Nov 2023 19:16:40 +0100 Subject: [PATCH 8/9] remove unused imports --- itests/fevm_address_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/itests/fevm_address_test.go b/itests/fevm_address_test.go index 4ac90db7a33..aea56264efe 100644 --- a/itests/fevm_address_test.go +++ b/itests/fevm_address_test.go @@ -1,7 +1,6 @@ package itests import ( - "bytes" "context" "encoding/hex" "os" @@ -14,7 +13,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" builtintypes "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v10/eam" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors" From b0fd04305e182e12a7f2cc4eeb3077f031a463dd Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 17 Nov 2023 19:25:13 +0100 Subject: [PATCH 9/9] fix lint --- itests/eth_transactions_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itests/eth_transactions_test.go b/itests/eth_transactions_test.go index 488691f704b..026ac238790 100644 --- a/itests/eth_transactions_test.go +++ b/itests/eth_transactions_test.go @@ -458,7 +458,7 @@ func TestEthTxFromNativeAccount(t *testing.T) { // Invoke a random method with the same input. We expect the same result as above, but with // a different method number. - msg.Method += 1 + msg.Method++ sMsg, err = client.MpoolPushMessage(ctx, msg, nil) require.NoError(t, err)