From 8a8f0ab3eca65d09d50e0980ac3381572eba60a2 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Tue, 8 Sep 2020 13:45:44 -0700 Subject: [PATCH] pass tipset through upgrade logic --- chain/stmgr/forks.go | 10 +++++----- chain/stmgr/forks_test.go | 2 +- chain/stmgr/stmgr.go | 6 +++--- chain/stmgr/utils.go | 2 +- conformance/driver.go | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/chain/stmgr/forks.go b/chain/stmgr/forks.go index 769cae7c07b..addaba90f92 100644 --- a/chain/stmgr/forks.go +++ b/chain/stmgr/forks.go @@ -17,14 +17,14 @@ import ( "golang.org/x/xerrors" ) -var ForksAtHeight = map[abi.ChainEpoch]func(context.Context, *StateManager, types.StateTree) error{ +var ForksAtHeight = map[abi.ChainEpoch]func(context.Context, *StateManager, types.StateTree, *types.TipSet) error{ build.UpgradeBreezeHeight: UpgradeFaucetBurnRecovery, } -func (sm *StateManager) handleStateForks(ctx context.Context, st types.StateTree, height abi.ChainEpoch) (err error) { +func (sm *StateManager) handleStateForks(ctx context.Context, st types.StateTree, height abi.ChainEpoch, ts *types.TipSet) (err error) { f, ok := ForksAtHeight[height] if ok { - err := f(ctx, sm, st) + err := f(ctx, sm, st, ts) if err != nil { return err } @@ -66,7 +66,7 @@ func doTransfer(tree types.StateTree, from, to address.Address, amt abi.TokenAmo return nil } -func UpgradeFaucetBurnRecovery(ctx context.Context, sm *StateManager, tree types.StateTree) error { +func UpgradeFaucetBurnRecovery(ctx context.Context, sm *StateManager, tree types.StateTree, ts *types.TipSet) error { // Some initial parameters FundsForMiners := types.FromFil(1_000_000) LookbackEpoch := abi.ChainEpoch(32000) @@ -91,7 +91,7 @@ func UpgradeFaucetBurnRecovery(ctx context.Context, sm *StateManager, tree types } // Grab lookback state for account checks - lbts, err := sm.ChainStore().GetTipsetByHeight(ctx, LookbackEpoch, nil, false) + lbts, err := sm.ChainStore().GetTipsetByHeight(ctx, LookbackEpoch, ts, false) if err != nil { return xerrors.Errorf("failed to get tipset at lookback height: %w", err) } diff --git a/chain/stmgr/forks_test.go b/chain/stmgr/forks_test.go index 7b7671317c6..b5fb0c60268 100644 --- a/chain/stmgr/forks_test.go +++ b/chain/stmgr/forks_test.go @@ -119,7 +119,7 @@ func TestForkHeightTriggers(t *testing.T) { t.Fatal(err) } - stmgr.ForksAtHeight[testForkHeight] = func(ctx context.Context, sm *StateManager, st types.StateTree) error { + stmgr.ForksAtHeight[testForkHeight] = func(ctx context.Context, sm *StateManager, st types.StateTree, ts *types.TipSet) error { cst := cbor.NewCborStore(sm.ChainStore().Blockstore()) act, err := st.GetActor(taddr) diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index 5679991aef6..929c9daf778 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -147,7 +147,7 @@ func (sm *StateManager) ExecutionTrace(ctx context.Context, ts *types.TipSet) (c type ExecCallback func(cid.Cid, *types.Message, *vm.ApplyRet) error -func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEpoch, pstate cid.Cid, bms []store.BlockMessages, epoch abi.ChainEpoch, r vm.Rand, cb ExecCallback, baseFee abi.TokenAmount) (cid.Cid, cid.Cid, error) { +func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEpoch, pstate cid.Cid, bms []store.BlockMessages, epoch abi.ChainEpoch, r vm.Rand, cb ExecCallback, baseFee abi.TokenAmount, ts *types.TipSet) (cid.Cid, cid.Cid, error) { vmopt := &vm.VMOpts{ StateBase: pstate, @@ -201,7 +201,7 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEp for i := parentEpoch; i < epoch; i++ { // handle state forks - err = sm.handleStateForks(ctx, vmi.StateTree(), i) + err = sm.handleStateForks(ctx, vmi.StateTree(), i, ts) if err != nil { return cid.Undef, cid.Undef, xerrors.Errorf("error handling state forks: %w", err) } @@ -350,7 +350,7 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, ts *types.TipSet baseFee := blks[0].ParentBaseFee - return sm.ApplyBlocks(ctx, parentEpoch, pstate, blkmsgs, blks[0].Height, r, cb, baseFee) + return sm.ApplyBlocks(ctx, parentEpoch, pstate, blkmsgs, blks[0].Height, r, cb, baseFee, ts) } func (sm *StateManager) parentState(ts *types.TipSet) cid.Cid { diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index ab7f4f47231..b21400da688 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -456,7 +456,7 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch, for i := ts.Height(); i < height; i++ { // handle state forks - err = sm.handleStateForks(ctx, vmi.StateTree(), i) + err = sm.handleStateForks(ctx, vmi.StateTree(), i, ts) if err != nil { return cid.Undef, nil, xerrors.Errorf("error handling state forks: %w", err) } diff --git a/conformance/driver.go b/conformance/driver.go index b6a61dac0f9..0cc5844f52e 100644 --- a/conformance/driver.go +++ b/conformance/driver.go @@ -102,7 +102,7 @@ func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, preroot messages = append(messages, msg) results = append(results, ret) return nil - }, tipset.BaseFee) + }, tipset.BaseFee, nil) if err != nil { return nil, err