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

feat(protocol): add parentGasUsed to blockproven #13704

Merged
merged 9 commits into from
May 5, 2023
3 changes: 2 additions & 1 deletion packages/protocol/contracts/L1/TaikoEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ abstract contract TaikoEvents {
bytes32 parentHash,
bytes32 blockHash,
bytes32 signalRoot,
address prover
address prover,
uint32 parentGasUsed
davidtaikocha marked this conversation as resolved.
Show resolved Hide resolved
);

event BlockVerified(uint256 indexed id, bytes32 blockHash);
Expand Down
4 changes: 4 additions & 0 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,8 @@ contract TaikoL1 is
function getVerifierName(uint16 id) public pure returns (bytes32) {
return LibUtils.getVerifierName(id);
}

function getOracleProver() public view returns (address) {
dantaik marked this conversation as resolved.
Show resolved Hide resolved
return AddressResolver(this).resolve("oracle_prover", true);
}
}
14 changes: 7 additions & 7 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ library LibProving {
bytes32 parentHash,
bytes32 blockHash,
bytes32 signalRoot,
address prover
address prover,
uint32 parentGasUsed
);

error L1_ALREADY_PROVEN();
Expand Down Expand Up @@ -59,9 +60,7 @@ library LibProving {
if (blk.metaHash != evidence.metaHash)
revert L1_EVIDENCE_MISMATCH(blk.metaHash, evidence.metaHash);

bool isOracleProof = evidence.prover == address(0);

if (isOracleProof) {
if (evidence.prover == address(0)) {
address oracleProver = resolver.resolve("oracle_prover", true);
if (oracleProver == address(0)) revert L1_ORACLE_DISABLED();

Expand Down Expand Up @@ -129,7 +128,7 @@ library LibProving {
evidence.parentGasUsed
] = fcId;
}
} else if (isOracleProof) {
} else if (evidence.prover == address(0)) {
fc = blk.forkChoices[fcId];

if (
Expand All @@ -147,7 +146,7 @@ library LibProving {
fc.provenAt = uint64(block.timestamp);
fc.prover = evidence.prover;

if (!isOracleProof) {
if (evidence.prover != address(0)) {
bytes32 instance;

// Set state.staticRefs
Expand Down Expand Up @@ -199,7 +198,8 @@ library LibProving {
parentHash: evidence.parentHash,
blockHash: evidence.blockHash,
signalRoot: evidence.signalRoot,
prover: evidence.prover
prover: evidence.prover,
parentGasUsed: evidence.parentGasUsed
});
}

Expand Down