Merge pull request #9547 from filecoin-project/asr/invariants-fix
shed: include invariant checks as part of migration testing
This commit is contained in:
commit
154fb3a727
@ -18,6 +18,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/builtin"
|
||||
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
|
||||
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
|
||||
v9 "github.com/filecoin-project/go-state-types/builtin/v9"
|
||||
market9 "github.com/filecoin-project/go-state-types/builtin/v9/market"
|
||||
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
|
||||
@ -216,25 +217,25 @@ func checkMigrationInvariants(ctx context.Context, v8StateRoot cid.Cid, v9StateR
|
||||
}
|
||||
|
||||
// Load the state root.
|
||||
//var stateRoot types.StateRoot
|
||||
//if err := actorStore.Get(ctx, v9StateRoot, &stateRoot); err != nil {
|
||||
// return xerrors.Errorf("failed to decode state root: %w", err)
|
||||
//}
|
||||
//
|
||||
//actorCodeCids, err := actors.GetActorCodeIDs(actorstypes.Version9)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//
|
||||
//actorTree, err := builtin.LoadTree(actorStore, stateRoot.Actors)
|
||||
//messages, err := v9.CheckStateInvariants(actorTree, epoch, actorCodeCids)
|
||||
//if err != nil {
|
||||
// return xerrors.Errorf("checking state invariants: %w", err)
|
||||
//}
|
||||
//
|
||||
//for _, message := range messages.Messages() {
|
||||
// fmt.Println("got the following error: ", message)
|
||||
//}
|
||||
var stateRoot types.StateRoot
|
||||
if err := actorStore.Get(ctx, v9StateRoot, &stateRoot); err != nil {
|
||||
return xerrors.Errorf("failed to decode state root: %w", err)
|
||||
}
|
||||
|
||||
actorCodeCids, err := actors.GetActorCodeIDs(actorstypes.Version9)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
actorTree, err := builtin.LoadTree(actorStore, stateRoot.Actors)
|
||||
messages, err := v9.CheckStateInvariants(actorTree, epoch, actorCodeCids)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("checking state invariants: %w", err)
|
||||
}
|
||||
|
||||
for _, message := range messages.Messages() {
|
||||
fmt.Println("got the following error: ", message)
|
||||
}
|
||||
|
||||
fmt.Println("completed invariant checks, took ", time.Since(startTime))
|
||||
|
||||
@ -252,7 +253,8 @@ func checkDatacaps(stateTreeV8 *state.StateTree, stateTreeV9 *state.StateTree, a
|
||||
return err
|
||||
}
|
||||
|
||||
if len(verifregDatacaps) != len(newDatacaps) {
|
||||
// Should have all the v8 datacaps, plus the verifreg actor itself
|
||||
if len(verifregDatacaps)+1 != len(newDatacaps) {
|
||||
return xerrors.Errorf("size of datacap maps do not match. verifreg: %d, datacap: %d", len(verifregDatacaps), len(newDatacaps))
|
||||
}
|
||||
|
||||
@ -341,6 +343,12 @@ func checkPendingVerifiedDeals(stateTreeV8 *state.StateTree, stateTreeV9 *state.
|
||||
return xerrors.Errorf("failed to get proposals: %w", err)
|
||||
}
|
||||
|
||||
// We only want those pending deals that haven't been activated -- an activated deal has an entry in dealStates8
|
||||
dealStates8, err := adt9.AsArray(actorStore, marketStateV8.States, market8.StatesAmtBitwidth)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to load v8 states array: %w", err)
|
||||
}
|
||||
|
||||
var numPendingVerifiedDeals = 0
|
||||
var proposal market8.DealProposal
|
||||
err = dealProposalsV8.ForEach(&proposal, func(dealID int64) error {
|
||||
@ -364,6 +372,17 @@ func checkPendingVerifiedDeals(stateTreeV8 *state.StateTree, stateTreeV9 *state.
|
||||
return nil
|
||||
}
|
||||
|
||||
var _dealState8 market8.DealState
|
||||
found, err := dealStates8.Get(uint64(dealID), &_dealState8)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to lookup deal state: %w", err)
|
||||
}
|
||||
|
||||
// the deal has an entry in deal states, which means it's already been allocated, nothing to do
|
||||
if found {
|
||||
return nil
|
||||
}
|
||||
|
||||
numPendingVerifiedDeals++
|
||||
// Checks if allocation ID is in market map
|
||||
allocationId, err := marketActorV9.GetAllocationIdForPendingDeal(abi.DealID(dealID))
|
||||
|
Loading…
Reference in New Issue
Block a user