Skip to content

Commit

Permalink
feat(protocol): improve TransitionProved event to include previous …
Browse files Browse the repository at this point in the history
…prover and contester (#16967)
  • Loading branch information
dantaik authored May 3, 2024
1 parent b51b1c5 commit 4b4a502
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
6 changes: 5 additions & 1 deletion packages/protocol/contracts/L1/TaikoEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ abstract contract TaikoEvents {
/// @dev Emitted when a block transition is proved or re-proved.
/// @param blockId The ID of the proven block.
/// @param tran The verified transition.
/// @param prevProver The previous prover address.
/// @param prevContester The previous contester address.
/// @param prover The prover address.
/// @param validityBond The validity bond amount.
/// @param tier The tier ID of the proof.
event TransitionProved(
uint256 indexed blockId,
TaikoData.Transition tran,
address prover,
address indexed prevProver,
address prevContester,
address indexed prover,
uint96 validityBond,
uint16 tier
);
Expand Down
38 changes: 23 additions & 15 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,20 @@ library LibProving {
}

// Warning: Any events defined here must also be defined in TaikoEvents.sol.
/// @notice Emitted when a transition is proved.
/// @param blockId The block ID.
/// @param tran The transition data.
/// @param prover The prover's address.
/// @dev Emitted when a block transition is proved or re-proved.
/// @param blockId The ID of the proven block.
/// @param tran The verified transition.
/// @param prevProver The previous prover address.
/// @param prevContester The previous contester address.
/// @param prover The prover address.
/// @param validityBond The validity bond amount.
/// @param tier The tier of the proof.
/// @param tier The tier ID of the proof.
event TransitionProved(
uint256 indexed blockId,
TaikoData.Transition tran,
address prover,
address indexed prevProver,
address prevContester,
address indexed prover,
uint96 validityBond,
uint16 tier
);
Expand Down Expand Up @@ -223,18 +227,20 @@ library LibProving {
local.sameTransition = _tran.blockHash == ts.blockHash && _tran.stateRoot == ts.stateRoot;

if (_proof.tier > ts.tier) {
// Handles the case when an incoming tier is higher than the current transition's tier.
// Reverts when the incoming proof tries to prove the same transition
// (L1_ALREADY_PROVED).
_overrideWithHigherProof(blk, ts, _tran, _proof, local, tko);

emit TransitionProved({
blockId: local.blockId,
tran: _tran,
prevProver: ts.prover,
prevContester: ts.contester,
prover: msg.sender,
validityBond: local.tier.validityBond,
tier: _proof.tier
});

// Handles the case when an incoming tier is higher than the current transition's tier.
// Reverts when the incoming proof tries to prove the same transition
// (L1_ALREADY_PROVED).
_overrideWithHigherProof(blk, ts, _tran, _proof, local, tko);
} else {
// New transition and old transition on the same tier - and if this transaction tries to
// prove the same, it reverts
Expand All @@ -245,17 +251,19 @@ library LibProving {
assert(local.tier.validityBond == 0);
assert(ts.validityBond == 0 && ts.contester == address(0));

ts.prover = msg.sender;
ts.blockHash = _tran.blockHash;
ts.stateRoot = _tran.stateRoot;

emit TransitionProved({
blockId: local.blockId,
tran: _tran,
prevProver: ts.prover,
prevContester: ts.contester,
prover: msg.sender,
validityBond: 0,
tier: _proof.tier
});

ts.prover = msg.sender;
ts.blockHash = _tran.blockHash;
ts.stateRoot = _tran.stateRoot;
} else {
// Contesting but not on the highest tier
if (ts.contester != address(0)) revert L1_ALREADY_CONTESTED();
Expand Down

0 comments on commit 4b4a502

Please sign in to comment.