From 859cdca4f78511925118e14a9577d5709e859049 Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 13 Jan 2023 22:31:08 +0200 Subject: [PATCH] update go-state-types use CreateExternal use CreateExternal in itest evm deployment add missing import update gst --- chain/types/ethtypes/eth_transactions.go | 12 +++++------- cli/evm.go | 13 +++---------- extern/filecoin-ffi | 2 +- go.mod | 2 +- go.sum | 4 ++-- itests/kit/evm.go | 9 ++++----- node/impl/full/eth.go | 16 +++++++--------- 7 files changed, 23 insertions(+), 35 deletions(-) diff --git a/chain/types/ethtypes/eth_transactions.go b/chain/types/ethtypes/eth_transactions.go index e94215d60..62d68e49a 100644 --- a/chain/types/ethtypes/eth_transactions.go +++ b/chain/types/ethtypes/eth_transactions.go @@ -6,6 +6,8 @@ import ( "fmt" mathbig "math/big" + "github.com/filecoin-project/go-state-types/abi" + cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/crypto/sha3" "golang.org/x/xerrors" @@ -71,16 +73,12 @@ func EthTxArgsFromMessage(msg *types.Message) (EthTxArgs, error) { if msg.To == builtintypes.EthereumAddressManagerActorAddr { switch msg.Method { - // TODO: Uncomment - //case builtintypes.MethodsEAM.CreateExternal: - case builtintypes.MethodsEAM.Create: - // TODO: Uncomment - // var create eam.CreateExternalParams - var create eam.CreateParams + case builtintypes.MethodsEAM.CreateExternal: + var create abi.CborBytes if err := create.UnmarshalCBOR(paramsReader); err != nil { return EthTxArgs{}, err } - params = create.Initcode + params = create default: return EthTxArgs{}, fmt.Errorf("unsupported EAM method") } diff --git a/cli/evm.go b/cli/evm.go index afc202e79..739f56f8b 100644 --- a/cli/evm.go +++ b/cli/evm.go @@ -249,15 +249,8 @@ var EvmDeployCmd = &cli.Command{ return err } - nonce, err := api.MpoolGetNonce(ctx, fromAddr) - if err != nil { - nonce = 0 // assume a zero nonce on error (e.g. sender doesn't exist). - } - - params, err := actors.SerializeParams(&eam.CreateParams{ - Initcode: contract, - Nonce: nonce, - }) + initcode := abi.CborBytes(contract) + params, err := actors.SerializeParams(&initcode) if err != nil { return fmt.Errorf("failed to serialize Create params: %w", err) } @@ -266,7 +259,7 @@ var EvmDeployCmd = &cli.Command{ To: builtintypes.EthereumAddressManagerActorAddr, From: fromAddr, Value: big.Zero(), - Method: builtintypes.MethodsEAM.Create, + Method: builtintypes.MethodsEAM.CreateExternal, Params: params, } diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index c4adeb453..86eac2161 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit c4adeb4532719acf7b1c182cb98a3cca7b955a14 +Subproject commit 86eac2161f442945bffee3fbfe7d094c20b48dd3 diff --git a/go.mod b/go.mod index f75bbcae4..485bfb5a4 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,7 @@ require ( github.com/filecoin-project/go-legs v0.4.4 github.com/filecoin-project/go-padreader v0.0.1 github.com/filecoin-project/go-paramfetch v0.0.4 - github.com/filecoin-project/go-state-types v0.10.0-alpha-9 + github.com/filecoin-project/go-state-types v0.10.0-alpha-10 github.com/filecoin-project/go-statemachine v1.0.2 github.com/filecoin-project/go-statestore v0.2.0 github.com/filecoin-project/go-storedcounter v0.1.0 diff --git a/go.sum b/go.sum index 419810695..6ae2f7c4b 100644 --- a/go.sum +++ b/go.sum @@ -356,8 +356,8 @@ github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psS github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= -github.com/filecoin-project/go-state-types v0.10.0-alpha-9 h1:Rriwh/Fs/hV15QqHuL47PkJMz4e8kLGRwgsdh+G+S5I= -github.com/filecoin-project/go-state-types v0.10.0-alpha-9/go.mod h1:FPgQE05BFwZxKw/vCuIaIrzfJKo4RPQQMMPGd43dAFI= +github.com/filecoin-project/go-state-types v0.10.0-alpha-10 h1:QUpSayVFUADlrtzCh7SDNlbuaNSlYPBR46Nt7WpFl9I= +github.com/filecoin-project/go-state-types v0.10.0-alpha-10/go.mod h1:FPgQE05BFwZxKw/vCuIaIrzfJKo4RPQQMMPGd43dAFI= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc= github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= diff --git a/itests/kit/evm.go b/itests/kit/evm.go index 06137778f..0c12229f5 100644 --- a/itests/kit/evm.go +++ b/itests/kit/evm.go @@ -14,6 +14,7 @@ import ( "github.com/filecoin-project/go-address" amt4 "github.com/filecoin-project/go-amt-ipld/v4" + "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" @@ -45,11 +46,9 @@ func (e *EVM) DeployContract(ctx context.Context, sender address.Address, byteco var salt [32]byte binary.BigEndian.PutUint64(salt[:], nonce) - method := builtintypes.MethodsEAM.Create2 - params, err := actors.SerializeParams(&eam.Create2Params{ - Initcode: bytecode, - Salt: salt, - }) + method := builtintypes.MethodsEAM.CreateExternal + initcode := abi.CborBytes(bytecode) + params, err := actors.SerializeParams(&initcode) require.NoError(err) msg := &types.Message{ diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index c400dae31..2b6ce1a62 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -675,15 +675,8 @@ func (a *EthModule) ethCallToFilecoinMessage(ctx context.Context, tx ethtypes.Et // this is a contract creation to = builtintypes.EthereumAddressManagerActorAddr - nonce, err := a.Mpool.GetNonce(ctx, from, types.EmptyTSK) - if err != nil { - nonce = 0 // assume a zero nonce on error (e.g. sender doesn't exist). - } - - params2, err := actors.SerializeParams(&eam.CreateParams{ - Initcode: tx.Data, - Nonce: nonce, - }) + initcode := abi.CborBytes(tx.Data) + params2, err := actors.SerializeParams(&initcode) if err != nil { return nil, fmt.Errorf("failed to serialize Create params: %w", err) } @@ -1488,6 +1481,11 @@ func newEthTxFromFilecoinMessage(ctx context.Context, smsg *types.SignedMessage, var params eam.Create2Params err = params.UnmarshalCBOR(bytes.NewReader(smsg.Message.Params)) input = params.Initcode + case builtintypes.MethodsEAM.CreateExternal: + toAddr = nil + var params abi.CborBytes + err = params.UnmarshalCBOR(bytes.NewReader(smsg.Message.Params)) + input = []byte(params) } if err != nil { return ethtypes.EthTx{}, err