Skip to content

Commit

Permalink
Ensure commitPrevRandao called after submitInitial
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeddes committed Dec 22, 2023
1 parent 09af5e4 commit cdd9224
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/src/BeefyClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
5 changes: 5 additions & 0 deletions contracts/test/BeefyClient.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cdd9224

Please sign in to comment.