Skip to content

Commit

Permalink
chore: rename process to propose for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Aug 29, 2024
1 parent 7df45c3 commit 5b614c2
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 137 deletions.
26 changes: 13 additions & 13 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
}

/**
* @notice Published the body and processes the block
* @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
*
Expand All @@ -198,34 +198,34 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
* @param _signatures - Signatures from the validators
* @param _body - The body of the L2 block
*/
function publishAndProcess(
function propose(
bytes calldata _header,
bytes32 _archive,
bytes32 _blockHash,
SignatureLib.Signature[] memory _signatures,
bytes calldata _body
) external override(IRollup) {
AVAILABILITY_ORACLE.publish(_body);
process(_header, _archive, _blockHash, _signatures);
propose(_header, _archive, _blockHash, _signatures);
}

/**
* @notice Published the body and processes the block
* @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 publishAndProcess(
function propose(
bytes calldata _header,
bytes32 _archive,
bytes32 _blockHash,
bytes calldata _body
) external override(IRollup) {
AVAILABILITY_ORACLE.publish(_body);
process(_header, _archive, _blockHash);
propose(_header, _archive, _blockHash);
}

/**
Expand Down Expand Up @@ -447,14 +447,14 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
}

/**
* @notice Processes an incoming L2 block with signatures
* @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 process(
function propose(
bytes calldata _header,
bytes32 _archive,
bytes32 _blockHash,
Expand Down Expand Up @@ -491,7 +491,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
header.globalVariables.blockNumber, header.contentCommitment.outHash, l2ToL1TreeMinHeight
);

emit L2BlockProcessed(header.globalVariables.blockNumber);
emit L2BlockProposed(header.globalVariables.blockNumber);

// Automatically flag the block as proven if we have cheated and set assumeProvenUntilBlockNumber.
if (header.globalVariables.blockNumber < assumeProvenUntilBlockNumber) {
Expand All @@ -509,18 +509,18 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
}

/**
* @notice Processes an incoming L2 block without signatures
* @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 process(bytes calldata _header, bytes32 _archive, bytes32 _blockHash)
function propose(bytes calldata _header, bytes32 _archive, bytes32 _blockHash)
public
override(IRollup)
{
SignatureLib.Signature[] memory emptySignatures = new SignatureLib.Signature[](0);
process(_header, _archive, _blockHash, emptySignatures);
propose(_header, _archive, _blockHash, emptySignatures);
}

/**
Expand Down Expand Up @@ -610,7 +610,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
revert Errors.Rollup__InvalidEpoch(currentEpoch, epochNumber);
}

_processPendingBlock(_slot, _signatures, _digest, _flags);
_proposePendingBlock(_slot, _signatures, _digest, _flags);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions l1-contracts/src/core/interfaces/IRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ITestRollup {
}

interface IRollup {
event L2BlockProcessed(uint256 indexed blockNumber);
event L2BlockProposed(uint256 indexed blockNumber);
event L2ProofVerified(uint256 indexed blockNumber, bytes32 indexed proverId);
event PrunedPending(uint256 provenBlockCount, uint256 pendingBlockCount);

Expand All @@ -38,21 +38,21 @@ interface IRollup {

function OUTBOX() external view returns (IOutbox);

function publishAndProcess(
function propose(
bytes calldata _header,
bytes32 _archive,
bytes32 _blockHash,
SignatureLib.Signature[] memory _signatures,
bytes calldata _body
) external;
function publishAndProcess(
function propose(
bytes calldata _header,
bytes32 _archive,
bytes32 _blockHash,
bytes calldata _body
) external;
function process(bytes calldata _header, bytes32 _archive, bytes32 _blockHash) external;
function process(
function propose(bytes calldata _header, bytes32 _archive, bytes32 _blockHash) external;
function propose(
bytes calldata _header,
bytes32 _archive,
bytes32 _blockHash,
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/src/core/sequencer_selection/Leonidas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ contract Leonidas is Ownable, ILeonidas {
}

/**
* @notice Process a pending block from the point-of-view of sequencer selection. Will:
* @notice Propose a pending block from the point-of-view of sequencer selection. Will:
* - Setup the epoch if needed (if epoch committee is empty skips the rest)
* - Validate that the proposer is the proposer of the slot
* - Validate that the signatures for attestations are indeed from the validatorset
Expand All @@ -354,7 +354,7 @@ contract Leonidas is Ownable, ILeonidas {
* @param _signatures - The signatures of the committee members
* @param _digest - The digest of the block
*/
function _processPendingBlock(
function _proposePendingBlock(
uint256 _slot,
SignatureLib.Signature[] memory _signatures,
bytes32 _digest,
Expand Down
16 changes: 8 additions & 8 deletions l1-contracts/test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contract RollupTest is DecoderBase {
// We jump to the time of the block. (unless it is in the past)
vm.warp(max(block.timestamp, data.decodedHeader.globalVariables.timestamp));

rollup.process(header, archive, bytes32(0));
rollup.propose(header, archive, bytes32(0));

rollup.submitBlockRootProof(header, archive, bytes32(0), "", "");

Expand Down Expand Up @@ -224,7 +224,7 @@ contract RollupTest is DecoderBase {
assertEq(coinbaseBalance, 0, "invalid initial coinbase balance");

// Assert that balance have NOT been increased by proposing the block
rollup.process(header, archive, bytes32(0));
rollup.propose(header, archive, bytes32(0));
assertEq(portalERC20.balanceOf(coinbase), 0, "invalid coinbase balance");

vm.expectRevert(
Expand Down Expand Up @@ -272,7 +272,7 @@ contract RollupTest is DecoderBase {

vm.warp(max(block.timestamp, data.decodedHeader.globalVariables.timestamp));
availabilityOracle.publish(body);
rollup.process(header, archive, bytes32(0));
rollup.propose(header, archive, bytes32(0));

vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__NonSequentialProving.selector));
rollup.submitBlockRootProof(header, archive, bytes32(0), "", "");
Expand Down Expand Up @@ -310,7 +310,7 @@ contract RollupTest is DecoderBase {
availabilityOracle.publish(body);

vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__InvalidBlockNumber.selector, 1, 0x420));
rollup.process(header, archive, bytes32(0));
rollup.propose(header, archive, bytes32(0));
}

function testRevertInvalidChainId() public setUpFor("empty_block_1") {
Expand All @@ -327,7 +327,7 @@ contract RollupTest is DecoderBase {
availabilityOracle.publish(body);

vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__InvalidChainId.selector, 31337, 0x420));
rollup.process(header, archive, bytes32(0));
rollup.propose(header, archive, bytes32(0));
}

function testRevertInvalidVersion() public setUpFor("empty_block_1") {
Expand All @@ -343,7 +343,7 @@ contract RollupTest is DecoderBase {
availabilityOracle.publish(body);

vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__InvalidVersion.selector, 1, 0x420));
rollup.process(header, archive, bytes32(0));
rollup.propose(header, archive, bytes32(0));
}

function testRevertInvalidTimestamp() public setUpFor("empty_block_1") {
Expand All @@ -364,7 +364,7 @@ contract RollupTest is DecoderBase {
availabilityOracle.publish(body);

vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__InvalidTimestamp.selector, realTs, badTs));
rollup.process(header, archive, bytes32(0));
rollup.propose(header, archive, bytes32(0));
}

