Skip to content

Commit

Permalink
Merge branch 'main' into post_ontake_cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Sep 9, 2024
2 parents c0618b6 + bff481e commit c905d1b
Show file tree
Hide file tree
Showing 14 changed files with 997 additions and 2,135 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/protocol/contract_layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
| __paused | uint8 | 201 | 1 | 1 | contracts/L2/TaikoL2.sol:TaikoL2 |
| lastUnpausedAt | uint64 | 201 | 2 | 8 | contracts/L2/TaikoL2.sol:TaikoL2 |
| __gap | uint256[49] | 202 | 0 | 1568 | contracts/L2/TaikoL2.sol:TaikoL2 |
| l2Hashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | contracts/L2/TaikoL2.sol:TaikoL2 |
| _blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | contracts/L2/TaikoL2.sol:TaikoL2 |
| publicInputHash | bytes32 | 252 | 0 | 32 | contracts/L2/TaikoL2.sol:TaikoL2 |
| parentGasExcess | uint64 | 253 | 0 | 8 | contracts/L2/TaikoL2.sol:TaikoL2 |
| lastSyncedBlock | uint64 | 253 | 8 | 8 | contracts/L2/TaikoL2.sol:TaikoL2 |
Expand Down
11 changes: 11 additions & 0 deletions packages/protocol/contracts/L2/IBlockHash.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;

/// @title IBlockHash
/// @notice Interface for retrieving block hashes.
interface IBlockHash {
/// @notice Retrieves the block hash for a given block ID.
/// @param _blockId The ID of the block whose hash is being requested.
/// @return The block hash of the specified block ID, or 0 if no hash is found.
function getBlockHash(uint256 _blockId) external view returns (bytes32);
}
20 changes: 9 additions & 11 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "../libs/LibAddress.sol";
import "../signal/ISignalService.sol";
import "./Lib1559Math.sol";
import "./LibL2Config.sol";
import "./IBlockHash.sol";

/// @title TaikoL2
/// @notice Taiko L2 is a smart contract that handles cross-layer message
Expand All @@ -19,7 +20,7 @@ import "./LibL2Config.sol";
/// communication, manage EIP-1559 parameters for gas pricing, and store
/// verified L1 block information.
/// @custom:security-contact [email protected]
contract TaikoL2 is EssentialContract {
contract TaikoL2 is EssentialContract, IBlockHash {
using LibAddress for address;
using SafeERC20 for IERC20;

Expand All @@ -28,7 +29,7 @@ contract TaikoL2 is EssentialContract {

/// @notice Mapping from L2 block numbers to their block hashes. All L2 block hashes will
/// be saved in this mapping.
mapping(uint256 blockId => bytes32 blockHash) public l2Hashes;
mapping(uint256 blockId => bytes32 blockHash) private _blockhashes;

/// @notice A hash to check the integrity of public inputs.
/// @dev Slot 2.
Expand Down Expand Up @@ -94,7 +95,7 @@ contract TaikoL2 is EssentialContract {
} else if (block.number == 1) {
// This is the case in tests
uint256 parentHeight = block.number - 1;
l2Hashes[parentHeight] = blockhash(parentHeight);
_blockhashes[parentHeight] = blockhash(parentHeight);
} else {
revert L2_TOO_LATE();
}
Expand Down Expand Up @@ -150,7 +151,7 @@ contract TaikoL2 is EssentialContract {

// Update state variables
bytes32 parentHash = blockhash(parentId);
l2Hashes[parentId] = parentHash;
_blockhashes[parentId] = parentHash;

publicInputHash = newPublicInputHash;
parentGasExcess = newGasExcess;
Expand Down Expand Up @@ -223,7 +224,7 @@ contract TaikoL2 is EssentialContract {

// Update state variables
bytes32 parentHash = blockhash(parentId);
l2Hashes[parentId] = parentHash;
_blockhashes[parentId] = parentHash;
parentTimestamp = uint64(block.timestamp);

emit Anchored(parentHash, parentGasExcess);
Expand Down Expand Up @@ -277,14 +278,11 @@ contract TaikoL2 is EssentialContract {
);
}

/// @notice Retrieves the block hash for the given L2 block number.
/// @param _blockId The L2 block number to retrieve the block hash for.
/// @return The block hash for the specified L2 block id, or zero if the
/// block id is greater than or equal to the current block number.
function getBlockHash(uint64 _blockId) public view returns (bytes32) {
/// @inheritdoc IBlockHash
function getBlockHash(uint256 _blockId) public view returns (bytes32) {
if (_blockId >= block.number) return 0;
if (_blockId + 256 >= block.number) return blockhash(_blockId);
return l2Hashes[_blockId];
return _blockhashes[_blockId];
}

/// @notice Returns the new gas excess that will keep the basefee the same.
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/hekla/HeklaTaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract HeklaTaikoL1 is TaikoL1 {
minGasExcess: 1_340_000_000,
maxGasIssuancePerBlock: 600_000_000 // two minutes
}),
ontakeForkHeight: 793_000
ontakeForkHeight: 840_512
});
}
}
2 changes: 1 addition & 1 deletion packages/protocol/contracts/hekla/HeklaTaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import "../L2/TaikoL2.sol";

