genesis: instantiate EAM at id 10.

This commit is contained in:
Raúl Kripalani 2022-10-21 00:16:30 +01:00 committed by vyzo
parent 7e7fff1dc5
commit 57a515f7a8
2 changed files with 21 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
cbor "github.com/ipfs/go-ipld-cbor"
@ -565,6 +566,11 @@ 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 {
return nil, xerrors.Errorf("failed to setup EAM: %w", err)
}
stateroot, err := st.Flush(ctx)
if err != nil {
return nil, xerrors.Errorf("flush state tree failed: %w", err)
@ -667,3 +673,18 @@ func MakeGenesisBlock(ctx context.Context, j journal.Journal, bs bstore.Blocksto
Genesis: b,
}, nil
}
func SetupEAM(_ context.Context, nst *state.StateTree) error {
// TODO Version10
codecid, ok := actors.GetActorCodeID(actors.Version8, actors.EamKey)
if !ok {
return fmt.Errorf("failed to get CodeCID for EAM during genesis")
}
header := &types.Actor{
Code: codecid,
Head: vm.EmptyObjectCid,
Balance: big.Zero(),
}
return nst.SetActor(builtintypes.EthereumAddressManagerActorAddr, header)
}

View File

@ -459,7 +459,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal
paramBytes = mustEnc(confirmParams)
}
_, err = doExecValue(ctx, genesisVm, minerInfos[i].maddr, power.Address, big.Zero(), builtintypes.MethodsMiner.ConfirmSectorProofsValid, paramBytes)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err)
@ -471,7 +470,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal
RawByteDelta: types.NewInt(uint64(m.SectorSize)),
QualityAdjustedDelta: sectorWeight,
}
_, err = doExecValue(ctx, genesisVm, power.Address, minerInfos[i].maddr, big.Zero(), power.Methods.UpdateClaimedPower, mustEnc(claimParams))
if err != nil {
return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err)