function testBlocksWithAssumeProven() public setUpFor("mixed_block_1") {
Expand Down Expand Up @@ -465,7 +465,7 @@ contract RollupTest is DecoderBase {

availabilityOracle.publish(body);

rollup.process(header, archive, bytes32(0));
rollup.propose(header, archive, bytes32(0));

if (_submitProof) {
uint256 pre = rollup.provenBlockCount();
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/test/sparta/DevNet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ contract DevNetTest is DecoderBase {
}

vm.prank(ree.proposer);
rollup.process(header, archive, bytes32(0));
rollup.propose(header, archive, bytes32(0));

assertEq(_expectRevert, ree.shouldRevert, "Invalid revert expectation");

Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/test/sparta/Sparta.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ contract SpartaTest is DecoderBase {
}

vm.prank(ree.proposer);
rollup.process(header, archive, bytes32(0), signatures);
rollup.propose(header, archive, bytes32(0), signatures);

if (ree.shouldRevert) {
return;
}
} else {
rollup.process(header, archive, bytes32(0));
rollup.propose(header, archive, bytes32(0));
}

assertEq(_expectRevert, ree.shouldRevert, "Does not match revert expectation");
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/archiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Archiver is a service which is used to fetch data on-chain data and present them in a nice-to-consume form.
The on-chain data specifically are the following events:

1. `L2BlockProcessed` event emitted on Rollup contract,
1. `L2BlockProposed` event emitted on Rollup contract,
2. `MessageAdded` event emitted on Inbox contract,

The interfaces defining how the data can be consumed from the archiver are `L2BlockSource`, `L2LogsSource` and `ContractDataSource`.
Expand Down
20 changes: 10 additions & 10 deletions yarn-project/archiver/src/archiver/archiver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('Archiver', () => {
mockGetLogs({
messageSent: [makeMessageSentEvent(98n, 1n, 0n), makeMessageSentEvent(99n, 1n, 1n)],
txPublished: [makeTxsPublishedEvent(101n, blocks[0].body.getTxsEffectsHash())],
l2BlockProcessed: [makeL2BlockProcessedEvent(101n, 1n)],
L2BlockProposed: [makeL2BlockProposedEvent(101n, 1n)],
proofVerified: [makeProofVerifiedEvent(102n, 1n, proverId)],
});

Expand All @@ -98,7 +98,7 @@ describe('Archiver', () => {
makeTxsPublishedEvent(2510n, blocks[1].body.getTxsEffectsHash()),
makeTxsPublishedEvent(2520n, blocks[2].body.getTxsEffectsHash()),
],
l2BlockProcessed: [makeL2BlockProcessedEvent(2510n, 2n), makeL2BlockProcessedEvent(2520n, 3n)],
L2BlockProposed: [makeL2BlockProposedEvent(2510n, 2n), makeL2BlockProposedEvent(2520n, 3n)],
});

publicClient.getTransaction.mockResolvedValueOnce(publishTxs[0]);
Expand Down Expand Up @@ -208,7 +208,7 @@ describe('Archiver', () => {
makeTxsPublishedEvent(70n, blocks[0].body.getTxsEffectsHash()),
makeTxsPublishedEvent(80n, blocks[1].body.getTxsEffectsHash()),
],
l2BlockProcessed: [makeL2BlockProcessedEvent(70n, 1n), makeL2BlockProcessedEvent(80n, 2n)],
L2BlockProposed: [makeL2BlockProposedEvent(70n, 1n), makeL2BlockProposedEvent(80n, 2n)],
});

mockGetLogs({});
Expand All @@ -231,29 +231,29 @@ describe('Archiver', () => {
const mockGetLogs = (logs: {
messageSent?: ReturnType<typeof makeMessageSentEvent>[];
txPublished?: ReturnType<typeof makeTxsPublishedEvent>[];
l2BlockProcessed?: ReturnType<typeof makeL2BlockProcessedEvent>[];
L2BlockProposed?: ReturnType<typeof makeL2BlockProposedEvent>[];
proofVerified?: ReturnType<typeof makeProofVerifiedEvent>[];
}) => {
publicClient.getLogs
.mockResolvedValueOnce(logs.messageSent ?? [])
.mockResolvedValueOnce(logs.txPublished ?? [])
.mockResolvedValueOnce(logs.l2BlockProcessed ?? [])
.mockResolvedValueOnce(logs.L2BlockProposed ?? [])
.mockResolvedValueOnce(logs.proofVerified ?? []);
};
});

/**
* Makes a fake L2BlockProcessed event for testing purposes.
* Makes a fake L2BlockProposed event for testing purposes.
* @param l1BlockNum - L1 block number.
* @param l2BlockNum - L2 Block number.
* @returns An L2BlockProcessed event log.
* @returns An L2BlockProposed event log.
*/
function makeL2BlockProcessedEvent(l1BlockNum: bigint, l2BlockNum: bigint) {
function makeL2BlockProposedEvent(l1BlockNum: bigint, l2BlockNum: bigint) {
return {
blockNumber: l1BlockNum,
args: { blockNumber: l2BlockNum },
transactionHash: `0x${l2BlockNum}`,
} as Log<bigint, number, false, undefined, true, typeof RollupAbi, 'L2BlockProcessed'>;
} as Log<bigint, number, false, undefined, true, typeof RollupAbi, 'L2BlockProposed'>;
}

/**
Expand Down Expand Up @@ -310,7 +310,7 @@ function makeRollupTx(l2Block: L2Block) {
const blockHash = toHex(l2Block.header.hash().toBuffer());
const input = encodeFunctionData({
abi: RollupAbi,
functionName: 'process',
functionName: 'propose',
args: [header, archive, blockHash],
});
return { input } as Transaction<bigint, number>;
Expand Down
16 changes: 8 additions & 8 deletions yarn-project/archiver/src/archiver/data_retrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { RollupAbi } from '@aztec/l1-artifacts';
import { type PublicClient, getAbiItem } from 'viem';

import {
getL2BlockProcessedLogs,
getL2BlockProposedLogs,
getMessageSentLogs,
getTxsPublishedLogs,
processL2BlockProcessedLogs,
processL2BlockProposedLogs,
processMessageSentLogs,
processTxsPublishedLogs,
} from './eth_log_handlers.js';
Expand Down Expand Up @@ -41,25 +41,25 @@ export async function retrieveBlockMetadataFromRollup(
if (searchStartBlock > searchEndBlock) {
break;
}
const l2BlockProcessedLogs = await getL2BlockProcessedLogs(
const L2BlockProposedLogs = await getL2BlockProposedLogs(
publicClient,
rollupAddress,
searchStartBlock,
searchEndBlock,
);
if (l2BlockProcessedLogs.length === 0) {
if (L2BlockProposedLogs.length === 0) {
break;
}

const lastLog = l2BlockProcessedLogs[l2BlockProcessedLogs.length - 1];
const lastLog = L2BlockProposedLogs[L2BlockProposedLogs.length - 1];
logger.debug(
`Got L2 block processed logs for ${l2BlockProcessedLogs[0].blockNumber}-${lastLog.blockNumber} between ${searchStartBlock}-${searchEndBlock} L1 blocks`,
`Got L2 block processed logs for ${L2BlockProposedLogs[0].blockNumber}-${lastLog.blockNumber} between ${searchStartBlock}-${searchEndBlock} L1 blocks`,
);

const newBlockMetadata = await processL2BlockProcessedLogs(
const newBlockMetadata = await processL2BlockProposedLogs(
publicClient,
expectedNextL2BlockNum,
l2BlockProcessedLogs,
L2BlockProposedLogs,
);
retrievedBlockMetadata.push(...newBlockMetadata);
searchStartBlock = lastLog.blockNumber! + 1n;
Expand Down
Loading

0 comments on commit 5b614c2

Please sign in to comment.