From 260109478b374ef7b11347931b86ffbc49ad6a87 Mon Sep 17 00:00:00 2001 From: Galaxy <30950645+GalaxySciTech@users.noreply.github.com> Date: Fri, 7 Jun 2024 09:14:14 +0400 Subject: [PATCH] fix the epoch number error (#44) fix the epoch number error --- contracts/FullCheckpoint.sol | 9 ++++++++- contracts/ReverseFullCheckpoint.sol | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/contracts/FullCheckpoint.sol b/contracts/FullCheckpoint.sol index d5fa856..5b4fcb2 100644 --- a/contracts/FullCheckpoint.sol +++ b/contracts/FullCheckpoint.sol @@ -81,7 +81,13 @@ contract FullCheckpoint { }); currentValidators = validators[1]; } else { - require(next.length > 0, "No Gap Validator Empty"); + require( + next.length > 0 && + uint64(uint256(gsbn % int256(uint256(initEpoch)))) == + initEpoch - initGap + 1, + "No Gap Block" + ); + validators[gapBlock.number] = Validators({ set: next, threshold: int256((initialValidatorSet.length * certThreshold)) @@ -90,6 +96,7 @@ contract FullCheckpoint { set: initialValidatorSet, threshold: int256((initialValidatorSet.length * certThreshold)) }); + epochNum = uint64(int64(gapBlock.number)) / initEpoch; } headerTree[gapHeaderHash] = Header({ diff --git a/contracts/ReverseFullCheckpoint.sol b/contracts/ReverseFullCheckpoint.sol index 8e12ba7..4cdf856 100644 --- a/contracts/ReverseFullCheckpoint.sol +++ b/contracts/ReverseFullCheckpoint.sol @@ -64,7 +64,7 @@ contract ReverseFullCheckpoint { address[] memory next = HeaderReader.getEpoch(v2esbnHeader); - require(next.length > 0, "No Epoch Validator Empty"); + require(next.length > 0, "No Epoch Block"); HeaderReader.ValidationParams memory v2esbnBlock = HeaderReader .getValidationParams(v2esbnHeader);