Skip to content

Commit

Permalink
feat(protocol): add anchorV2 back (#18820)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoGhurt111 authored Jan 22, 2025
1 parent 64130a8 commit 12de2cf
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/protocol/contracts/layer2/based/TaikoAnchor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,38 @@ contract TaikoAnchor is EssentialContract, IBlockHashProvider, TaikoAnchorDeprec
ISignalService(resolve(LibStrings.B_SIGNAL_SERVICE, false)).receiveSignals(_signalSlots);
}

/// @notice Anchors the latest L1 block details to L2 for cross-layer
/// message verification.
/// @dev This function can be called freely as the golden touch private key is publicly known,
/// but the Taiko node guarantees the first transaction of each block is always this anchor
/// transaction, and any subsequent calls will revert with L2_PUBLIC_INPUT_HASH_MISMATCH.
/// @param _anchorBlockId The `anchorBlockId` value in this block's metadata.
/// @param _anchorStateRoot The state root for the L1 block with id equals `_anchorBlockId`.
/// @param _parentGasUsed The gas used in the parent block.
/// @param _baseFeeConfig The base fee configuration.
function anchorV2(
uint64 _anchorBlockId,
bytes32 _anchorStateRoot,
uint32 _parentGasUsed,
LibSharedData.BaseFeeConfig calldata _baseFeeConfig
)
external
nonZeroBytes32(_anchorStateRoot)
nonZeroValue(_anchorBlockId)
nonZeroValue(_baseFeeConfig.gasIssuancePerSecond)
nonZeroValue(_baseFeeConfig.adjustmentQuotient)
onlyGoldenTouch
nonReentrant
{
require(block.number < pacayaForkHeight, L2_FORK_ERROR());

uint256 parentId = block.number - 1;
_verifyAndUpdatePublicInputHash(parentId);
_verifyBaseFeeAndUpdateGasExcess(_parentGasUsed, _baseFeeConfig);
_syncChainData(_anchorBlockId, _anchorStateRoot);
_updateParentHashAndTimestamp(parentId);
}

/// @notice Withdraw token or Ether from this address.
/// Note: This contract receives a portion of L2 base fees, while the remainder is directed to
/// L2 block's coinbase address.
Expand Down

0 comments on commit 12de2cf

Please sign in to comment.