Skip to content

Commit

Permalink
Merge pull request #5665 from filecoin-project/feat/fevm-eam-refactor
Browse files Browse the repository at this point in the history
fix: update evm actor creation for eam refactor
  • Loading branch information
simlecode authored Jan 17, 2023
2 parents 0b510c5 + cda7f33 commit f2dca96
Show file tree
Hide file tree
Showing 18 changed files with 421 additions and 308 deletions.
18 changes: 8 additions & 10 deletions app/submodule/eth/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,20 +582,13 @@ func (a *ethAPI) ethCallToFilecoinMessage(ctx context.Context, tx types.EthCall)
// this is a contract creation
to = builtintypes.EthereumAddressManagerActorAddr

nonce, err := a.mpool.MpoolGetNonce(ctx, from)
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)
}
params = params2
method = builtintypes.MethodsEAM.Create
method = builtintypes.MethodsEAM.CreateExternal
} else {
addr, err := tx.To.ToFilecoinAddress()
if err != nil {
Expand Down Expand Up @@ -828,6 +821,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 types.EthTx{}, err
Expand Down
13 changes: 3 additions & 10 deletions cmd/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,8 @@ var evmDeployCmd = &cmds.Command{
return err
}

nonce, err := env.(*node.Env).MessagePoolAPI.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)
}
Expand All @@ -249,7 +242,7 @@ var evmDeployCmd = &cmds.Command{
To: builtintypes.EthereumAddressManagerActorAddr,
From: fromAddr,
Value: big.Zero(),
Method: builtintypes.MethodsEAM.Create,
Method: builtintypes.MethodsEAM.CreateExternal,
Params: params,
}

Expand Down
2 changes: 1 addition & 1 deletion extern/filecoin-ffi
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/filecoin-project/go-fil-markets v1.25.2
github.com/filecoin-project/go-jsonrpc v0.1.5
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/pubsub v1.0.0
github.com/filecoin-project/specs-actors v0.9.15
github.com/filecoin-project/specs-actors/v2 v2.3.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4
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=
Expand Down
23 changes: 16 additions & 7 deletions pkg/chain/signatures.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package chain

import (
"golang.org/x/xerrors"
"fmt"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/network"
Expand All @@ -20,21 +20,30 @@ func AuthenticateMessage(msg *types.SignedMessage, signer address.Address) error
typ := msg.Signature.Type
switch typ {
case crypto.SigTypeDelegated:
txArgs, err := types.NewEthTxArgsFromMessage(&msg.Message)
txArgs, err := types.EthTxArgsFromMessage(&msg.Message)
if err != nil {
return xerrors.Errorf("failed to reconstruct eth transaction: %w", err)
return fmt.Errorf("failed to reconstruct eth transaction: %w", err)
}
msg, err := txArgs.ToRlpUnsignedMsg()
roundTripMsg, err := txArgs.ToUnsignedMessage(msg.Message.From)
if err != nil {
return xerrors.Errorf("failed to repack eth rlp message: %w", err)
return fmt.Errorf("failed to reconstruct filecoin msg: %w", err)
}
digest = msg

if !msg.Message.Equals(roundTripMsg) {
return fmt.Errorf("ethereum tx failed to roundtrip")
}

rlpEncodedMsg, err := txArgs.ToRlpUnsignedMsg()
if err != nil {
return fmt.Errorf("failed to repack eth rlp message: %w", err)
}
digest = rlpEncodedMsg
default:
digest = msg.Message.Cid().Bytes()
}

if err := crypto.Verify(&msg.Signature, signer, digest); err != nil {
return xerrors.Errorf("message %s has invalid signature (type %d): %w", msg.Cid(), typ, err)
return fmt.Errorf("message %s has invalid signature (type %d): %w", msg.Cid(), typ, err)
}
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/events/filter/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ func (ei *EventIndex) CollectEvents(ctx context.Context, te *TipSetEvents, rever
}

isIndexedValue := func(b uint8) bool {
return b&types.EventFlagIndexedValue == types.EventFlagIndexedValue
// currently we mark the full entry as indexed if either the key
// or the value are indexed; in the future we will need finer-grained
// management of indices
return b&(types.EventFlagIndexedKey|types.EventFlagIndexedValue) > 0
}

for msgIdx, em := range ems {
Expand Down
4 changes: 2 additions & 2 deletions venus-devtool/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/filecoin-project/go-data-transfer v1.15.2
github.com/filecoin-project/go-fil-markets v1.25.2
github.com/filecoin-project/go-jsonrpc v0.1.9
github.com/filecoin-project/go-state-types v0.10.0-alpha-9
github.com/filecoin-project/lotus v1.18.2-0.20230111002849-3456d90e0d0b
github.com/filecoin-project/go-state-types v0.10.0-alpha-10
github.com/filecoin-project/lotus v1.20.0-pre-rc.0.20230115023118-b6eb7fcd962e
github.com/filecoin-project/venus v0.0.0-00010101000000-000000000000
github.com/google/uuid v1.3.0
github.com/ipfs/go-block-format v0.0.3
Expand Down
8 changes: 4 additions & 4 deletions venus-devtool/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,14 @@ github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4
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 v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc=
github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNdofHZoGPjfNaAo5Q=
github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo=
github.com/filecoin-project/index-provider v0.9.1 h1:Jnh9dviIHvQxZ2baNoYu3n8z6F9O62ksnVlyREgPyyM=
github.com/filecoin-project/lotus v1.18.2-0.20230111002849-3456d90e0d0b h1:CWGe1J4zNxpaFMRL1tf6VKjXhWLBFqs91VslUSt+aP4=
github.com/filecoin-project/lotus v1.18.2-0.20230111002849-3456d90e0d0b/go.mod h1:GXpDE5JAJjIrPfKXwTFZ4HHPhKI4NPJMO9oKJ7wsgoY=
github.com/filecoin-project/lotus v1.20.0-pre-rc.0.20230115023118-b6eb7fcd962e h1:TMUYpDsk+DJHlyiSSJp6EErphKkY/MDfnn++8n43Srw=
github.com/filecoin-project/lotus v1.20.0-pre-rc.0.20230115023118-b6eb7fcd962e/go.mod h1:Lzz0lq20H+5z2RKaKvrYQK04hpr5Sd7DlFkRwvrSmWQ=
github.com/filecoin-project/pubsub v1.0.0 h1:ZTmT27U07e54qV1mMiQo4HDr0buo8I1LDHBYLXlsNXM=
github.com/filecoin-project/pubsub v1.0.0/go.mod h1:GkpB33CcUtUNrLPhJgfdy4FDx4OMNR9k+46DHx/Lqrg=
github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao=
Expand Down
Binary file modified venus-shared/actors/builtin-actors-code/v10.tar.zst
Binary file not shown.
Binary file modified venus-shared/actors/builtin-actors-code/v8.tar.zst
Binary file not shown.
Binary file modified venus-shared/actors/builtin-actors-code/v9.tar.zst
Binary file not shown.
Loading

0 comments on commit f2dca96

Please sign in to comment.