genesis: Set remainder account balance correctly
This commit is contained in:
parent
42730bcf1c
commit
574a22de6c
@ -263,6 +263,11 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
}
|
}
|
||||||
|
|
||||||
totalFilAllocated := big.Zero()
|
totalFilAllocated := big.Zero()
|
||||||
|
|
||||||
|
// flush as ForEach works on the HAMT
|
||||||
|
if _, err := state.Flush(ctx); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
err = state.ForEach(func(addr address.Address, act *types.Actor) error {
|
err = state.ForEach(func(addr address.Address, act *types.Actor) error {
|
||||||
totalFilAllocated = big.Add(totalFilAllocated, act.Balance)
|
totalFilAllocated = big.Add(totalFilAllocated, act.Balance)
|
||||||
return nil
|
return nil
|
||||||
@ -277,15 +282,18 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
return nil, nil, xerrors.Errorf("somehow overallocated filecoin (allocated = %s)", types.FIL(totalFilAllocated))
|
return nil, nil, xerrors.Errorf("somehow overallocated filecoin (allocated = %s)", types.FIL(totalFilAllocated))
|
||||||
}
|
}
|
||||||
|
|
||||||
template.RemainderAccount.Balance = remainingFil
|
|
||||||
|
|
||||||
remAccKey, err := address.NewIDAddress(90)
|
remAccKey, err := address.NewIDAddress(90)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := createAccount(ctx, bs, cst, state, remAccKey, template.RemainderAccount); err != nil {
|
err = state.SetActor(remAccKey, &types.Actor{
|
||||||
return nil, nil, err
|
Code: builtin.AccountActorCodeID,
|
||||||
|
Balance: remainingFil,
|
||||||
|
Head: emptyobject,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, xerrors.Errorf("set burnt funds account actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return state, keyIDs, nil
|
return state, keyIDs, nil
|
||||||
|
@ -80,5 +80,4 @@ type Template struct {
|
|||||||
Timestamp uint64 `json:",omitempty"`
|
Timestamp uint64 `json:",omitempty"`
|
||||||
|
|
||||||
VerifregRootKey Actor
|
VerifregRootKey Actor
|
||||||
RemainderAccount Actor
|
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ func mockSbBuilder(t *testing.T, nFull int, storage []test.StorageMiner) ([]test
|
|||||||
|
|
||||||
genaccs = append(genaccs, genesis.Actor{
|
genaccs = append(genaccs, genesis.Actor{
|
||||||
Type: genesis.TAccount,
|
Type: genesis.TAccount,
|
||||||
Balance: big.Mul(big.NewInt(400_000_000_000), types.NewInt(build.FilecoinPrecision)),
|
Balance: big.Mul(big.NewInt(400_000_000), types.NewInt(build.FilecoinPrecision)),
|
||||||
Meta: (&genesis.AccountMeta{Owner: wk.Address}).ActorMeta(),
|
Meta: (&genesis.AccountMeta{Owner: wk.Address}).ActorMeta(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user