Make reward actor state in genesis more realistic
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
e1c9c4297b
commit
bb33994219
@ -39,8 +39,8 @@ func testGeneration(t testing.TB, n int, msgs int, sectors int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestChainGeneration(t *testing.T) {
|
func TestChainGeneration(t *testing.T) {
|
||||||
testGeneration(t, 10, 20, 1)
|
t.Run("10-20-1", func(t *testing.T) { testGeneration(t, 10, 20, 1) })
|
||||||
testGeneration(t, 10, 20, 25)
|
t.Run("10-20-25", func(t *testing.T) { testGeneration(t, 10, 20, 25) })
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkChainGeneration(b *testing.B) {
|
func BenchmarkChainGeneration(b *testing.B) {
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-amt-ipld/v2"
|
"github.com/filecoin-project/go-amt-ipld/v2"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"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"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
"github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||||
@ -62,6 +63,7 @@ The process:
|
|||||||
- market.AddFunds with correct value
|
- market.AddFunds with correct value
|
||||||
- market.PublishDeals for related sectors
|
- market.PublishDeals for related sectors
|
||||||
- Set network power in the power actor to what we'll have after genesis creation
|
- 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
|
- For each precommitted sector
|
||||||
- Get deal weight
|
- Get deal weight
|
||||||
- Calculate QA Power
|
- Calculate QA Power
|
||||||
@ -139,7 +141,8 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup reward
|
// Setup reward
|
||||||
rewact, err := SetupRewardActor(bs)
|
// RewardActor's state is overrwritten by SetupStorageMiners
|
||||||
|
rewact, err := SetupRewardActor(bs, big.Zero())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("setup init actor: %w", err)
|
return nil, xerrors.Errorf("setup init actor: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,11 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("mutating state: %w", err)
|
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 {
|
for i, m := range miners {
|
||||||
|
@ -2,6 +2,7 @@ package genesis
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@ -12,12 +13,10 @@ import (
|
|||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
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)
|
cst := cbor.NewCborStore(bs)
|
||||||
|
|
||||||
z := big.Zero()
|
st := reward.ConstructState(qaPower)
|
||||||
st := reward.ConstructState(z)
|
|
||||||
st.ThisEpochReward = types.FromFil(100)
|
|
||||||
|
|
||||||
hcid, err := cst.Put(context.TODO(), st)
|
hcid, err := cst.Put(context.TODO(), st)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user