-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(protocol): remove unused code post Ontake fork (#18150)
Co-authored-by: dantaik <[email protected]> Co-authored-by: gavin <[email protected]> Co-authored-by: David <[email protected]> Co-authored-by: Bernat Canal Garceran <[email protected]> Co-authored-by: taiko-bot <[email protected]> Co-authored-by: Roger <[email protected]> Co-authored-by: maskpp <[email protected]> Co-authored-by: smtmfft <[email protected]> Co-authored-by: Ivan Lagunovsky <[email protected]> Co-authored-by: jeff <[email protected]> Co-authored-by: Karim <[email protected]> Co-authored-by: Karim <[email protected]> Co-authored-by: YoGhurt111 <[email protected]>
- Loading branch information
1 parent
ea0158f
commit 8543cec
Showing
117 changed files
with
7,575 additions
and
7,644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
node_modules/ | ||
lib/ | ||
contracts/layer1/automata-attestation/ | ||
contracts/layer1/preconf/avs-mvp/ | ||
contracts/layer1/preconf/libs/LibBLS12381.sol | ||
test/shared/thirdparty/ |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,6 @@ import "./TaikoData.sol"; | |
/// @title ITaikoL1 | ||
/// @custom:security-contact [email protected] | ||
interface ITaikoL1 { | ||
/// @notice Proposes a Taiko L2 block. | ||
/// @param _params Block parameters, currently an encoded BlockParams object. | ||
/// @param _txList txList data if calldata is used for DA. | ||
/// @return meta_ The metadata of the proposed L2 block. | ||
/// @return deposits_ The Ether deposits processed. | ||
function proposeBlock( | ||
bytes calldata _params, | ||
bytes calldata _txList | ||
) | ||
external | ||
payable | ||
returns (TaikoData.BlockMetadata memory meta_, TaikoData.EthDeposit[] memory deposits_); | ||
|
||
/// @notice Proposes a Taiko L2 block (version 2) | ||
/// @param _params Block parameters, an encoded BlockParamsV2 object. | ||
/// @param _txList txList data if calldata is used for DA. | ||
|
@@ -42,9 +29,9 @@ interface ITaikoL1 { | |
returns (TaikoData.BlockMetadataV2[] memory metaArr_); | ||
|
||
/// @notice Proves or contests a block transition. | ||
/// @param _blockId The index of the block to prove. This is also used to | ||
/// select the right implementation version. | ||
/// @param _input An abi-encoded (TaikoData.BlockMetadata, TaikoData.Transition, | ||
/// @param _blockId Index of the block to prove. This is also used to select the right | ||
/// implementation version. | ||
/// @param _input ABI-encoded (TaikoData.BlockMetadata, TaikoData.Transition, | ||
/// TaikoData.TierProof) tuple. | ||
function proveBlock(uint64 _blockId, bytes calldata _input) external; | ||
|
||
|
@@ -61,14 +48,27 @@ interface ITaikoL1 { | |
) | ||
external; | ||
|
||
/// @notice Verifies up to a certain number of blocks. | ||
/// @param _maxBlocksToVerify Max number of blocks to verify. | ||
/// @notice Verifies up to a specified number of blocks. | ||
/// @param _maxBlocksToVerify Maximum number of blocks to verify. | ||
function verifyBlocks(uint64 _maxBlocksToVerify) external; | ||
|
||
/// @notice Pause block proving. | ||
/// @param _pause True if paused. | ||
/// @notice Pauses or unpauses block proving. | ||
/// @param _pause True to pause, false to unpause. | ||
function pauseProving(bool _pause) external; | ||
|
||
/// @notice Deposits Taiko token to be used as bonds. | ||
/// @param _amount The amount of Taiko token to deposit. | ||
function depositBond(uint256 _amount) external; | ||
|
||
/// @notice Withdraws Taiko tokens. | ||
/// @param _amount Amount of Taiko tokens to withdraw. | ||
function withdrawBond(uint256 _amount) external; | ||
|
||
/// @notice Gets the prover that actually proved a verified block. | ||
/// @param _blockId Index of the block. | ||
/// @return The prover's address. If the block is not verified yet, address(0) will be returned. | ||
function getVerifiedBlockProver(uint64 _blockId) external view returns (address); | ||
|
||
/// @notice Gets the details of a block. | ||
/// @param _blockId Index of the block. | ||
/// @return blk_ The block. | ||
|
@@ -77,7 +77,8 @@ interface ITaikoL1 { | |
/// @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. | ||
/// @return The state transition data of the block. The transition's state root will be zero if | ||
/// the block is not a sync-block. | ||
function getTransition( | ||
uint64 _blockId, | ||
uint32 _tid | ||
|
@@ -86,19 +87,6 @@ interface ITaikoL1 { | |
view | ||
returns (TaikoData.TransitionState memory); | ||
|
||
/// @notice Deposits Taiko token to be used as bonds. | ||
/// @param _amount The amount of Taiko token to deposit. | ||
function depositBond(uint256 _amount) external; | ||
|
||
/// @notice Withdraws Taiko token. | ||
/// @param _amount The amount of Taiko token to withdraw. | ||
function withdrawBond(uint256 _amount) external; | ||
|
||
/// @notice Gets the prover that actually proved a verified block. | ||
/// @param _blockId The index of the block. | ||
/// @return The prover's address. If the block is not verified yet, address(0) will be returned. | ||
function getVerifiedBlockProver(uint64 _blockId) external view returns (address); | ||
|
||
/// @notice Gets the configuration of the TaikoL1 contract. | ||
/// @return Config struct containing configuration parameters. | ||
function getConfig() external pure returns (TaikoData.Config memory); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,91 +11,127 @@ import "./TaikoData.sol"; | |
/// @notice A library that offers helper functions to handle bonds. | ||
/// @custom:security-contact [email protected] | ||
library LibBonds { | ||
/// @dev Emitted when token is credited back to a user's bond balance. | ||
event BondCredited(address indexed user, uint256 amount); | ||
/// @dev Emitted when tokens are deposited into a user's bond balance. | ||
/// @param user The address of the user who deposited the tokens. | ||
/// @param amount The amount of tokens deposited. | ||
event BondDeposited(address indexed user, uint256 amount); | ||
|
||
/// @dev Emitted when token is debited from a user's bond balance. | ||
event BondDebited(address indexed user, uint256 amount); | ||
/// @dev Emitted when tokens are withdrawn from a user's bond balance. | ||
/// @param user The address of the user who withdrew the tokens. | ||
/// @param amount The amount of tokens withdrawn. | ||
event BondWithdrawn(address indexed user, uint256 amount); | ||
|
||
/// @dev Deposits Taiko token to be used as bonds. | ||
/// @param _state Current TaikoData.State. | ||
/// @param _resolver Address resolver interface. | ||
/// @param _amount The amount of token to deposit. | ||
/// @dev Emitted when a token is credited back to a user's bond balance. | ||
/// @param user The address of the user whose bond balance is credited. | ||
/// @param blockId The ID of the block to credit for. | ||
/// @param amount The amount of tokens credited. | ||
event BondCredited(address indexed user, uint256 blockId, uint256 amount); | ||
|
||
/// @dev Emitted when a token is debited from a user's bond balance. | ||
/// @param user The address of the user whose bond balance is debited. | ||
/// @param blockId The ID of the block to debit for. | ||
/// @param amount The amount of tokens debited. | ||
event BondDebited(address indexed user, uint256 blockId, uint256 amount); | ||
|
||
/// @dev Deposits TAIKO tokens to be used as bonds. | ||
/// @param _state The current state of TaikoData. | ||
/// @param _resolver The address resolver interface. | ||
/// @param _amount The amount of tokens to deposit. | ||
function depositBond( | ||
TaikoData.State storage _state, | ||
IAddressResolver _resolver, | ||
uint256 _amount | ||
) | ||
internal | ||
public | ||
{ | ||
emit BondDeposited(msg.sender, _amount); | ||
_state.bondBalance[msg.sender] += _amount; | ||
_tko(_resolver).transferFrom(msg.sender, address(this), _amount); | ||
} | ||
|
||
/// @dev Withdraws Taiko token. | ||
/// @param _state Current TaikoData.State. | ||
/// @param _resolver Address resolver interface. | ||
/// @param _amount The amount of token to withdraw. | ||
/// @dev Withdraws TAIKO tokens. | ||
/// @param _state The current state of TaikoData. | ||
/// @param _resolver The address resolver interface. | ||
/// @param _amount The amount of tokens to withdraw. | ||
function withdrawBond( | ||
TaikoData.State storage _state, | ||
IAddressResolver _resolver, | ||
uint256 _amount | ||
) | ||
internal | ||
public | ||
{ | ||
emit BondWithdrawn(msg.sender, _amount); | ||
_state.bondBalance[msg.sender] -= _amount; | ||
_tko(_resolver).transfer(msg.sender, _amount); | ||
} | ||
|
||
/// @dev Debits Taiko tokens as bonds. | ||
/// @param _state Current TaikoData.State. | ||
/// @param _resolver Address resolver interface. | ||
/// @param _user The user address to debit. | ||
/// @param _amount The amount of token to debit. | ||
/// @dev Gets a user's current TAIKO token bond balance. | ||
/// @param _state The current state of TaikoData. | ||
/// @param _user The address of the user. | ||
/// @return The current token balance. | ||
function bondBalanceOf( | ||
TaikoData.State storage _state, | ||
address _user | ||
) | ||
public | ||
view | ||
returns (uint256) | ||
{ | ||
return _state.bondBalance[_user]; | ||
} | ||
|
||
/// @dev Debits TAIKO tokens as bonds. | ||
/// @param _state The current state of TaikoData. | ||
/// @param _resolver The address resolver interface. | ||
/// @param _user The address of the user to debit. | ||
/// @param _blockId The ID of the block to debit for. | ||
/// @param _amount The amount of tokens to debit. | ||
function debitBond( | ||
TaikoData.State storage _state, | ||
IAddressResolver _resolver, | ||
address _user, | ||
uint256 _blockId, | ||
uint256 _amount | ||
) | ||
internal | ||
{ | ||
uint256 balance = _state.bondBalance[_user]; | ||
if (_amount == 0) return; | ||
|
||
uint256 balance = _state.bondBalance[_user]; | ||
if (balance >= _amount) { | ||
unchecked { | ||
_state.bondBalance[_user] = balance - _amount; | ||
} | ||
emit BondDebited(_user, _amount); | ||
} else { | ||
emit BondDeposited(msg.sender, _amount); | ||
_tko(_resolver).transferFrom(_user, address(this), _amount); | ||
} | ||
emit BondDebited(_user, _blockId, _amount); | ||
} | ||
|
||
/// @dev Credits Taiko tokens to user's bond balance. | ||
/// @param _state Current TaikoData.State. | ||
/// @param _user The user address to credit. | ||
/// @param _amount The amount of token to credit. | ||
function creditBond(TaikoData.State storage _state, address _user, uint256 _amount) internal { | ||
_state.bondBalance[_user] += _amount; | ||
emit BondCredited(_user, _amount); | ||
} | ||
|
||
/// @dev Gets a user's current Taiko token bond balance. | ||
/// @param _state Current TaikoData.State. | ||
/// @param _user The user address to credit. | ||
/// @return The current token balance. | ||
function bondBalanceOf( | ||
/// @dev Credits TAIKO tokens to a user's bond balance. | ||
/// @param _state The current state of TaikoData. | ||
/// @param _user The address of the user to credit. | ||
/// @param _blockId The ID of the block to credit for. | ||
/// @param _amount The amount of tokens to credit. | ||
function creditBond( | ||
TaikoData.State storage _state, | ||
address _user | ||
address _user, | ||
uint256 _blockId, | ||
uint256 _amount | ||
) | ||
internal | ||
view | ||
returns (uint256) | ||
{ | ||
return _state.bondBalance[_user]; | ||
if (_amount == 0) return; | ||
unchecked { | ||
_state.bondBalance[_user] += _amount; | ||
} | ||
emit BondCredited(_user, _blockId, _amount); | ||
} | ||
|
||
/// @dev Resolves the TAIKO token address using the address resolver. | ||
/// @param _resolver The address resolver interface. | ||
/// @return tko_ The IERC20 interface of the TAIKO token. | ||
function _tko(IAddressResolver _resolver) private view returns (IERC20) { | ||
return IERC20(_resolver.resolve(LibStrings.B_TAIKO_TOKEN, false)); | ||
} | ||
|
Oops, something went wrong.