Skip to content

Commit

Permalink
fix(protocol): fix liveness bond related tokenomics issue (#16684)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Apr 8, 2024
1 parent 2b27477 commit 2c63cb0
Show file tree
Hide file tree
Showing 19 changed files with 2,195 additions and 360 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ library TaikoData {
uint96 contestBond;
uint64 timestamp; // slot 6 (90 bits)
uint16 tier;
uint8 contestations;
uint8 __reserved1;
}

/// @dev Struct containing data required for verifying a block.
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/TaikoErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pragma solidity 0.8.24;
abstract contract TaikoErrors {
error L1_ALREADY_CONTESTED();
error L1_ALREADY_PROVED();
error L1_ASSIGNED_PROVER_NOT_ALLOWED();
error L1_BLOB_NOT_AVAILABLE();
error L1_BLOB_NOT_FOUND();
error L1_BLOCK_MISMATCH();
error L1_CANNOT_CONTEST();
error L1_INVALID_BLOCK_ID();
error L1_INVALID_CONFIG();
error L1_INVALID_GENESIS_HASH();
Expand Down
6 changes: 1 addition & 5 deletions packages/protocol/contracts/L1/TaikoEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,17 @@ abstract contract TaikoEvents {
);
/// @dev Emitted when a block is verified.
/// @param blockId The ID of the verified block.
/// @param assignedProver The block's assigned prover.
/// @param prover The prover whose transition is used for verifying the
/// block.
/// @param blockHash The hash of the verified block.
/// @param stateRoot The block's state root.
/// @param tier The tier ID of the proof.
/// @param contestations Number of total contestations.
event BlockVerified(
uint256 indexed blockId,
address indexed assignedProver,
address indexed prover,
bytes32 blockHash,
bytes32 stateRoot,
uint16 tier,
uint8 contestations
uint16 tier
);

/// @notice Emitted when some state variable values changed.
Expand Down
29 changes: 17 additions & 12 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,8 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {
/// @notice Gets the details of a block.
/// @param _blockId Index of the block.
/// @return blk_ The block.
/// @return ts_ The transition used to verify this block.
function getBlock(uint64 _blockId)
public
view
returns (TaikoData.Block memory blk_, TaikoData.TransitionState memory ts_)
{
uint64 slot;
(blk_, slot) = LibUtils.getBlock(state, getConfig(), _blockId);

if (blk_.verifiedTransitionId != 0) {
ts_ = state.transitions[slot][blk_.verifiedTransitionId];
}
function getBlock(uint64 _blockId) public view returns (TaikoData.Block memory blk_) {
(blk_,) = LibUtils.getBlock(state, getConfig(), _blockId);
}

/// @notice Gets the state transition for a specific block.
Expand All @@ -167,10 +157,25 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {
return LibUtils.getTransition(state, getConfig(), _blockId, _parentHash);
}

/// @notice Gets the state transition for a specific block.
/// @param _blockId Index of the block.
/// @param _tid The transition id.
/// @return The state transition data of the block.
function getTransition(
uint64 _blockId,
uint32 _tid
)
public
view
returns (TaikoData.TransitionState memory)
{
return LibUtils.getTransition(state, getConfig(), _blockId, _tid);
}
/// @notice Gets the state variables of the TaikoL1 contract.
/// @dev This method can be deleted once node/client stops using it.
/// @return State variables stored at SlotA.
/// @return State variables stored at SlotB.

function getStateVariables()
public
view
Expand Down
Loading

0 comments on commit 2c63cb0

Please sign in to comment.