Skip to content

Commit

Permalink
Commit parent finality only if finality height is greater (#607)
Browse files Browse the repository at this point in the history
Co-authored-by: Denis Kolegov <dnkolegov@gmail.com>
  • Loading branch information
cryptoAtwill and dnkolegov authored Jan 23, 2024
1 parent 8960bad commit 4ed1c9b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/src/lib/LibGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ library LibGateway {
GatewayActorStorage storage s = LibGatewayActorStorage.appStorage();

uint256 lastHeight = s.latestParentHeight;
if (lastHeight > finality.height) {
if (lastHeight >= finality.height) {
revert ParentFinalityAlreadyCommitted();
}
lastFinality = s.finalitiesMap[lastHeight];
Expand Down
3 changes: 3 additions & 0 deletions contracts/test/integration/GatewayDiamond.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,9 @@ contract GatewayActorDiamondTest is Test, IntegrationTestBase {
weights[1] = 150;

vm.startPrank(FilAddress.SYSTEM_ACTOR);
// increase the block number so that current block number is
// not the same as init committed parent finality height
vm.roll(10);

ParentFinality memory finality = ParentFinality({height: block.number, blockHash: bytes32(0)});

Expand Down
6 changes: 6 additions & 0 deletions contracts/test/integration/GatewayDiamondToken.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ contract GatewayDiamondTokenTest is Test, IntegrationTestBase {
saLouper = DiamondLoupeFacet(address(saDiamond));
saCutter = DiamondCutFacet(address(saDiamond));

// increment the block number by 5 (could be other number as well) so that commit
// parent finality called down stream will work we need this because in setUp,
// parent finality is committed at the block height, without
// incrementing the block number, test won't pass
vm.roll(5);

addValidator(TOPDOWN_VALIDATOR_1, 100);

(address validatorAddress, bytes memory publicKey) = TestUtils.deriveValidatorAddress(100);
Expand Down

0 comments on commit 4ed1c9b

Please sign in to comment.