diff --git a/chain/gen/gen_test.go b/chain/gen/gen_test.go index 7a4d73031..52766af7a 100644 --- a/chain/gen/gen_test.go +++ b/chain/gen/gen_test.go @@ -39,8 +39,8 @@ func testGeneration(t testing.TB, n int, msgs int, sectors int) { } func TestChainGeneration(t *testing.T) { - testGeneration(t, 10, 20, 1) - testGeneration(t, 10, 20, 25) + t.Run("10-20-1", func(t *testing.T) { testGeneration(t, 10, 20, 1) }) + t.Run("10-20-25", func(t *testing.T) { testGeneration(t, 10, 20, 25) }) } func BenchmarkChainGeneration(b *testing.B) { diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index 84ff25a6a..cd3881a27 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -6,6 +6,7 @@ import ( "github.com/filecoin-project/go-amt-ipld/v2" "github.com/filecoin-project/specs-actors/actors/abi" + "github.com/filecoin-project/specs-actors/actors/abi/big" "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin/account" "github.com/filecoin-project/specs-actors/actors/builtin/multisig" @@ -62,6 +63,7 @@ The process: - market.AddFunds with correct value - market.PublishDeals for related sectors - Set network power in the power actor to what we'll have after genesis creation + - Recreate reward actor state with the right power - For each precommitted sector - Get deal weight - Calculate QA Power @@ -139,7 +141,8 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge } // Setup reward - rewact, err := SetupRewardActor(bs) + // RewardActor's state is overrwritten by SetupStorageMiners + rewact, err := SetupRewardActor(bs, big.Zero()) if err != nil { return nil, xerrors.Errorf("setup init actor: %w", err) } diff --git a/chain/gen/genesis/miners.go b/chain/gen/genesis/miners.go index 1897118ef..be2dbbefe 100644 --- a/chain/gen/genesis/miners.go +++ b/chain/gen/genesis/miners.go @@ -198,6 +198,11 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid if err != nil { return cid.Undef, xerrors.Errorf("mutating state: %w", err) } + + err = vm.MutateState(ctx, builtin.RewardActorAddr, func(sct cbor.IpldStore, st *reward.State) error { + st = reward.ConstructState(qaPow) + return nil + }) } for i, m := range miners { diff --git a/chain/gen/genesis/t02_reward.go b/chain/gen/genesis/t02_reward.go index b573726cc..0866f9fa3 100644 --- a/chain/gen/genesis/t02_reward.go +++ b/chain/gen/genesis/t02_reward.go @@ -2,6 +2,7 @@ package genesis import ( "context" + "github.com/filecoin-project/specs-actors/actors/abi/big" "github.com/filecoin-project/lotus/build" @@ -12,12 +13,10 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" ) -func SetupRewardActor(bs bstore.Blockstore) (*types.Actor, error) { +func SetupRewardActor(bs bstore.Blockstore, qaPower big.Int) (*types.Actor, error) { cst := cbor.NewCborStore(bs) - z := big.Zero() - st := reward.ConstructState(z) - st.ThisEpochReward = types.FromFil(100) + st := reward.ConstructState(qaPower) hcid, err := cst.Put(context.TODO(), st) if err != nil {