From 30083949a03a37fe9bd2503430cae5df4461aefe Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 10 Nov 2022 04:35:41 +0200 Subject: [PATCH] fix genesis SetupEAM Only when actors version is >= 10 --- chain/gen/genesis/genesis.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index ba21843b3..98becc481 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -566,8 +566,8 @@ func MakeGenesisBlock(ctx context.Context, j journal.Journal, bs bstore.Blocksto return nil, xerrors.Errorf("make initial state tree failed: %w", err) } - // Set up the Ethereum Address Manager. - if err = SetupEAM(ctx, st); err != nil { + // Set up the Ethereum Address Manager + if err = SetupEAM(ctx, st, template.NetworkVersion); err != nil { return nil, xerrors.Errorf("failed to setup EAM: %w", err) } @@ -674,9 +674,18 @@ func MakeGenesisBlock(ctx context.Context, j journal.Journal, bs bstore.Blocksto }, nil } -func SetupEAM(_ context.Context, nst *state.StateTree) error { - // TODO Version10 - codecid, ok := actors.GetActorCodeID(actorstypes.Version10, actors.EamKey) +func SetupEAM(_ context.Context, nst *state.StateTree, nv network.Version) error { + av, err := actorstypes.VersionForNetwork(nv) + if err != nil { + return fmt.Errorf("failed to get actors version for network version %d: %w", nv, err) + } + + if av < actorstypes.Version10 { + // Not defined before version 10; migration has to create. + return nil + } + + codecid, ok := actors.GetActorCodeID(av, actors.EamKey) if !ok { return fmt.Errorf("failed to get CodeCID for EAM during genesis") }