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
2 changes: 1 addition & 1 deletion l1-contracts/src/core/FeeJuicePortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract FeeJuicePortal is IFeeJuicePortal {
// Preamble
address rollup = canonicalRollup();
uint256 version = REGISTRY.getVersionFor(rollup);
IInbox inbox = IRollup(rollup).INBOX();
IInbox inbox = IRollup(rollup).getInbox();
DataStructures.L2Actor memory actor = DataStructures.L2Actor(L2_TOKEN_ADDRESS, version);

// Hash the message content to be reconstructed in the receiving contract
Expand Down
101 changes: 67 additions & 34 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,36 @@ import {
EnumerableSet
} from "@aztec/core/interfaces/IStaking.sol";
import {IValidatorSelection} from "@aztec/core/interfaces/IValidatorSelection.sol";
import {DataStructures} from "@aztec/core/libraries/DataStructures.sol";
import {FeeAssetValue} from "@aztec/core/libraries/RollupLibs/FeeMath.sol";

// We allow the unused imports here as they make it much simpler to import the Rollup later
// solhint-disable no-unused-import
import {FeeMath} from "@aztec/core/libraries/RollupLibs/FeeMath.sol";
import {HeaderLib} from "@aztec/core/libraries/RollupLibs/HeaderLib.sol";
import {EpochProofLib} from "./libraries/RollupLibs/EpochProofLib.sol";
import {ValidatorSelectionLib} from "./libraries/ValidatorSelectionLib/ValidatorSelectionLib.sol";
import {
RollupCore,
Config,
IRewardDistributor,
IFeeJuicePortal,
IERC20,
BlockLog,
FeeHeader,
ManaBaseFeeComponents,
SubmitEpochRootProofArgs,
L1FeeData,
ValidatorSelectionLib,
StakingLib,
TimeLib,
Slot,
Epoch,
Timestamp,
Errors,
Signature,
DataStructures,
ExtRollupLib,
IntRollupLib,
EpochRewards,
FeeAssetPerEthE9,
EthValue,
PriceLib
PriceLib,
STFLib,
RollupStore,
IInbox,
IOutbox,
ProposeLib,
EpochRewards
} from "./RollupCore.sol";
// solhint-enable no-unused-import

/**
* @title Rollup
Expand All @@ -57,7 +55,6 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
using TimeLib for Timestamp;
using TimeLib for Slot;
using TimeLib for Epoch;
using IntRollupLib for ManaBaseFeeComponents;
using PriceLib for EthValue;

constructor(
Expand Down Expand Up @@ -121,7 +118,7 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
}

function getTips() external view override(IRollup) returns (ChainTips memory) {
return rollupStore.tips;
return STFLib.getStorage().tips;
}

function status(uint256 _myHeaderBlockNumber)
Expand All @@ -137,6 +134,7 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
Epoch provenEpochNumber
)
{
RollupStore storage rollupStore = STFLib.getStorage();
return (
rollupStore.tips.provenBlockNumber,
rollupStore.blocks[rollupStore.tips.provenBlockNumber].archive,
Expand Down Expand Up @@ -169,7 +167,7 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
bytes calldata _aggregationObject
) external view override(IRollup) returns (bytes32[] memory) {
return ExtRollupLib.getEpochProofPublicInputs(
rollupStore, _start, _end, _args, _fees, _blobPublicInputs, _aggregationObject
_start, _end, _args, _fees, _blobPublicInputs, _aggregationObject
);
}

Expand All @@ -194,8 +192,8 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
bytes32 _blobsHash,
DataStructures.ExecutionFlags memory _flags
) external view override(IRollup) {
_validateHeader(
ExtRollupLib.decodeHeader(_header),
ProposeLib.validateHeader(
HeaderLib.decode(_header),
_signatures,
_digest,
_currentTime,
Expand Down Expand Up @@ -224,18 +222,20 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
* @return bytes32 - The current archive root
*/
function archive() external view override(IRollup) returns (bytes32) {
RollupStore storage rollupStore = STFLib.getStorage();
return rollupStore.blocks[rollupStore.tips.pendingBlockNumber].archive;
}

function getProvenBlockNumber() external view override(IRollup) returns (uint256) {
return rollupStore.tips.provenBlockNumber;
return STFLib.getStorage().tips.provenBlockNumber;
}

function getPendingBlockNumber() external view override(IRollup) returns (uint256) {
return rollupStore.tips.pendingBlockNumber;
return STFLib.getStorage().tips.pendingBlockNumber;
}

function getBlock(uint256 _blockNumber) external view override(IRollup) returns (BlockLog memory) {
RollupStore storage rollupStore = STFLib.getStorage();
require(
_blockNumber <= rollupStore.tips.pendingBlockNumber,
Errors.Rollup__InvalidBlockNumber(rollupStore.tips.pendingBlockNumber, _blockNumber)
Expand All @@ -249,7 +249,7 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
override(IRollup)
returns (bytes32)
{
return rollupStore.blobPublicInputsHashes[_blockNumber];
return STFLib.getStorage().blobPublicInputsHashes[_blockNumber];
}

function getProposerForAttester(address _attester)
Expand Down Expand Up @@ -440,7 +440,7 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
}

function getProofSubmissionWindow() external view override(IRollup) returns (uint256) {
return PROOF_SUBMISSION_WINDOW;
return STFLib.getStorage().config.proofSubmissionWindow;
}

function getSequencerRewards(address _sequencer)
Expand All @@ -449,7 +449,7 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
override(IRollup)
returns (uint256)
{
return rollupStore.sequencerRewards[_sequencer];
return STFLib.getStorage().sequencerRewards[_sequencer];
}

function getCollectiveProverRewardsForEpoch(Epoch _epoch)
Expand All @@ -458,7 +458,7 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
override(IRollup)
returns (uint256)
{
return rollupStore.epochRewards[_epoch].rewards;
return STFLib.getStorage().epochRewards[_epoch].rewards;
}

/**
Expand All @@ -477,6 +477,7 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
override(IRollup)
returns (uint256)
{
RollupStore storage rollupStore = STFLib.getStorage();
if (rollupStore.proverClaimed[_prover][_epoch]) {
return 0;
}
Expand All @@ -497,11 +498,11 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
override(IRollup)
returns (bool)
{
return rollupStore.epochRewards[_epoch].subEpoch[_length].hasSubmitted[_prover];
return STFLib.getStorage().epochRewards[_epoch].subEpoch[_length].hasSubmitted[_prover];
}

function getProvingCostPerManaInEth() external view override(IRollup) returns (EthValue) {
return rollupStore.provingCostPerMana;
return STFLib.getStorage().provingCostPerMana;
}

function getProvingCostPerManaInFeeAsset()
Expand All @@ -510,7 +511,35 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
override(IRollup)
returns (FeeAssetValue)
{
return rollupStore.provingCostPerMana.toFeeAsset(getFeeAssetPerEth());
return STFLib.getStorage().provingCostPerMana.toFeeAsset(getFeeAssetPerEth());
}

function getCuauhxicalli() external view override(IRollup) returns (address) {
return EpochProofLib.CUAUHXICALLI;
}

function getVersion() external view override(IRollup) returns (uint256) {
return STFLib.getStorage().config.version;
}

function getInbox() external view override(IRollup) returns (IInbox) {
return STFLib.getStorage().config.inbox;
}

function getOutbox() external view override(IRollup) returns (IOutbox) {
return STFLib.getStorage().config.outbox;
}

function getFeeAsset() external view override(IRollup) returns (IERC20) {
return STFLib.getStorage().config.feeAsset;
}

function getFeeAssetPortal() external view override(IRollup) returns (IFeeJuicePortal) {
return STFLib.getStorage().config.feeAssetPortal;
}

function getRewardDistributor() external view override(IRollup) returns (IRewardDistributor) {
return STFLib.getStorage().config.rewardDistributor;
}

/**
Expand All @@ -529,18 +558,21 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
returns (Slot, uint256)
{
Slot slot = _ts.slotFromTimestamp();
RollupStore storage rollupStore = STFLib.getStorage();

// Consider if a prune will hit in this slot
uint256 pendingBlockNumber =
canPruneAtTime(_ts) ? rollupStore.tips.provenBlockNumber : rollupStore.tips.pendingBlockNumber;

Slot lastSlot = rollupStore.blocks[pendingBlockNumber].slotNumber;
{
Slot lastSlot = rollupStore.blocks[pendingBlockNumber].slotNumber;

require(slot > lastSlot, Errors.Rollup__SlotAlreadyInChain(lastSlot, slot));
require(slot > lastSlot, Errors.Rollup__SlotAlreadyInChain(lastSlot, slot));

// Make sure that the proposer is up to date and on the right chain (ie no reorgs)
bytes32 tipArchive = rollupStore.blocks[pendingBlockNumber].archive;
require(tipArchive == _archive, Errors.Rollup__InvalidArchive(tipArchive, _archive));
// Make sure that the proposer is up to date and on the right chain (ie no reorgs)
bytes32 tipArchive = rollupStore.blocks[pendingBlockNumber].archive;
require(tipArchive == _archive, Errors.Rollup__InvalidArchive(tipArchive, _archive));
}

Signature[] memory sigs = new Signature[](0);
DataStructures.ExecutionFlags memory flags =
Expand All @@ -567,7 +599,7 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
override(IRollup)
returns (uint256)
{
return getManaBaseFeeComponentsAt(_timestamp, _inFeeAsset).summedBaseFee();
return FeeMath.summedBaseFee(getManaBaseFeeComponentsAt(_timestamp, _inFeeAsset));
}

/**
Expand All @@ -578,6 +610,7 @@ contract Rollup is IStaking, IValidatorSelection, IRollup, RollupCore {
* @return bytes32 - The archive root of the block
*/
function archiveAt(uint256 _blockNumber) public view override(IRollup) returns (bytes32) {
RollupStore storage rollupStore = STFLib.getStorage();
return _blockNumber <= rollupStore.tips.pendingBlockNumber
? rollupStore.blocks[_blockNumber].archive
: bytes32(0);
Expand Down
Loading
Loading