Skip to content

Commit

Permalink
go/registry: Fix node stake claim sanity check with suspended runtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Mar 25, 2022
1 parent bd5fd7e commit f6b38e4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions .changelog/4603.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/registry: Fix node stake claim sanity check with suspended runtimes
2 changes: 1 addition & 1 deletion go/consensus/tendermint/apps/supplementarysanity/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,5 @@ func checkStakeClaims(ctx *abciAPI.Context, now beacon.EpochTime) error {
}
}

return registry.SanityCheckStake(entities, accounts, nodes, runtimes, stakingParams.Thresholds, false)
return registry.SanityCheckStake(entities, accounts, nodes, runtimes, runtimes, stakingParams.Thresholds, false)
}
3 changes: 2 additions & 1 deletion go/genesis/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,9 @@ func TestGenesisSanityCheck(t *testing.T) {
// Enable stake claims check.
d.Registry.Parameters.DebugBypassStake = false
// Setup registry state.
d.Registry.Entities = []*entity.SignedEntity{signedTestEntity}
d.Registry.Entities = []*entity.SignedEntity{signedEntityWithTestNode}
d.Registry.Runtimes = []*registry.Runtime{testKMRuntime, testRuntime}
d.Registry.Nodes = []*node.MultiSignedNode{signedComputeTestNode}
// Setup ledger.
d.Staking.Ledger[testEntityAddress] = &staking.Account{
Escrow: staking.EscrowAccount{
Expand Down
5 changes: 3 additions & 2 deletions go/registry/api/sanity_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (g *Genesis) SanityCheck(
return fmt.Errorf("registry: sanity check failed: could not obtain runtimes from runtimesLookup: %w", err)
}
// Check stake.
return SanityCheckStake(entities, stakeLedger, nodes, runtimes, stakeThresholds, true)
return SanityCheckStake(entities, stakeLedger, nodes, runtimes, allRuntimes, stakeThresholds, true)
}

return nil
Expand Down Expand Up @@ -221,6 +221,7 @@ func SanityCheckStake(
accounts map[staking.Address]*staking.Account,
nodes []*node.Node,
runtimes []*Runtime,
allRuntimes []*Runtime,
stakeThresholds map[staking.ThresholdKind]quantity.Quantity,
isGenesis bool,
) error {
Expand Down Expand Up @@ -254,7 +255,7 @@ func SanityCheckStake(
// Also generate escrow accounts for all runtimes that are using the
// runtime governance model.
runtimeMap := make(map[common.Namespace]*Runtime)
for _, rt := range runtimes {
for _, rt := range allRuntimes {
runtimeMap[rt.ID] = rt

if rt.GovernanceModel == GovernanceRuntime {
Expand Down

0 comments on commit f6b38e4

Please sign in to comment.