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

Slightly improve code related to revert in PreconfTaskManager.sol #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 9 additions & 6 deletions SmartContracts/src/avs/PreconfTaskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ contract PreconfTaskManager is IPreconfTaskManager, Initializable {
//
if (block.timestamp <= lookaheadEntry.prevTimestamp || block.timestamp > lookaheadEntry.timestamp) {
revert InvalidLookaheadPointer();
} else if (msg.sender != lookaheadEntry.preconfer) {
}
if (msg.sender != lookaheadEntry.preconfer) {
revert SenderIsNotThePreconfer();
}

Expand Down Expand Up @@ -135,10 +136,13 @@ contract PreconfTaskManager is IPreconfTaskManager, Initializable {
if (block.timestamp - taikoBlock.proposedAt >= PreconfConstants.DISPUTE_PERIOD) {
// Revert if the dispute window has been missed
revert MissedDisputeWindow();
} else if (header.chainId != block.chainid) {
}
if (header.chainId != block.chainid) {
// Revert if the preconfirmation was provided on another chain
revert PreconfirmationChainIdMismatch();
} else if (keccak256(abi.encode(taikoBlockMetadata)) != taikoBlock.metaHash) {
}

if (keccak256(abi.encode(taikoBlockMetadata)) != taikoBlock.metaHash) {
// Revert if the metadata of the block does not match the one stored in Taiko
revert MetadataMismatch();
}
Expand All @@ -148,13 +152,12 @@ contract PreconfTaskManager is IPreconfTaskManager, Initializable {

// Slash if the preconfirmation was given offchain, but block proposal was missed OR
// the preconfirmed set of transactions is different from the transactions in the proposed block.
if (preconfSigner != proposer || header.txListHash != taikoBlockMetadata.blobHash) {
preconfServiceManager.slashOperator(preconfSigner);
} else {
if (preconfSigner == proposer && header.txListHash == taikoBlockMetadata.blobHash) {
revert PreconfirmationIsCorrect();
}

emit ProvedIncorrectPreconfirmation(proposer, blockId, msg.sender);
preconfServiceManager.slashOperator(preconfSigner);
Copy link
Contributor Author

@dantaik dantaik Oct 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call out to another contract at the end will save some gas.

}

/**
Expand Down