Skip to content

Commit

Permalink
refactor: remove unneeded propose and da oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Sep 10, 2024
1 parent bff0338 commit c183292
Show file tree
Hide file tree
Showing 42 changed files with 195 additions and 794 deletions.
1 change: 0 additions & 1 deletion .github/workflows/devnet-deploys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ jobs:
echo "TF_VAR_REGISTRY_CONTRACT_ADDRESS=$(extract registryAddress)" >>$GITHUB_ENV
echo "TF_VAR_INBOX_CONTRACT_ADDRESS=$(extract inboxAddress)" >>$GITHUB_ENV
echo "TF_VAR_OUTBOX_CONTRACT_ADDRESS=$(extract outboxAddress)" >>$GITHUB_ENV
echo "TF_VAR_AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$(extract availabilityOracleAddress)" >>$GITHUB_ENV
echo "TF_VAR_FEE_JUICE_CONTRACT_ADDRESS=$(extract feeJuiceAddress)" >>$GITHUB_ENV
echo "TF_VAR_FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$(extract feeJuicePortalAddress)" >>$GITHUB_ENV
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ services:
REGISTRY_CONTRACT_ADDRESS: "0x589a9634c1d00c62e47b3b7a790c8dc986b3d40d"
INBOX_CONTRACT_ADDRESS: "0x12d9b5effc69bf5c0c29c8258c6b6fa95a08de74"
OUTBOX_CONTRACT_ADDRESS: "0x3ec4b6c68a8c2ce4c78cdd465b3019b11a568d1d"
AVAILABILITY_ORACLE_CONTRACT_ADDRESS: "0x98a4089127f3f5d555656f1c9b1801342c9d6bce"
FEE_JUICE_CONTRACT_ADDRESS: "0x73c43b919973711e096bfc04c9d4b3be511ffc0b"
FEE_JUICE_PORTAL_CONTRACT_ADDRESS: "0xdf25b0a34dbee9f25518f7a4d63bab8b3bb3e496"
ETHEREUM_HOST:
Expand Down
2 changes: 0 additions & 2 deletions helm-charts/aztec-network/files/config/config-prover-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ rollup_address=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}'
registry_address=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}')
inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}')
outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
availability_oracle_address=$(echo "$output" | grep -oP 'Availability Oracle Address: \K0x[a-fA-F0-9]{40}')
fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')

Expand All @@ -26,7 +25,6 @@ export ROLLUP_CONTRACT_ADDRESS=$rollup_address
export REGISTRY_CONTRACT_ADDRESS=$registry_address
export INBOX_CONTRACT_ADDRESS=$inbox_address
export OUTBOX_CONTRACT_ADDRESS=$outbox_address
export AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$availability_oracle_address
export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address
EOF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ rollup_address=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}'
registry_address=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}')
inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}')
outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
availability_oracle_address=$(echo "$output" | grep -oP 'Availability Oracle Address: \K0x[a-fA-F0-9]{40}')
fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')

Expand All @@ -37,7 +36,6 @@ export ROLLUP_CONTRACT_ADDRESS=$rollup_address
export REGISTRY_CONTRACT_ADDRESS=$registry_address
export INBOX_CONTRACT_ADDRESS=$inbox_address
export OUTBOX_CONTRACT_ADDRESS=$outbox_address
export AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$availability_oracle_address
export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address
export VALIDATOR_PRIVATE_KEY=$private_key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ data:
registry_address=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}')
inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}')
outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
availability_oracle_address=$(echo "$output" | grep -oP 'Availability Oracle Address: \K0x[a-fA-F0-9]{40}')
fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')
Expand All @@ -29,7 +28,6 @@ data:
export REGISTRY_CONTRACT_ADDRESS=$registry_address
export INBOX_CONTRACT_ADDRESS=$inbox_address
export OUTBOX_CONTRACT_ADDRESS=$outbox_address
export AVAILABILITY_ORACLE_CONTRACT_ADDRESS=$availability_oracle_address
export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address
EOF
Expand Down
177 changes: 67 additions & 110 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity >=0.8.18;

// Interfaces
import {IRollup, ITestRollup} from "./interfaces/IRollup.sol";
import {IAvailabilityOracle} from "./interfaces/IAvailabilityOracle.sol";
import {IInbox} from "./interfaces/messagebridge/IInbox.sol";
import {IOutbox} from "./interfaces/messagebridge/IOutbox.sol";
import {IRegistry} from "./interfaces/messagebridge/IRegistry.sol";
Expand All @@ -19,6 +18,7 @@ import {MerkleLib} from "./libraries/MerkleLib.sol";
import {SignatureLib} from "./sequencer_selection/SignatureLib.sol";
import {SafeCast} from "@oz/utils/math/SafeCast.sol";
import {DataStructures} from "./libraries/DataStructures.sol";
import {TxsDecoder} from "./libraries/decoders/TxsDecoder.sol";

// Contracts
import {MockVerifier} from "../mock/MockVerifier.sol";
Expand Down Expand Up @@ -47,7 +47,6 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
uint256 public constant TIMELINESS_PROVING_IN_SLOTS = 100;

