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

fix(protocol): hash taiko address with assignment #15120

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ library LibProposing {

function hashAssignment(
TaikoData.ProverAssignment memory assignment,
address taikoAddress,
bytes32 blobHash
)
internal
Expand All @@ -215,6 +216,7 @@ library LibProposing {
return keccak256(
abi.encode(
"PROVER_ASSIGNMENT",
taikoAddress,
blobHash,
assignment.feeToken,
assignment.expiry,
Expand Down Expand Up @@ -242,7 +244,7 @@ library LibProposing {

// Hash the assignment with the blobHash, this hash will be signed by
// the prover, therefore, we add a string as a prefix.
bytes32 hash = hashAssignment(assignment, blobHash);
bytes32 hash = hashAssignment(assignment, address(this), blobHash);

if (!assignment.prover.isValidSignature(hash, assignment.signature)) {
revert L1_ASSIGNMENT_INVALID_SIG();
Expand Down
6 changes: 4 additions & 2 deletions packages/protocol/test/L1/TaikoL1TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ abstract contract TaikoL1TestBase is TestBase {
bytes memory txList = new bytes(txListSize);

assignment.signature =
_signAssignment(prover, assignment, keccak256(txList));
_signAssignment(prover, assignment, address(L1), keccak256(txList));

(, TaikoData.SlotB memory b) = L1.getStateVariables();

Expand Down Expand Up @@ -307,13 +307,15 @@ abstract contract TaikoL1TestBase is TestBase {
function _signAssignment(
address signer,
TaikoData.ProverAssignment memory assignment,
address taikoAddr,
bytes32 blobHash
)
internal
view
returns (bytes memory signature)
{
bytes32 digest = LibProposing.hashAssignment(assignment, blobHash);
bytes32 digest =
LibProposing.hashAssignment(assignment, taikoAddr, blobHash);
uint256 signerPrivateKey;

// In the test suite these are the 3 which acts as provers
Expand Down