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): reserve slots for upgradability & add bond events #14657

Merged
merged 5 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 7 additions & 3 deletions packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,18 @@ library TaikoData {
}

/// @dev Struct representing state transition data.
/// 4 slots.
/// 10 slots reserved for upgradability, 4 slots used.
struct Transition {
bytes32 key; //only written/read for the 1st state transition.
bytes32 blockHash;
bytes32 signalRoot;
address prover;
uint64 provenAt;
bytes32[6] __reserved;
}

/// @dev Struct containing data required for verifying a block.
/// 3 slots.
/// 10 slots reserved for upgradability, 3 slots used.
struct Block {
bytes32 metaHash; // slot 1
address prover; // slot 2
Expand All @@ -147,15 +148,18 @@ library TaikoData {
uint64 proposedAt;
uint32 nextTransitionId;
uint32 verifiedTransitionId;
bytes32[7] __reserved;
}

/// @dev Struct representing information about a transaction list.
/// 1 slot used.
struct TxListInfo {
uint64 validSince;
uint24 size;
}

/// @dev Struct representing an Ethereum deposit.
/// 1 slot used.
struct EthDeposit {
address recipient;
uint96 amount;
Expand Down Expand Up @@ -203,6 +207,6 @@ library TaikoData {
mapping(address account => uint256 balance) taikoTokenBalances;
SlotA slotA; // slot 7
SlotB slotB; // slot 8
uint256[42] __gap;
uint256[142] __gap;
}
}
7 changes: 3 additions & 4 deletions packages/protocol/contracts/L1/libs/LibDepositing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ pragma solidity ^0.8.20;
import { AddressResolver } from "../../common/AddressResolver.sol";
import { LibAddress } from "../../libs/LibAddress.sol";
import { LibMath } from "../../libs/LibMath.sol";
import { SafeCastUpgradeable } from
"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import { TaikoData } from "../TaikoData.sol";

/// @title LibDepositing
/// @notice A library for handling Ether deposits in the Taiko protocol.
library LibDepositing {
using LibAddress for address;
using LibMath for uint256;
using SafeCastUpgradeable for uint256;

event EthDeposited(TaikoData.EthDeposit deposit);

Expand Down Expand Up @@ -51,12 +48,14 @@ library LibDepositing {
address _recipient = recipient == address(0) ? msg.sender : recipient;
uint256 slot =
state.slotA.numEthDeposits % config.ethDepositRingBufferSize;

// range of msg.value is checked by next line.
state.ethDeposits[slot] = _encodeEthDeposit(_recipient, msg.value);

emit EthDeposited(
TaikoData.EthDeposit({
recipient: _recipient,
amount: msg.value.toUint96(),
amount: uint96(msg.value),
id: state.slotA.numEthDeposits
})
);
Expand Down
5 changes: 1 addition & 4 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { ICrossChainSync } from "../common/ICrossChainSync.sol";
import { Lib1559Math } from "../libs/Lib1559Math.sol";
import { LibMath } from "../libs/LibMath.sol";
import { Proxied } from "../common/Proxied.sol";
import { SafeCastUpgradeable } from
"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import { TaikoL2Signer } from "./TaikoL2Signer.sol";

/// @title TaikoL2
Expand All @@ -22,7 +20,6 @@ import { TaikoL2Signer } from "./TaikoL2Signer.sol";
/// communication, manage EIP-1559 parameters for gas pricing, and store
/// verified L1 block information.
contract TaikoL2 is EssentialContract, TaikoL2Signer, ICrossChainSync {
using SafeCastUpgradeable for uint256;
using LibMath for uint256;

struct VerifiedBlock {
Expand Down Expand Up @@ -59,7 +56,7 @@ contract TaikoL2 is EssentialContract, TaikoL2Signer, ICrossChainSync {
uint64 public gasExcess;
uint64 private __reserved1;

uint256[45] private __gap;
uint256[145] private __gap;

// Captures all block variables mentioned in
// https://docs.soliditylang.org/en/v0.8.20/units-and-global-variables.html
Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/DeployOnL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../contracts/L1/TaikoToken.sol";
import "../contracts/L1/TaikoL1.sol";
import "../contracts/L1/ProofVerifier.sol";
Expand All @@ -24,8 +23,6 @@ import "../contracts/test/erc20/FreeMintERC20.sol";
import "../contracts/test/erc20/MayFailFreeMintERC20.sol";

contract DeployOnL1 is Script {
using SafeCastUpgradeable for uint256;

bytes32 public genesisHash = vm.envBytes32("L2_GENESIS_HASH");

uint256 public deployerPrivateKey = vm.envUint("PRIVATE_KEY");
Expand Down
1 change: 0 additions & 1 deletion packages/protocol/script/upgrade/SetAddressManager.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "./UpgradeScript.s.sol";

interface IEssentialContract {
Expand Down
1 change: 0 additions & 1 deletion packages/protocol/script/upgrade/TransferOwnership.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "./UpgradeScript.s.sol";

interface IOwnable {
Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/upgrade/UpgradeAddressManager.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/common/AddressManager.sol";
import "./UpgradeScript.s.sol";

Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/upgrade/UpgradeBridge.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/bridge/Bridge.sol";
import "./UpgradeScript.s.sol";

Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/upgrade/UpgradeERC1155Vault.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/tokenvault/ERC1155Vault.sol";
import "./UpgradeScript.s.sol";

Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/upgrade/UpgradeERC20Vault.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/tokenvault/ERC20Vault.sol";
import "./UpgradeScript.s.sol";

Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/upgrade/UpgradeERC721Vault.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/tokenvault/ERC721Vault.sol";
import "./UpgradeScript.s.sol";

Expand Down
1 change: 0 additions & 1 deletion packages/protocol/script/upgrade/UpgradeScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";

contract UpgradeScript is Script {
uint256 public deployerPrivateKey = vm.envUint("PRIVATE_KEY");
Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/upgrade/UpgradeSignalService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/signal/SignalService.sol";
import "./UpgradeScript.s.sol";

Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/upgrade/UpgradeTaikoL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/L1/TaikoL1.sol";
import "./UpgradeScript.s.sol";

Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/upgrade/UpgradeTaikoL2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/L2/TaikoL2.sol";
import "./UpgradeScript.s.sol";

Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/upgrade/UpgradeTaikoToken.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "../../contracts/L1/TaikoToken.sol";
import "./UpgradeScript.s.sol";

Expand Down