Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/registry: Fix node stake claim sanity check with suspended runtimes #4603

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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