Skip to content

Commit

Permalink
yarn format
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJeremyHe committed Mar 7, 2024
1 parent e21c06d commit e16b1c4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/osp/OneStepProofEntry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ contract OneStepProofEntry is IOneStepProofEntry {
} else if (
(opcode >= Instructions.GET_GLOBAL_STATE_BYTES32 &&
opcode <= Instructions.SET_GLOBAL_STATE_U64) ||
(opcode >= Instructions.READ_PRE_IMAGE && opcode <= Instructions.HALT_AND_SET_FINISHED) ||
(opcode >= Instructions.READ_PRE_IMAGE &&
opcode <= Instructions.HALT_AND_SET_FINISHED) ||
(opcode == Instructions.READ_HOTSHOT_COMMITMENT)
) {
prover = proverHostIo;
Expand Down
15 changes: 6 additions & 9 deletions src/osp/OneStepProverHostIo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface IHotShot {
function commitments(uint256) external view returns (uint256);
}


contract OneStepProverHostIo is IOneStepProver {
using GlobalStateLib for GlobalState;
using MerkleProofLib for MerkleProof;
Expand Down Expand Up @@ -335,16 +334,12 @@ contract OneStepProverHostIo is IOneStepProver {
proofOffset
);

bytes calldata commitment = proof[proofOffset:proofOffset+32];
bytes calldata commitment = proof[proofOffset:proofOffset + 32];
bool success = validateHotShotCommitment(execCtx, height, commitment);
require(success, "ERROR_HOTSHOT_COMMITMENT");

for (uint32 i = 0; i < 32; i++) {
leafContents = setLeafByte(
leafContents,
i,
uint8(proof[proofOffset + i])
);
leafContents = setLeafByte(leafContents, i, uint8(proof[proofOffset + i]));
}

mod.moduleMemory.merkleRoot = merkleProof.computeRootFromMemory(leafIdx, leafContents);
Expand All @@ -358,13 +353,15 @@ contract OneStepProverHostIo is IOneStepProver {
uint256 expected = hotshot.commitments(height);
require(expected != 0, "EMPTY HOTSHOT COMMITMENT");
bytes memory b = new bytes(32);
assembly { mstore(add(b, 32), expected) }
assembly {
mstore(add(b, 32), expected)
}

if (commitment.length != 32) {
return false;
}

for (uint i = 0; i < b.length; i++) {
for (uint256 i = 0; i < b.length; i++) {
if (b[i] != commitment[i]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test-helpers/HotShot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ contract MockHotShot {
function setCommitment(uint256 height, uint256 commitment) external {
commitments[height] = commitment;
}
}
}
2 changes: 1 addition & 1 deletion test/foundry/RollupCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract RollupCreatorTest is Test {
rollupCreator = new RollupCreator();
deployHelper = new DeployHelper();

for (uint i = 1; i < 10; i++) {
for (uint256 i = 1; i < 10; i++) {
hotshot.setCommitment(uint256(i), uint256(i));
}

Expand Down

0 comments on commit e16b1c4

Please sign in to comment.