From 8c101cd9618a19101165daa30b70abe5eb458f97 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Wed, 8 Oct 2025 13:21:33 +0800 Subject: [PATCH] engine_v2: fix potential modulo by zero, close XFN-17 (#1615) --- consensus/XDPoS/engines/engine_v2/utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/consensus/XDPoS/engines/engine_v2/utils.go b/consensus/XDPoS/engines/engine_v2/utils.go index 56f828f3f3..47d304dbae 100644 --- a/consensus/XDPoS/engines/engine_v2/utils.go +++ b/consensus/XDPoS/engines/engine_v2/utils.go @@ -175,6 +175,9 @@ func (x *XDPoS_v2) CalculateMissingRounds(chain consensus.ChainReader, header *t return nil, err } masternodes := switchInfo.Masternodes + if len(masternodes) == 0 { + return nil, fmt.Errorf("masternodes is empty in CalculateMissingRounds, number = %v, hash %#x", header.Number, header.Hash()) + } // Loop through from the epoch switch block to the current "header" block nextHeader := header