diff --git a/contracts/src/BeefyClient.sol b/contracts/src/BeefyClient.sol index 72cd3f0fd2..bf40943a1a 100644 --- a/contracts/src/BeefyClient.sol +++ b/contracts/src/BeefyClient.sol @@ -299,6 +299,10 @@ contract BeefyClient { bytes32 ticketID = createTicketID(msg.sender, commitmentHash); Ticket storage ticket = tickets[ticketID]; + if (ticket.blockNumber == 0) { + revert InvalidTicket(); + } + if (ticket.prevRandao != 0) { revert PrevRandaoAlreadyCaptured(); } diff --git a/contracts/test/BeefyClient.t.sol b/contracts/test/BeefyClient.t.sol index eeb039ee28..8f74d10607 100644 --- a/contracts/test/BeefyClient.t.sol +++ b/contracts/test/BeefyClient.t.sol @@ -437,6 +437,11 @@ contract BeefyClientTest is Test { assertEq(beefyClient.getValidatorCounter(true, finalValidatorProofs[1].index), 0); } + function testCommitPrevRandaoCalledInSequence() public { + vm.expectRevert(BeefyClient.InvalidTicket.selector); + commitPrevRandao(); + } + function testSubmitWithHandoverAnd3SignatureCount() public { //initialize with previous set BeefyClient.Commitment memory commitment = initialize(setId - 1);