IRegistry public immutable REGISTRY;
IAvailabilityOracle public immutable AVAILABILITY_ORACLE;
IInbox public immutable INBOX;
IOutbox public immutable OUTBOX;
uint256 public immutable VERSION;
Expand All @@ -73,15 +72,13 @@ contract Rollup is Leonidas, IRollup, ITestRollup {

constructor(
IRegistry _registry,
IAvailabilityOracle _availabilityOracle,
IFeeJuicePortal _fpcJuicePortal,
bytes32 _vkTreeRoot,
address _ares,
address[] memory _validators
) Leonidas(_ares) {
verifier = new MockVerifier();
REGISTRY = _registry;
AVAILABILITY_ORACLE = _availabilityOracle;
FEE_JUICE_PORTAL = _fpcJuicePortal;
INBOX = new Inbox(address(this), Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT);
OUTBOX = new Outbox(address(this));
Expand Down Expand Up @@ -171,9 +168,17 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
vkTreeRoot = _vkTreeRoot;
}

function computeTxsEffectsHash(bytes calldata _body)
external
view
override(IRollup)
returns (bytes32)
{
return TxsDecoder.decode(_body);
}

/**
* @notice Published the body and propose the block
* @dev This should likely be purged in the future as it is a convenience method
* @notice Publishes the body and propose the block
* @dev `eth_log_handlers` rely on this function
*
* @param _header - The L2 block header
Expand All @@ -189,27 +194,55 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
SignatureLib.Signature[] memory _signatures,
bytes calldata _body
) external override(IRollup) {
AVAILABILITY_ORACLE.publish(_body);
propose(_header, _archive, _blockHash, _signatures);
}
bytes32 txsEffectsHash = TxsDecoder.decode(_body);

/**
* @notice Published the body and propose the block
* @dev This should likely be purged in the future as it is a convenience method
* @dev `eth_log_handlers` rely on this function
* @param _header - The L2 block header
* @param _archive - A root of the archive tree after the L2 block is applied
* @param _blockHash - The poseidon2 hash of the header added to the archive tree in the rollup circuit
* @param _body - The body of the L2 block
*/
function propose(
bytes calldata _header,
bytes32 _archive,
bytes32 _blockHash,
bytes calldata _body
) external override(IRollup) {
AVAILABILITY_ORACLE.publish(_body);
propose(_header, _archive, _blockHash);
// Decode and validate header
HeaderLib.Header memory header = HeaderLib.decode(_header);
setupEpoch();
_validateHeader({
_header: header,
_signatures: _signatures,
_digest: _archive,
_currentTime: block.timestamp,
_txEffectsHash: txsEffectsHash,
_flags: DataStructures.ExecutionFlags({ignoreDA: false, ignoreSignatures: false})
});

blocks[pendingBlockCount++] = BlockLog({
archive: _archive,
blockHash: _blockHash,
slotNumber: header.globalVariables.slotNumber.toUint128()
});

// @note The block number here will always be >=1 as the genesis block is at 0
bytes32 inHash = INBOX.consume(header.globalVariables.blockNumber);
if (header.contentCommitment.inHash != inHash) {
revert Errors.Rollup__InvalidInHash(inHash, header.contentCommitment.inHash);
}

// TODO(#7218): Revert to fixed height tree for outbox, currently just providing min as interim
// Min size = smallest path of the rollup tree + 1
(uint256 min,) = MerkleLib.computeMinMaxPathLength(header.contentCommitment.numTxs);
uint256 l2ToL1TreeMinHeight = min + 1;
OUTBOX.insert(
header.globalVariables.blockNumber, header.contentCommitment.outHash, l2ToL1TreeMinHeight
);

emit L2BlockProposed(header.globalVariables.blockNumber);

// Automatically flag the block as proven if we have cheated and set assumeProvenUntilBlockNumber.
if (header.globalVariables.blockNumber < assumeProvenUntilBlockNumber) {
provenBlockCount += 1;

if (header.globalVariables.coinbase != address(0) && header.totalFees > 0) {
// @note This will currently fail if there are insufficient funds in the bridge
// which WILL happen for the old version after an upgrade where the bridge follow.
// Consider allowing a failure. See #7938.
FEE_JUICE_PORTAL.distributeFees(header.globalVariables.coinbase, header.totalFees);
}

emit L2ProofVerified(header.globalVariables.blockNumber, "CHEAT");
}
}

/**
Expand Down Expand Up @@ -416,87 +449,11 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
SignatureLib.Signature[] memory _signatures,
bytes32 _digest,
uint256 _currentTime,
bytes32 _txsEffectsHash,
DataStructures.ExecutionFlags memory _flags
) external view override(IRollup) {
HeaderLib.Header memory header = HeaderLib.decode(_header);
_validateHeader(header, _signatures, _digest, _currentTime, _flags);
}

/**
* @notice propose an incoming L2 block with signatures
*
* @param _header - The L2 block header
* @param _archive - A root of the archive tree after the L2 block is applied
* @param _blockHash - The poseidon2 hash of the header added to the archive tree in the rollup circuit
* @param _signatures - Signatures from the validators
*/
function propose(
bytes calldata _header,
bytes32 _archive,
bytes32 _blockHash,
SignatureLib.Signature[] memory _signatures
) public override(IRollup) {
// Decode and validate header
HeaderLib.Header memory header = HeaderLib.decode(_header);
setupEpoch();
_validateHeader({
_header: header,
_signatures: _signatures,
_digest: _archive,
_currentTime: block.timestamp,
_flags: DataStructures.ExecutionFlags({ignoreDA: false, ignoreSignatures: false})
});

blocks[pendingBlockCount++] = BlockLog({
archive: _archive,
blockHash: _blockHash,
slotNumber: header.globalVariables.slotNumber.toUint128()
});

// @note The block number here will always be >=1 as the genesis block is at 0
bytes32 inHash = INBOX.consume(header.globalVariables.blockNumber);
if (header.contentCommitment.inHash != inHash) {
revert Errors.Rollup__InvalidInHash(inHash, header.contentCommitment.inHash);
}

// TODO(#7218): Revert to fixed height tree for outbox, currently just providing min as interim
// Min size = smallest path of the rollup tree + 1
(uint256 min,) = MerkleLib.computeMinMaxPathLength(header.contentCommitment.numTxs);
uint256 l2ToL1TreeMinHeight = min + 1;
OUTBOX.insert(
header.globalVariables.blockNumber, header.contentCommitment.outHash, l2ToL1TreeMinHeight
);

emit L2BlockProposed(header.globalVariables.blockNumber);

// Automatically flag the block as proven if we have cheated and set assumeProvenUntilBlockNumber.
if (header.globalVariables.blockNumber < assumeProvenUntilBlockNumber) {
provenBlockCount += 1;

if (header.globalVariables.coinbase != address(0) && header.totalFees > 0) {
// @note This will currently fail if there are insufficient funds in the bridge
// which WILL happen for the old version after an upgrade where the bridge follow.
// Consider allowing a failure. See #7938.
FEE_JUICE_PORTAL.distributeFees(header.globalVariables.coinbase, header.totalFees);
}

emit L2ProofVerified(header.globalVariables.blockNumber, "CHEAT");
}
}

/**
* @notice Propose a L2 block without signatures
*
* @param _header - The L2 block header
* @param _archive - A root of the archive tree after the L2 block is applied
* @param _blockHash - The poseidon2 hash of the header added to the archive tree in the rollup circuit
*/
function propose(bytes calldata _header, bytes32 _archive, bytes32 _blockHash)
public
override(IRollup)
{
SignatureLib.Signature[] memory emptySignatures = new SignatureLib.Signature[](0);
propose(_header, _archive, _blockHash, emptySignatures);
_validateHeader(header, _signatures, _digest, _currentTime, _txsEffectsHash, _flags);
}

/**
Expand All @@ -523,9 +480,10 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
SignatureLib.Signature[] memory _signatures,
bytes32 _digest,
uint256 _currentTime,
bytes32 _txEffectsHash,
DataStructures.ExecutionFlags memory _flags
) internal view {
_validateHeaderForSubmissionBase(_header, _currentTime, _flags);
_validateHeaderForSubmissionBase(_header, _currentTime, _txEffectsHash, _flags);
_validateHeaderForSubmissionSequencerSelection(
_header.globalVariables.slotNumber, _signatures, _digest, _currentTime, _flags
);
Expand Down Expand Up @@ -586,14 +544,15 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
* - The last archive root in the header MUST match the current archive
* - The slot MUST be larger than the slot of the previous block (ensures single block per slot)
* - The timestamp MUST be equal to GENESIS_TIME + slot * SLOT_DURATION
* - The availability oracle MUST return true for availability of txsEffectsHash
* - The `txsEffectsHash` of the header must match the computed `_txsEffectsHash`
* - This can be relaxed to happen at the time of `submitProof` instead
*
* @param _header - The header to validate
*/
function _validateHeaderForSubmissionBase(
HeaderLib.Header memory _header,
uint256 _currentTime,
bytes32 _txsEffectsHash,
DataStructures.ExecutionFlags memory _flags
) internal view {
if (block.chainid != _header.globalVariables.chainId) {
Expand Down Expand Up @@ -640,10 +599,8 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
revert Errors.Rollup__TimestampInFuture(_currentTime, timestamp);
}

// Check if the data is available using availability oracle (change availability oracle if you want a different DA layer)
if (
!_flags.ignoreDA && !AVAILABILITY_ORACLE.isAvailable(_header.contentCommitment.txsEffectsHash)
) {
// Check if the data is available
if (!_flags.ignoreDA && _header.contentCommitment.txsEffectsHash != _txsEffectsHash) {
revert Errors.Rollup__UnavailableTxs(_header.contentCommitment.txsEffectsHash);
}
}
Expand Down
32 changes: 0 additions & 32 deletions l1-contracts/src/core/availability_oracle/AvailabilityOracle.sol

This file was deleted.

11 changes: 0 additions & 11 deletions l1-contracts/src/core/interfaces/IAvailabilityOracle.sol

This file was deleted.

Loading

0 comments on commit c183292

Please sign in to comment.