diff --git a/bolt-contracts/src/contracts/BoltChallenger.sol b/bolt-contracts/src/contracts/BoltChallenger.sol index 8bac9bb4f..fe77a2f89 100644 --- a/bolt-contracts/src/contracts/BoltChallenger.sol +++ b/bolt-contracts/src/contracts/BoltChallenger.sol @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.25; +import {console} from "forge-std/Test.sol"; + import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; @@ -126,6 +128,11 @@ contract BoltChallenger is IBoltChallenger { (address txSender, address commitmentSigner, TransactionData memory firstTransactionData) = _recoverCommitmentData(commitments[0]); + console.log("first"); + console.log(txSender); + console.log(commitmentSigner); + console.logBytes32(firstTransactionData.txHash); + transactionsData[0] = firstTransactionData; for (uint256 i = 1; i < commitments.length; i++) { @@ -134,6 +141,11 @@ contract BoltChallenger is IBoltChallenger { transactionsData[i] = otherTransactionData; + console.log("other"); + console.log(otherTxSender); + console.log(otherCommitmentSigner); + console.logBytes32(otherTransactionData.txHash); + // check that all commitments are for the same slot if (commitments[i].slot != targetSlot) { revert UnexpectedMixedSlots(); diff --git a/bolt-contracts/test/BoltChallenger.t.sol b/bolt-contracts/test/BoltChallenger.t.sol index 9ea074e39..0d759a412 100644 --- a/bolt-contracts/test/BoltChallenger.t.sol +++ b/bolt-contracts/test/BoltChallenger.t.sol @@ -355,6 +355,10 @@ contract BoltChallengerTest is Test { // Prove the full defense of a challenge: the block headers, account proof, and tx proofs // are all valid and the proposer has included the transaction in their slot. // This time, the proposer has committed to multiple transactions in their slot. + // + // The test data for this test was generated by querying for an Ethereum block with a + // sender that has sent multiple transactions in the same block. + // Check out https://etherscan.io/block/20817618 uint256 inclusionBlockNumber = 20_817_618; IBoltChallenger.SignedCommitment[] memory commitments = new IBoltChallenger.SignedCommitment[](3); @@ -362,6 +366,18 @@ contract BoltChallengerTest is Test { commitments[1] = _createRecentBoltCommitment(inclusionBlockNumber, 2); commitments[2] = _createRecentBoltCommitment(inclusionBlockNumber, 3); + // Sanity check senders of the transactions: they should all be the same + for (uint256 i = 0; i < commitments.length; i++) { + address recovered = commitments[i].signedTx.decodeEnveloped().recoverSender(); + assertEq(recovered, 0xc21fb45Eeb45D883B838E30ABBd2896aE5AC888c); + } + + // Sanity check signers of the commitments: they should all be the same + for (uint256 i = 0; i < commitments.length; i++) { + address signer = ECDSA.recover(_computeCommitmentID(commitments[i].signedTx, commitments[i].slot), commitments[i].signature); + assertEq(signer, target); + } + // Open a challenge vm.prank(challenger); boltChallenger.openChallenge{value: 1 ether}(commitments); @@ -436,6 +452,9 @@ contract BoltChallengerTest is Test { (uint8 v, bytes32 r, bytes32 s) = vm.sign(targetPK, commitmentID); commitment.signature = abi.encodePacked(r, s, v); + // Sanity check + assertEq(ECDSA.recover(commitmentID, commitment.signature), target); + return commitment; }