/// @title HeklaTaikoL2
/// @custom:security-contact [email protected]
contract HeklaTaikoL2 is TaikoL2 { }
contract HeklaTaikoL2 is TaikoL2 { }
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract contract AddressCache {
function getAddress(
uint64 _chainId,
bytes32 _name,
function (uint64, bytes32) view returns (address) _fallbackFunc
function (uint64, bytes32) view returns (address) _fallbackFunc
)
internal
view
Expand Down
2 changes: 1 addition & 1 deletion packages/taiko-client/bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
428dd49fb678ddeb5a942d4ed924ce760709a350
703b062f4b2af3438cc3de940104e9b6cfcbebc1
6 changes: 6 additions & 0 deletions packages/taiko-client/internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ var (
ProverSgxProofGeneratedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_sgx_generated",
})
ProverR0ProofGeneratedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_r0_generated",
})
ProverSp1ProofGeneratedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_sp1_generated",
})
ProverSubmissionRevertedCounter = factory.NewCounter(prometheus.CounterOpts{
Name: "prover_proof_submission_reverted",
})
Expand Down
6 changes: 5 additions & 1 deletion packages/taiko-client/prover/proof_producer/zkvm_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ func (s *ZKvmProofProducer) RequestProof(
return nil, err
}

metrics.ProverSgxProofGeneratedCounter.Add(1)
if s.ZKProofType == ZKProofTypeR0 {
metrics.ProverR0ProofGeneratedCounter.Add(1)
} else if s.ZKProofType == ZKProofTypeSP1 {
metrics.ProverSp1ProofGeneratedCounter.Add(1)
}

return &ProofWithHeader{
BlockID: blockID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,40 @@ func (a *ProveBlockTxBuilder) Build(
return nil, err
}

if a.proverSetAddress != ZeroAddress {
if data, err = encoding.ProverSetABI.Pack("proveBlock", blockID.Uint64(), input); err != nil {
return nil, err
if meta.IsOntakeBlock() {
if a.proverSetAddress != ZeroAddress {
if data, err = encoding.ProverSetABI.Pack(
"proveBlocks",
[]uint64{blockID.Uint64()},
[][]byte{input},
[]byte{},
); err != nil {
return nil, err
}
to = a.proverSetAddress
} else {
if data, err = encoding.TaikoL1ABI.Pack(
"proveBlocks",
[]uint64{blockID.Uint64()},
[][]byte{input},
[]byte{},
); err != nil {
return nil, err
}
to = a.taikoL1Address
}
to = a.proverSetAddress
} else {
if data, err = encoding.TaikoL1ABI.Pack("proveBlock", blockID.Uint64(), input); err != nil {
return nil, err
if a.proverSetAddress != ZeroAddress {
if data, err = encoding.ProverSetABI.Pack("proveBlock", blockID.Uint64(), input); err != nil {
return nil, err
}
to = a.proverSetAddress
} else {
if data, err = encoding.TaikoL1ABI.Pack("proveBlock", blockID.Uint64(), input); err != nil {
return nil, err
}
to = a.taikoL1Address
}
to = a.taikoL1Address
}
} else {
if tier > encoding.TierGuardianMinorityID {
Expand Down
Loading

0 comments on commit c905d1b

Please sign in to comment.