From fdc76405fcb2183d6eee52e4d56984e108dd2d50 Mon Sep 17 00:00:00 2001 From: Dimo99 Date: Tue, 20 Aug 2024 17:30:12 +0300 Subject: [PATCH] fix: DendrETHAdapter compile errors --- .../adapters/DendrETH/DendrETHAdapter.sol | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/evm/contracts/adapters/DendrETH/DendrETHAdapter.sol b/packages/evm/contracts/adapters/DendrETH/DendrETHAdapter.sol index c093ca8c..5a44c80a 100644 --- a/packages/evm/contracts/adapters/DendrETH/DendrETHAdapter.sol +++ b/packages/evm/contracts/adapters/DendrETH/DendrETHAdapter.sol @@ -32,6 +32,18 @@ contract DendrETHAdapter is BlockHashAdapter { bytes32 _blockHash, bytes32[] calldata _blockHashProof ) external { + if (!SSZ.verifySlot(_slot, _slotProof, _finalizedBlockHeader)) { + revert InvalidSlot(); + } + + if (!SSZ.verifyBlockNumber(_blockNumber, _blockNumberProof, _finalizedBlockHeader)) { + revert InvalidBlockNumberProof(); + } + + if (!SSZ.verifyBlockHash(_blockHash, _blockHashProof, _finalizedBlockHeader)) { + revert InvalidBlockHashProof(); + } + ILightClient lightClient = ILightClient(DENDRETH); uint256 currentIndex = lightClient.currentIndex(); @@ -50,22 +62,10 @@ contract DendrETHAdapter is BlockHashAdapter { } while (i != currentIndex); if (!found) { - revert BlockHeaderNotAvailable(slot); - } - - if (!SSZ.verifySlot(_slot, _slotProof, _finalizedBlockHeader)) { - revert InvalidSlot(); - } - - if (!SSZ.verifyBlockNumber(_blockNumber, _blockNumberProof, _finalizedBlockHeader)) { - revert InvalidBlockNumberProof(); - } - - if (!SSZ.verifyBlockHash(_blockHash, _blockHashProof, _finalizedBlockHeader)) { - revert InvalidBlockHashProof(); + revert BlockHeaderNotAvailable(_slot); } - _storeHash(SOURCE_CHAIN_ID, blockNumber, blockHash); + _storeHash(SOURCE_CHAIN_ID, _blockNumber, _blockHash); } /// @notice Updates DendrETH Light client and stores the given block @@ -82,8 +82,6 @@ contract DendrETHAdapter is BlockHashAdapter { ) external { ILightClient lightClient = ILightClient(DENDRETH); - lightClient.light_client_update(update); - bytes32 finalizedHeaderRoot = lightClient.finalizedHeaderRoot(); if (!SSZ.verifySlot(_slot, _slotProof, finalizedHeaderRoot)) { @@ -98,6 +96,8 @@ contract DendrETHAdapter is BlockHashAdapter { revert InvalidBlockHashProof(); } - _storeHash(SOURCE_CHAIN_ID, blockNumber, blockHash); + lightClient.light_client_update(update); + + _storeHash(SOURCE_CHAIN_ID, _blockNumber, _blockHash); } }