update go-state-types

use CreateExternal

use CreateExternal in itest evm deployment

add missing import

update gst
This commit is contained in:
vyzo 2023-01-13 22:31:08 +02:00 committed by Aayush
parent cb10108c8e
commit 859cdca4f7
7 changed files with 23 additions and 35 deletions

View File

@ -6,6 +6,8 @@ import (
"fmt" "fmt"
mathbig "math/big" mathbig "math/big"
"github.com/filecoin-project/go-state-types/abi"
cbg "github.com/whyrusleeping/cbor-gen" cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
"golang.org/x/xerrors" "golang.org/x/xerrors"
@ -71,16 +73,12 @@ func EthTxArgsFromMessage(msg *types.Message) (EthTxArgs, error) {
if msg.To == builtintypes.EthereumAddressManagerActorAddr { if msg.To == builtintypes.EthereumAddressManagerActorAddr {
switch msg.Method { switch msg.Method {
// TODO: Uncomment case builtintypes.MethodsEAM.CreateExternal:
//case builtintypes.MethodsEAM.CreateExternal: var create abi.CborBytes
case builtintypes.MethodsEAM.Create:
// TODO: Uncomment
// var create eam.CreateExternalParams
var create eam.CreateParams
if err := create.UnmarshalCBOR(paramsReader); err != nil { if err := create.UnmarshalCBOR(paramsReader); err != nil {
return EthTxArgs{}, err return EthTxArgs{}, err
} }
params = create.Initcode params = create
default: default:
return EthTxArgs{}, fmt.Errorf("unsupported EAM method") return EthTxArgs{}, fmt.Errorf("unsupported EAM method")
} }

View File

@ -249,15 +249,8 @@ var EvmDeployCmd = &cli.Command{
return err return err
} }
nonce, err := api.MpoolGetNonce(ctx, fromAddr) initcode := abi.CborBytes(contract)
if err != nil { params, err := actors.SerializeParams(&initcode)
nonce = 0 // assume a zero nonce on error (e.g. sender doesn't exist).
}
params, err := actors.SerializeParams(&eam.CreateParams{
Initcode: contract,
Nonce: nonce,
})
if err != nil { if err != nil {
return fmt.Errorf("failed to serialize Create params: %w", err) return fmt.Errorf("failed to serialize Create params: %w", err)
} }
@ -266,7 +259,7 @@ var EvmDeployCmd = &cli.Command{
To: builtintypes.EthereumAddressManagerActorAddr, To: builtintypes.EthereumAddressManagerActorAddr,
From: fromAddr, From: fromAddr,
Value: big.Zero(), Value: big.Zero(),
Method: builtintypes.MethodsEAM.Create, Method: builtintypes.MethodsEAM.CreateExternal,
Params: params, Params: params,
} }

2
extern/filecoin-ffi vendored

@ -1 +1 @@
Subproject commit c4adeb4532719acf7b1c182cb98a3cca7b955a14 Subproject commit 86eac2161f442945bffee3fbfe7d094c20b48dd3

2
go.mod
View File

@ -44,7 +44,7 @@ require (
github.com/filecoin-project/go-legs v0.4.4 github.com/filecoin-project/go-legs v0.4.4
github.com/filecoin-project/go-padreader v0.0.1 github.com/filecoin-project/go-padreader v0.0.1
github.com/filecoin-project/go-paramfetch v0.0.4 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-statemachine v1.0.2
github.com/filecoin-project/go-statestore v0.2.0 github.com/filecoin-project/go-statestore v0.2.0
github.com/filecoin-project/go-storedcounter v0.1.0 github.com/filecoin-project/go-storedcounter v0.1.0

4
go.sum
View File

@ -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.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.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.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-10 h1:QUpSayVFUADlrtzCh7SDNlbuaNSlYPBR46Nt7WpFl9I=
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/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 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 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc=
github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
amt4 "github.com/filecoin-project/go-amt-ipld/v4" 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" "github.com/filecoin-project/go-state-types/big"
builtintypes "github.com/filecoin-project/go-state-types/builtin" 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/builtin/v10/eam"
@ -45,11 +46,9 @@ func (e *EVM) DeployContract(ctx context.Context, sender address.Address, byteco
var salt [32]byte var salt [32]byte
binary.BigEndian.PutUint64(salt[:], nonce) binary.BigEndian.PutUint64(salt[:], nonce)
method := builtintypes.MethodsEAM.Create2 method := builtintypes.MethodsEAM.CreateExternal
params, err := actors.SerializeParams(&eam.Create2Params{ initcode := abi.CborBytes(bytecode)
Initcode: bytecode, params, err := actors.SerializeParams(&initcode)
Salt: salt,
})
require.NoError(err) require.NoError(err)
msg := &types.Message{ msg := &types.Message{

View File

@ -675,15 +675,8 @@ func (a *EthModule) ethCallToFilecoinMessage(ctx context.Context, tx ethtypes.Et
// this is a contract creation // this is a contract creation
to = builtintypes.EthereumAddressManagerActorAddr to = builtintypes.EthereumAddressManagerActorAddr
nonce, err := a.Mpool.GetNonce(ctx, from, types.EmptyTSK) initcode := abi.CborBytes(tx.Data)
if err != nil { params2, err := actors.SerializeParams(&initcode)
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,
})
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to serialize Create params: %w", err) 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 var params eam.Create2Params
err = params.UnmarshalCBOR(bytes.NewReader(smsg.Message.Params)) err = params.UnmarshalCBOR(bytes.NewReader(smsg.Message.Params))
input = params.Initcode 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 { if err != nil {
return ethtypes.EthTx{}, err return ethtypes.EthTx{}, err