Skip to content

Commit

Permalink
Merge pull request paradigmxyz#20 from taikoxyz/brought_over_latest_t…
Browse files Browse the repository at this point in the history
…aiko_mono

feat(gwyneth): update everything (except core protocol) to latest taiko-mono
  • Loading branch information
adaki2004 authored Jul 15, 2024
2 parents 5ac4a0b + 19461a0 commit 6f2b50e
Show file tree
Hide file tree
Showing 105 changed files with 8,537 additions and 9,601 deletions.
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 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.
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

0 comments on commit 6f2b50e

Please sign in to comment.