Skip to content
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
51 changes: 1 addition & 50 deletions l1-contracts/src/core/RollupCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ contract RollupCore is

RollupStore internal rollupStore;

// @note Assume that all blocks up to this value (inclusive) are automatically proven. Speeds up bootstrapping.
// Testing only. This should be removed eventually.
uint256 private assumeProvenThroughBlockNumber;

constructor(
IFeeJuicePortal _fpcJuicePortal,
IRewardDistributor _rewardDistributor,
Expand Down Expand Up @@ -288,19 +284,6 @@ contract RollupCore is
_prune();
}

/**
* Sets the assumeProvenThroughBlockNumber. Only the contract deployer can set it.
* @param _blockNumber - New value.
*/
function setAssumeProvenThroughBlockNumber(uint256 _blockNumber)
external
override(ITestRollup)
onlyOwner
{
_fakeBlockNumberAsProven(_blockNumber);
assumeProvenThroughBlockNumber = _blockNumber;
}

/**
* @notice Set the verifier contract
*
Expand Down Expand Up @@ -552,26 +535,6 @@ contract RollupCore is
OUTBOX.insert(blockNumber, header.contentCommitment.outHash, min + 1);

emit L2BlockProposed(blockNumber, _args.archive, blobHashes);

// Automatically flag the block as proven if we have cheated and set assumeProvenThroughBlockNumber.
if (blockNumber <= assumeProvenThroughBlockNumber) {
_fakeBlockNumberAsProven(blockNumber);

bool isFeeCanonical = address(this) == FEE_JUICE_PORTAL.canonicalRollup();
bool isRewardDistributorCanonical = address(this) == REWARD_DISTRIBUTOR.canonicalRollup();

if (isFeeCanonical && 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);
}
if (isRewardDistributorCanonical && header.globalVariables.coinbase != address(0)) {
REWARD_DISTRIBUTOR.claim(header.globalVariables.coinbase);
}

emit L2ProofVerified(blockNumber, "CHEAT");
}
}

/**
Expand Down Expand Up @@ -660,10 +623,7 @@ contract RollupCore is
}

function canPruneAtTime(Timestamp _ts) public view override(IRollupCore) returns (bool) {
if (
rollupStore.tips.pendingBlockNumber == rollupStore.tips.provenBlockNumber
|| rollupStore.tips.pendingBlockNumber <= assumeProvenThroughBlockNumber
) {
if (rollupStore.tips.pendingBlockNumber == rollupStore.tips.provenBlockNumber) {
return false;
}

Expand Down Expand Up @@ -789,13 +749,4 @@ contract RollupCore is
})
});
}

function _fakeBlockNumberAsProven(uint256 _blockNumber) private {
if (
_blockNumber > rollupStore.tips.provenBlockNumber
&& _blockNumber <= rollupStore.tips.pendingBlockNumber
) {
rollupStore.tips.provenBlockNumber = _blockNumber;
}
}
}
3 changes: 1 addition & 2 deletions l1-contracts/src/core/interfaces/IRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ struct EpochRewards {
// The below blobPublicInputsHashes are filled when proposing a block, then used to verify an epoch proof.
// TODO(#8955): When implementing batched kzg proofs, store one instance per epoch rather than block
struct RollupStore {
ChainTips tips; // put first such that the struct slot structure is easy to follow for cheatcodes
mapping(uint256 blockNumber => BlockLog log) blocks;
mapping(uint256 blockNumber => bytes32) blobPublicInputsHashes;
ChainTips tips;
bytes32 vkTreeRoot;
bytes32 protocolContractTreeRoot;
L1GasOracleValues l1GasOracleValues;
Expand All @@ -84,7 +84,6 @@ interface ITestRollup {
function setEpochVerifier(address _verifier) external;
function setVkTreeRoot(bytes32 _vkTreeRoot) external;
function setProtocolContractTreeRoot(bytes32 _protocolContractTreeRoot) external;
function setAssumeProvenThroughBlockNumber(uint256 _blockNumber) external;
function cheat__InitialiseValidatorSet(CheatDepositArgs[] memory _args) external;
function getManaBaseFeeComponentsAt(Timestamp _timestamp, bool _inFeeAsset)
external
Expand Down
139 changes: 0 additions & 139 deletions l1-contracts/test/CheatingRollup.t.sol

This file was deleted.

7 changes: 5 additions & 2 deletions l1-contracts/test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ import {
} from "@aztec/core/libraries/TimeLib.sol";

import {RollupBase, IInstance} from "./base/RollupBase.sol";

import {stdStorage, StdStorage} from "forge-std/StdStorage.sol";
// solhint-disable comprehensive-interface

/**
* Blocks are generated using the `integration_l1_publisher.test.ts` tests.
* Main use of these test is shorter cycles when updating the decoder contract.
*/
contract RollupTest is RollupBase {
using stdStorage for StdStorage;
using SlotLib for Slot;
using EpochLib for Epoch;
using ProposeLib for ProposeArgs;
Expand Down Expand Up @@ -266,7 +267,9 @@ contract RollupTest is RollupBase {
warpToL2Slot(1);
_proposeBlock("mixed_block_1", 1);
// we prove epoch 0
rollup.setAssumeProvenThroughBlockNumber(rollup.getPendingBlockNumber());
stdstore.target(address(rollup)).sig("getProvenBlockNumber()").checked_write(
rollup.getPendingBlockNumber()
);

// jump to epoch 1
warpToL2Slot(EPOCH_DURATION);
Expand Down
9 changes: 8 additions & 1 deletion l1-contracts/test/fees/FeeRollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity >=0.8.27;

import {DecoderBase} from "../base/DecoderBase.sol";

import {stdStorage, StdStorage} from "forge-std/StdStorage.sol";

import {DataStructures} from "@aztec/core/libraries/DataStructures.sol";
import {Constants} from "@aztec/core/libraries/ConstantsGen.sol";
import {SignatureLib, Signature} from "@aztec/core/libraries/crypto/SignatureLib.sol";
Expand Down Expand Up @@ -88,6 +90,8 @@ contract FakeCanonical is IRewardDistributor {
}

contract FeeRollupTest is FeeModelTestPoints, DecoderBase {
using stdStorage for StdStorage;

using SlotLib for Slot;
using EpochLib for Epoch;
using FeeMath for uint256;
Expand Down Expand Up @@ -291,7 +295,10 @@ contract FeeRollupTest is FeeModelTestPoints, DecoderBase {
rollup.getManaBaseFeeComponentsAt(Timestamp.wrap(timeOfPrune), true);

// If we assume that everything is proven, we will see what the fee would be if we did not prune.
rollup.setAssumeProvenThroughBlockNumber(10000);
stdstore.target(address(rollup)).sig("getProvenBlockNumber()").checked_write(
rollup.getPendingBlockNumber()
);

ManaBaseFeeComponents memory componentsNoPrune =
rollup.getManaBaseFeeComponentsAt(Timestamp.wrap(timeOfPrune), true);

Expand Down
24 changes: 24 additions & 0 deletions yarn-project/aztec.js/src/api/ethereum/anvil_test_watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { RollupAbi } from '@aztec/l1-artifacts';
import { type GetContractReturnType, type HttpTransport, type PublicClient, getAddress, getContract } from 'viem';
import type * as chains from 'viem/chains';

import { RollupCheatCodes } from './cheat_codes.js';

/**
* Represents a watcher for a rollup contract.
*
Expand All @@ -19,12 +21,16 @@ export class AnvilTestWatcher {
private isSandbox: boolean = false;

private rollup: GetContractReturnType<typeof RollupAbi, PublicClient<HttpTransport, chains.Chain>>;
private rollupCheatCodes: RollupCheatCodes;

private filledRunningPromise?: RunningPromise;
private mineIfOutdatedPromise?: RunningPromise;
private markingAsProvenRunningPromise?: RunningPromise;

private logger: Logger = createLogger(`aztecjs:utils:watcher`);

private isMarkingAsProven = true;

constructor(
private cheatcodes: EthCheatCodes,
rollupAddress: EthAddress,
Expand All @@ -37,9 +43,17 @@ export class AnvilTestWatcher {
client: publicClient,
});

this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
rollupAddress,
});

this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
}

setIsMarkingAsProven(isMarkingAsProven: boolean) {
this.isMarkingAsProven = isMarkingAsProven;
}

setIsSandbox(isSandbox: boolean) {
this.isSandbox = isSandbox;
}
Expand All @@ -60,6 +74,8 @@ export class AnvilTestWatcher {
this.filledRunningPromise.start();
this.mineIfOutdatedPromise = new RunningPromise(() => this.mineIfOutdated(), this.logger, 1000);
this.mineIfOutdatedPromise.start();
this.markingAsProvenRunningPromise = new RunningPromise(() => this.markAsProven(), this.logger, 1000);
this.markingAsProvenRunningPromise.start();
this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
} else {
this.logger.info(`Watcher not started because not auto mining`);
Expand All @@ -69,6 +85,14 @@ export class AnvilTestWatcher {
async stop() {
await this.filledRunningPromise?.stop();
await this.mineIfOutdatedPromise?.stop();
await this.markingAsProvenRunningPromise?.stop();
}

async markAsProven() {
if (!this.isMarkingAsProven) {
return;
}
await this.rollupCheatCodes.markAsProven();
}

async mineIfOutdated() {
Expand Down
Loading