Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of getRemoteGatewayLatestProvenBlockNumber #304

Closed
wants to merge 8 commits into from
13 changes: 13 additions & 0 deletions contracts/consensus-gateway/ConsensusCogateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
13 changes: 13 additions & 0 deletions contracts/consensus-gateway/ConsensusGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
13 changes: 13 additions & 0 deletions contracts/erc20-gateway/ERC20Cogateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions contracts/erc20-gateway/ERC20Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
7 changes: 7 additions & 0 deletions test/consensus_cogateway/prove_consensus_gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
});
});
});
7 changes: 7 additions & 0 deletions test/erc20_gateway/erc20_cogateway/prove_gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
});
});
});
7 changes: 7 additions & 0 deletions test/erc20_gateway/erc20_gateway/prove_gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
});
});
});