Skip to content
Draft
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
7 changes: 5 additions & 2 deletions deploy/OneStepProverHostIoCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ module.exports = async hre => {

await deploy('OneStepProverHostIo', {
from: deployer,
args: [ethers.constants.AddressZero],
args: [
ethers.constants.AddressZero,
(await deployments.get('HashProofHelper')).address,
],
})
}

module.exports.tags = ['OneStepProverHostIo']
module.exports.dependencies = []
module.exports.dependencies = ['HashProofHelper']
38 changes: 22 additions & 16 deletions src/osp/OneStepProofEntry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,28 @@ contract OneStepProofEntry is IOneStepProofEntry {
(globalState, offset) = Deserialize.globalState(proof, offset);
require(globalState.hash() == mach.globalStateHash, "BAD_GLOBAL_STATE");

MELState memory melState;
(melState, offset) = Deserialize.melState(proof, offset);
require(melState.hash() == globalState.getMELStateHash(), "BAD_MEL_STATE");

// The machine has finished processing a message and we're at the start of the next execution segment (machineStep == 0).
// If the MELState is not at its target (meaning that it hasn't finished extracting messages, which should only happen before the extraction process is started),
// or if all messages were extracted, but there are still messages to be executed in MEL, we kickstart the machine.
if (
mach.status == MachineStatus.FINISHED && machineStep == 0
&& (
melState.parentChainBlockHash != execCtx.targetParentChainBlockHash
|| globalState.getMELExecutedMsgCount() < melState.msgCount
)
) {
// Kickstart the machine
return getStartMachineHash(mach.globalStateHash, execCtx.initialWasmModuleRoot);
// Only MEL-enhanced proofs carry a MELState. For non-MEL halted
// machines (MELStateHash == 0) the prover serializes the global
// state and reads no further, so we must not attempt to read a
// MELState here either.
if (globalState.getMELStateHash() != bytes32(0)) {
MELState memory melState;
(melState, offset) = Deserialize.melState(proof, offset);
require(melState.hash() == globalState.getMELStateHash(), "BAD_MEL_STATE");

// The machine has finished processing a message and we're at the start of the next execution segment (machineStep == 0).
// If the MELState is not at its target (meaning that it hasn't finished extracting messages, which should only happen before the extraction process is started),
// or if all messages were extracted, but there are still messages to be executed in MEL, we kickstart the machine.
if (
mach.status == MachineStatus.FINISHED && machineStep == 0
&& (
melState.parentChainBlockHash != execCtx.targetParentChainBlockHash
|| globalState.getMELExecutedMsgCount() < melState.msgCount
)
) {
// Kickstart the machine
return getStartMachineHash(mach.globalStateHash, execCtx.initialWasmModuleRoot);
}
}
return mach.hash();
}
Expand Down
9 changes: 1 addition & 8 deletions test/prover/one-step-proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ describe('OneStepProof', function () {
await deployments.get('OneStepProofEntry')
).address
)
const bridge = await ethers.getContractAt(
'BridgeStub',
(
await deployments.get('BridgeStub')
).address
)

const promises = []
const isdone = []
Expand All @@ -89,10 +83,9 @@ describe('OneStepProof', function () {
)
const proof = proofs[i]
isdone.push(false)
const inboxLimit = 1000000
const promise = osp
.proveOneStep(
[inboxLimit, bridge.address],
[ethers.constants.HashZero, ethers.constants.HashZero],
i,
[...Buffer.from(proof.before, 'hex')],
[...Buffer.from(proof.proof, 'hex')]
Expand Down
Loading