Skip to content

Commit

Permalink
Do not call node.GetChains() if node is nil
Browse files Browse the repository at this point in the history
In `NewSessionNodes`, the variable `node` can be `nil` if the node
is unstaked between `sessionCtx` and `ctx`.  In such a case,
`node.GetChains()` causes a panic.  This patch makes sure we don't
call it if the `node` is `nil`.
This is a regression from #1582.
  • Loading branch information
msmania committed Dec 21, 2023
1 parent 4a17b6f commit 5f376c6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions x/pocketcore/types/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,9 @@ func NewSessionNodes(

// cross check the node from the `new` or `end` world state
node = keeper.Validator(ctx, n)
lenNodeChains := int64(len(node.GetChains()))
// if not found or jailed or is overstaked to chains
if node == nil ||
(isEnforceMaxChains && lenNodeChains > nodeMaxChains) ||
(isEnforceMaxChains && int64(len(node.GetChains())) > nodeMaxChains) ||
node.IsJailed() ||
!NodeHasChain(chain, node) ||
sessionNodes.Contains(node.GetAddress()) {
Expand Down

0 comments on commit 5f376c6

Please sign in to comment.