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"
|
||||
@ -32,8 +33,9 @@ func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Versi
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
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"
|
||||
|
||||
@ -181,8 +182,9 @@ func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, i
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
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"
|
||||
@ -31,8 +32,9 @@ func SetupCronActor(ctx context.Context, bs bstore.Blockstore, av actors.Version
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
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"
|
||||
@ -33,8 +34,9 @@ func SetupStoragePowerActor(ctx context.Context, bs bstore.Blockstore, av actors
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
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"
|
||||
@ -31,8 +32,9 @@ func SetupStorageMarketActor(ctx context.Context, bs bstore.Blockstore, av actor
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
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"
|
||||
@ -46,8 +47,9 @@ func SetupVerifiedRegistryActor(ctx context.Context, bs bstore.Blockstore, av ac
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
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