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

refactor(protocol): remove unused code post Ontake fork #18150

Merged
merged 67 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
ce76e66
refactor(protocol): remove unused code post Ontake fork (#18072)
dantaik Sep 20, 2024
1f4b014
Merge branch 'main' into ontake_cleanup2
dantaik Sep 22, 2024
671dd42
Merge branch 'main' into ontake_cleanup2
dantaik Sep 26, 2024
1cf87c9
Merge branch 'main' into ontake_cleanup2
dantaik Sep 28, 2024
4b46a8c
Merge branch 'main' into ontake_cleanup2
dantaik Sep 30, 2024
86852f0
Merge branch 'main' into ontake_cleanup2
dantaik Oct 1, 2024
5e50481
Merge branch 'main' into ontake_cleanup2
dantaik Oct 4, 2024
44e5184
fix(protocol): remove "payable" from ProverSet.sol (#18209)
dantaik Oct 4, 2024
1dcc18a
fix comments
dantaik Oct 10, 2024
db376c8
Update ComposeVerifier.sol
dantaik Oct 10, 2024
93241d5
Merge branch 'main' into ontake_cleanup2
dantaik Oct 11, 2024
8e076c1
Merge branch 'main' into ontake_cleanup2
dantaik Oct 11, 2024
c9982e6
refactor(protocol): extract SgxVerifierBase to be reused (#18231)
dantaik Oct 11, 2024
a77d40a
Merge branch 'main' into ontake_cleanup2
dantaik Oct 16, 2024
7fbfe84
feat(protocol): migrate Nethermind's preconf contracts here (#18234)
dantaik Oct 18, 2024
035acb2
docs(protocol): update Hekla deployments (#18257)
davidtaikocha Oct 17, 2024
e8b1454
docs(taiko-client): update readme how to do integration test (#18256)
YoGhurt111 Oct 17, 2024
6f668e5
docs(protocol): update mainnet deployment (#18258)
davidtaikocha Oct 17, 2024
f91c2b5
chore(docs-site): remove banner (#18267)
RogerLamTd Oct 20, 2024
129960a
chore(main): release docs-site 1.12.3 (#18268)
taiko-kitty Oct 20, 2024
438d139
chore(protocol): rename B_PRECONF_REGISTRY to B_PRECONF_TASK_MANAGER …
dantaik Oct 21, 2024
4c9df8c
Merge branch 'main' into ontake_cleanup2
dantaik Oct 22, 2024
90f014b
fix(protocol): update `slotB.lastUnpausedAt` by both general unpause…
dantaik Oct 22, 2024
3f315ed
Merge branch 'main' into ontake_cleanup2
dantaik Oct 23, 2024
f7ee69f
Merge branch 'main' into ontake_cleanup2
dantaik Oct 25, 2024
9c69c2f
Merge branch 'main' into ontake_cleanup2
dantaik Oct 25, 2024
2bb5bd5
Merge branch 'main' into ontake_cleanup2
dantaik Oct 25, 2024
3f0d15a
code simplification
dantaik Oct 25, 2024
31dc47b
refactor(protocol): apply multiple improvements based on feedback fro…
dantaik Oct 25, 2024
adfbff5
Merge branch 'main' into ontake_cleanup2
dantaik Oct 25, 2024
e2b7ce7
chore(protocol): delete `approve` function from GuardianProver (#18310)
dantaik Oct 25, 2024
0c88472
refactor(protocol): set `blk.proposedIn` in genesis block (#18312)
dantaik Oct 27, 2024
6196eaa
refactor(protocol): simplify some protocol code based on OpenZeppelin…
dantaik Oct 26, 2024
b5daab8
merge
dantaik Oct 27, 2024
63ac08b
Update LibProposing.sol
dantaik Oct 27, 2024
18c0b2f
Merge branch 'main' into ontake_cleanup2
dantaik Oct 27, 2024
61aaa4c
fix initializers
dantaik Oct 27, 2024
39dcdff
Update Multicall3.sol
dantaik Oct 27, 2024
4e07014
Merge branch 'fix_initializers2' into ontake_cleanup2
dantaik Oct 27, 2024
3588f3d
chore(protocol): emit state root as 0 in events for non-sync blocks (…
dantaik Oct 28, 2024
54b4b86
Merge branch 'main' into ontake_cleanup2
dantaik Oct 28, 2024
e6ea55b
docs(protocol): improve Natspec comments (#18320) (#18321)
dantaik Oct 28, 2024
1abde15
Update LibProposing.sol
dantaik Oct 28, 2024
818bbd6
Merge branch 'main' into ontake_cleanup2
dantaik Oct 28, 2024
290a9f9
Update LibProposing.sol
dantaik Oct 28, 2024
eb47f88
fix(protocol): check ontake for height in _proposeBlock (#18329)
dantaik Oct 28, 2024
1df854b
Merge branch 'main' into ontake_cleanup2
dantaik Oct 29, 2024
f71df9e
Merge branch 'main' into ontake_cleanup2
dantaik Oct 29, 2024
576f748
Merge branch 'main' into ontake_cleanup2
dantaik Oct 29, 2024
454d4b6
chore(protocol): use require-statements for readability (#18325)
dantaik Oct 30, 2024
dc29ad2
Merge branch 'main' into ontake_cleanup2
dantaik Oct 30, 2024
6b03929
Update LibData.sol
dantaik Oct 30, 2024
93d7f24
feat(protocol): change devnet `ontakeForkHeight` to `0` after cleanup
davidtaikocha Oct 30, 2024
9aa8295
Merge branch 'main' into ontake_cleanup2
dantaik Oct 30, 2024
6b453ce
restore maxBlocksToVerifyPerProof
dantaik Oct 30, 2024
502d87d
Update TierProviderBase.sol
dantaik Oct 30, 2024
c8599fa
Update LibEIP1559.sol
dantaik Oct 30, 2024
46e3e76
chore(protocol): update base `ontakeForkHeight` to 0 (#18354)
YoGhurt111 Oct 31, 2024
66ad7f6
Merge branch 'main' into ontake_cleanup2
dantaik Oct 31, 2024
d689566
Merge branch 'main' into ontake_cleanup2
dantaik Nov 1, 2024
ee1596b
Merge branch 'main' into ontake_cleanup2
dantaik Nov 1, 2024
693b234
Update LibEIP1559.sol
dantaik Nov 1, 2024
9a3c5ab
correct comments about verifiedAt
dantaik Nov 2, 2024
acaaaaa
Merge branch 'main' into ontake_cleanup2
dantaik Nov 2, 2024
4e43ad3
Merge branch 'main' into ontake_cleanup2
dantaik Nov 2, 2024
749c817
Merge branch 'main' into ontake_cleanup2
dantaik Nov 3, 2024
a76f2cc
change TaikoL1's library function visibility
dantaik Nov 3, 2024
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
2 changes: 2 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ extend-ignore-identifiers-re = [
"bafybeiegdqpwx3he5dvoxqklspdjekjepjcobfaakyficksratn73qbbyy",
"TGE",
"tge",
"preconf",
"preconfer",
"baed",
"Groth",
"groth",
Expand Down
3 changes: 3 additions & 0 deletions packages/protocol/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ broadcast
lcov.info

simulation/out/
test/genesis/data/genesis.json
test/genesis/data/genesis_alloc.json
test/genesis/data/genesis_storage_layout.json

# Serverless directories
.serverless
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"no-inline-assembly": "off",
"not-rely-on-time": "off",
"gas-custom-errors": "off",
"immutable-vars-naming": "off",
"one-contract-per-file": "off"
}
}
2 changes: 2 additions & 0 deletions packages/protocol/.solhintignore
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/
882 changes: 441 additions & 441 deletions packages/protocol/contract_layout_layer1.md

Large diffs are not rendered by default.

374 changes: 187 additions & 187 deletions packages/protocol/contract_layout_layer2.md

Large diffs are not rendered by default.

56 changes: 22 additions & 34 deletions packages/protocol/contracts/layer1/based/ITaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ import "./TaikoData.sol";
/// @title ITaikoL1
/// @custom:security-contact security@taiko.xyz
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.
Expand All @@ -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;

Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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);
Expand Down
114 changes: 75 additions & 39 deletions packages/protocol/contracts/layer1/based/LibBonds.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,91 +11,127 @@ import "./TaikoData.sol";
/// @notice A library that offers helper functions to handle bonds.
/// @custom:security-contact security@taiko.xyz
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));
}
Expand Down
Loading