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

feat(gwyneth): add reth-based private network , and L1 contract deployment #19

Merged
merged 9 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions packages/protocol/.env_sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
L2_GENESIS_HASH=0xdf90a9c4daa571aa308e967c9a6b4bf21ba8842d95d73d28be112b6fe0618e8c
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
MAINNET_CONTRACT_OWNER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 #It shall belong to the PK above. I got this example ADDR-PK from local anvil.
10 changes: 5 additions & 5 deletions packages/protocol/contracts/L1/BasedOperator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ contract BasedOperator is EssentialContract, TaikoErrors {

mapping(uint256 => Block) public blocks;

function init(address _addressManager) external initializer {
function init(address _owner, address _addressManager) external initializer {
if (_addressManager == address(0)) {
revert L1_INVALID_ADDRESS();
}
__Essential_init(_addressManager);
__Essential_init(_owner, _addressManager);
}

/// @dev Proposes a Taiko L2 block.
Expand Down Expand Up @@ -119,8 +119,8 @@ contract BasedOperator is EssentialContract, TaikoErrors {
require(verifierRegistry.isVerifier(address(verifier)), "invalid verifier");
// Verify the proof
verifier.verifyProof(
proofBatch.blockMetadata,
proofBatch.transition,
keccak256(abi.encode(proofBatch.blockMetadata)),
proofBatch.prover,
proofBatch.proofs[i].proof
);
Expand Down Expand Up @@ -185,9 +185,9 @@ contract BasedOperator is EssentialContract, TaikoErrors {
uint256 bondToReturn = blk.bond;
if (prover != blk.assignedProver) {
bondToReturn >>= 1;
treasury.sendEther(bondToReturn, MAX_GAS_PROVER_PAYMENT);
treasury.sendEtherAndVerify(bondToReturn, MAX_GAS_PROVER_PAYMENT);
}
prover.sendEther(bondToReturn, MAX_GAS_PROVER_PAYMENT);
prover.sendEtherAndVerify(bondToReturn, MAX_GAS_PROVER_PAYMENT);
}
}

Expand Down
53 changes: 53 additions & 0 deletions packages/protocol/contracts/L1/ITaikoL1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

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.
function proposeBlock(
bytes calldata _params,
bytes calldata _txList
)
external
payable
returns (TaikoData.BlockMetadata memory meta_);

/// @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,
/// TaikoData.TierProof) tuple.
function proveBlock(uint64 _blockId, bytes calldata _input) external;

/// @notice Verifies up to a certain number of blocks.
/// @param _maxBlocksToVerify Max number of blocks to verify.
function verifyBlocks(uint64 _maxBlocksToVerify) external;

/// @notice Pause block proving.
/// @param _pause True if paused.
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 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);
}
17 changes: 13 additions & 4 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ contract TaikoL1 is EssentialContract, TaikoEvents, TaikoErrors {
/// @notice Initializes the rollup.
/// @param _addressManager The {AddressManager} address.
/// @param _genesisBlockHash The block hash of the genesis block.
function init(address _addressManager, bytes32 _genesisBlockHash) external initializer {
__Essential_init(_addressManager);
function init(
address _owner,
address _addressManager,
bytes32 _genesisBlockHash
)
external
initializer
{
__Essential_init(_owner, _addressManager);

TaikoData.Config memory config = getConfig();
require(isConfigValid(config), "invalid config");
Expand Down Expand Up @@ -57,8 +64,10 @@ contract TaikoL1 is EssentialContract, TaikoEvents, TaikoErrors {
payable
nonReentrant
whenNotPaused
onlyFromNamed("operator")
returns (TaikoData.BlockMetadata memory _block)
returns (
//onlyFromNamed("operator")
TaikoData.BlockMetadata memory _block
)
{
TaikoData.Config memory config = getConfig();

Expand Down
131 changes: 0 additions & 131 deletions packages/protocol/contracts/L1/TaikoToken.sol

This file was deleted.

7 changes: 4 additions & 3 deletions packages/protocol/contracts/L1/VerifierBattleRoyale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ contract VerifierBattleRoyale is EssentialContract {
/// @dev Struct representing transition to be proven.
struct ProofData {
IVerifier verifier;
TaikoData.Transition transition;
TaikoData.Transition transition; // This differs from BasedOperator ! Mainly because of
// transition comparison for the battle!!
bytes proof;
}

struct ProofBatch {
TaikoData.BlockMetadata _block;
TaikoData.BlockMetadata blockMetadata;
ProofData[] proofs;
address prover;
}
Expand Down Expand Up @@ -67,8 +68,8 @@ contract VerifierBattleRoyale is EssentialContract {
IVerifier verifier = proofBatch.proofs[i].verifier;
require(verifierRegistry.isVerifier(address(verifier)), "invalid verifier");
verifier.verifyProof(
proofBatch._block,
proofBatch.proofs[i].transition,
keccak256(abi.encode(proofBatch.blockMetadata)),
proofBatch.prover,
proofBatch.proofs[i].proof
);
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/actors/PBSActor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ contract PBSActor {
require(keccak256(abi.encode(_block)) == parentHash, "unexpected parent");

// Do conditional payment
address(block.coinbase).sendEther(tip);
address(block.coinbase).sendEtherAndVerify(tip);
}
}
4 changes: 2 additions & 2 deletions packages/protocol/contracts/L1/actors/ProverPayment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract ProverPayment {
);

// Pay the prover
assignment.prover.sendEther(msg.value, MAX_GAS_PAYING_PROVER);
assignment.prover.sendEtherAndVerify(msg.value, MAX_GAS_PAYING_PROVER);
}

function hashAssignment(ProverAssignment memory assignment) internal view returns (bytes32) {
Expand All @@ -93,6 +93,6 @@ contract ProverPayment {
// TODO(Brecht): delay
function witdraw(address from, address to, uint256 amount) external {
balances[from] -= amount;
to.sendEther(amount);
to.sendEtherAndVerify(amount);
}
}
Loading
Loading