diff --git a/contracts/consensus-gateway/ConsensusCogateway.sol b/contracts/consensus-gateway/ConsensusCogateway.sol index 710facec..227f6c48 100644 --- a/contracts/consensus-gateway/ConsensusCogateway.sol +++ b/contracts/consensus-gateway/ConsensusCogateway.sol @@ -198,6 +198,19 @@ contract ConsensusCogateway is MasterCopyNonUpgradable, MessageBus, ConsensusGat ); } + /** + * @notice Gets the remote gateway latest proven block number. + * + * @return blockNumber_ Remote gateway latest proven block number. + */ + function getRemoteGatewayLatestProvenBlockNumber() + external + view + returns (uint256 blockNumber_) + { + blockNumber_ = CircularBufferUint.head(); + } + /** * @notice Confirms the initiation of opening a kernel at auxiliary chain. * diff --git a/contracts/consensus-gateway/ConsensusGateway.sol b/contracts/consensus-gateway/ConsensusGateway.sol index 237059d3..4c801514 100644 --- a/contracts/consensus-gateway/ConsensusGateway.sol +++ b/contracts/consensus-gateway/ConsensusGateway.sol @@ -311,4 +311,17 @@ contract ConsensusGateway is "Token transfer to the beneficiary must succeed." ); } + + /** + * @notice Gets the remote gateway latest proven block number. + * + * @return blockNumber_ Remote gateway latest proven block number. + */ + function getRemoteGatewayLatestProvenBlockNumber() + external + view + returns (uint256 blockNumber_) + { + blockNumber_ = CircularBufferUint.head(); + } } diff --git a/contracts/erc20-gateway/ERC20Cogateway.sol b/contracts/erc20-gateway/ERC20Cogateway.sol index 39534353..f6087fb0 100644 --- a/contracts/erc20-gateway/ERC20Cogateway.sol +++ b/contracts/erc20-gateway/ERC20Cogateway.sol @@ -152,6 +152,19 @@ contract ERC20Cogateway is emit GatewayProven(messageInbox, _blockNumber); } + /** + * @notice Gets the remote gateway latest proven block number. + * + * @return blockNumber_ Remote gateway latest proven block number. + */ + function getRemoteGatewayLatestProvenBlockNumber() + external + view + returns (uint256 blockNumber_) + { + blockNumber_ = CircularBufferUint.head(); + } + /** * @notice It allows withdrawing Utility tokens. Withdrawer needs to * approve erc20 cogateway contract for the amount to be diff --git a/contracts/erc20-gateway/ERC20Gateway.sol b/contracts/erc20-gateway/ERC20Gateway.sol index fd3efa8f..c62680d5 100644 --- a/contracts/erc20-gateway/ERC20Gateway.sol +++ b/contracts/erc20-gateway/ERC20Gateway.sol @@ -129,6 +129,19 @@ contract ERC20Gateway is MasterCopyNonUpgradable, MessageBus, ERC20GatewayBase { emit GatewayProven(messageInbox, _blockNumber); } + /** + * @notice Gets the remote gateway latest proven block number. + * + * @return blockNumber_ Remote gateway latest proven block number. + */ + function getRemoteGatewayLatestProvenBlockNumber() + external + view + returns (uint256 blockNumber_) + { + blockNumber_ = CircularBufferUint.head(); + } + /** * @notice Deposit ERC20 token to mint utility token on the auxiliary chain. * diff --git a/test/consensus_cogateway/prove_consensus_gateway.js b/test/consensus_cogateway/prove_consensus_gateway.js index d40b9d4d..be7ce14b 100644 --- a/test/consensus_cogateway/prove_consensus_gateway.js +++ b/test/consensus_cogateway/prove_consensus_gateway.js @@ -79,6 +79,13 @@ contract('CoConsensusgateway::proveConsensusGateway', (accounts) => { ProveConsensusGatewayProof.storageHash, 'Incorrect storage hash', ); + + const latestProvenBlockNumber = await consensusCogateway + .getRemoteGatewayLatestProvenBlockNumber.call(); + assert.isOk( + latestProvenBlockNumber.eqn(ProveConsensusGatewayProof.blockNumber), + 'Invalid latest proven block number.', + ); }); }); }); diff --git a/test/erc20_gateway/erc20_cogateway/prove_gateway.js b/test/erc20_gateway/erc20_cogateway/prove_gateway.js index 5f8c20a9..9bd40e9b 100644 --- a/test/erc20_gateway/erc20_cogateway/prove_gateway.js +++ b/test/erc20_gateway/erc20_cogateway/prove_gateway.js @@ -96,6 +96,13 @@ contract('ERC20Cogateway::proveGateway', (accounts) => { `Expected block number is ${ProveERC20GatewayProof.blockNumber} but found to be ${eventObject.args.blockNumber.toString(10)}.`, ); + + const latestProvenBlockNumber = await erc20Cogateway.getRemoteGatewayLatestProvenBlockNumber + .call(); + assert.isOk( + latestProvenBlockNumber.eqn(ProveERC20GatewayProof.blockNumber), + 'Invalid latest proven block number.', + ); }); }); }); diff --git a/test/erc20_gateway/erc20_gateway/prove_gateway.js b/test/erc20_gateway/erc20_gateway/prove_gateway.js index 3533c076..bb7c752a 100644 --- a/test/erc20_gateway/erc20_gateway/prove_gateway.js +++ b/test/erc20_gateway/erc20_gateway/prove_gateway.js @@ -90,6 +90,13 @@ contract('ERC20Gateway::proveGateway', () => { `Expected block number is ${ProveERC20CogatewayProof.blockNumber} but found to be ${eventObject.args.blockNumber.toString(10)}.`, ); + + const latestProvenBlockNumber = await erc20Gateway.getRemoteGatewayLatestProvenBlockNumber + .call(); + assert.isOk( + latestProvenBlockNumber.eqn(ProveERC20CogatewayProof.blockNumber), + 'Invalid latest proven block number.', + ); }); }); });