fix(genesis): set initial balances to 0
This commit is contained in:
parent
b30b5dd629
commit
eb0a15faf0
@ -3,6 +3,7 @@ package genesis
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/system"
|
||||
@ -34,6 +35,7 @@ func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Versi
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
Balance: big.Zero(),
|
||||
}
|
||||
|
||||
return act, nil
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
|
||||
@ -183,6 +184,7 @@ func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, i
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
Balance: big.Zero(),
|
||||
}
|
||||
|
||||
return counter, act, keyToId, nil
|
||||
|
@ -3,6 +3,7 @@ package genesis
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/cron"
|
||||
@ -33,6 +34,7 @@ func SetupCronActor(ctx context.Context, bs bstore.Blockstore, av actors.Version
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
Balance: big.Zero(),
|
||||
}
|
||||
|
||||
return act, nil
|
||||
|
@ -3,6 +3,7 @@ package genesis
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
@ -35,6 +36,7 @@ func SetupStoragePowerActor(ctx context.Context, bs bstore.Blockstore, av actors
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
Balance: big.Zero(),
|
||||
}
|
||||
|
||||
return act, nil
|
||||
|
@ -3,6 +3,7 @@ package genesis
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||
@ -33,6 +34,7 @@ func SetupStorageMarketActor(ctx context.Context, bs bstore.Blockstore, av actor
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
Balance: big.Zero(),
|
||||
}
|
||||
|
||||
return act, nil
|
||||
|
@ -3,6 +3,7 @@ package genesis
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
@ -48,6 +49,7 @@ func SetupVerifiedRegistryActor(ctx context.Context, bs bstore.Blockstore, av ac
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
Balance: big.Zero(),
|
||||
}
|
||||
|
||||
return act, nil
|
||||
|
@ -313,11 +313,10 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
||||
|
||||
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 {
|
||||
if act.Balance.Nil() {
|
||||
panic(fmt.Sprintf("actor %s (%s) has nil balance", addr, builtin.ActorNameByCode(act.Code)))
|
||||
}
|
||||
totalFilAllocated = big.Add(totalFilAllocated, act.Balance)
|
||||
return nil
|
||||
})
|
||||
|
@ -515,7 +515,8 @@ func (st *StateTree) ForEach(f func(address.Address, *types.Actor) error) error
|
||||
if op.Delete {
|
||||
continue
|
||||
}
|
||||
if err := f(addr, &op.Act); err != nil {
|
||||
act := op.Act // copy
|
||||
if err := f(addr, &act); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user