Skip to content

Conversation

@philippecamacho
Copy link
Collaborator

@philippecamacho philippecamacho commented Nov 14, 2025

Closes https://app.asana.com/1/1208976916964769/project/1209423958092927/task/1211849813289225?focus=true

This PR:

  • Make changes to the Inbox contract so that it allows two batchers. The specification of this contract change can be found at https://eng-wiki.espressosys.com/mainch36.html#:Components:Base%20Layer%20Batch%20Validation:Batch%20Inbox%20Contract (see paragraph "Allowing different batchers")
  • Extend the CI test suite to run L1 contract tests
  • Remove the concept of preapproved batcher key and replace it with the non TEE batcher key, while introducing the TEE batcher key.
  • Remove test TestRotateBatcherKey as the batcher key rotation will happen in the Inbox contract.
  • NOT RELATED to the fallback inbox contract changes, but the circle ci tests that are failing have been deactivated for now. We can reactivate them later once they pass.

This PR does not:

  • Implement the full fallback mechanism. This will be addressed in another PR.

Key places to review:

  • Focus on the smart contract changes, in particular packages/contracts-bedrock/test/L1/BatchInbox.t.sol.

How to test this PR:

cd packages/contracts-bedrock/
forge test  --match-path test/L1/BatchInbox.t.sol

Things tested

  • The core logic of the new inbox contract with about handling two batchers and allowing to switch from one to another. See packages/contracts-bedrock/test/L1/BatchInbox.t.sol.

@philippecamacho philippecamacho force-pushed the philippe/fallback-contracts-change-new branch from b09bfab to 62d96d3 Compare November 14, 2025 20:06
@philippecamacho philippecamacho marked this pull request as ready for review November 15, 2025 15:18
@philippecamacho philippecamacho force-pushed the philippe/fallback-contracts-change-new branch from fcd5832 to 9af9291 Compare November 26, 2025 16:47
contract MockBatchAuthenticator {
mapping(bytes32 => bool) private validHashes;

function setValidBatchInfo(bytes32 hash, bool valid) external {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Similar to the comment above, setBatchValidity might be a better name.

/// @title MockBatchAuthenticator
/// @notice Mock implementation for testing - only implements validBatchInfo
contract MockBatchAuthenticator {
mapping(bytes32 => bool) private validHashes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: hashValidities might be a more accurate name since the mapped bool might be false.

validHashes[hash] = valid;
}

function validBatchInfo(bytes32 hash) external view returns (bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Similar to the comment above, batchValidity might be a better name.


function setUp() public virtual {
authenticator = new MockBatchAuthenticator();
inbox = new BatchInbox(nonTeeBatcher, IBatchAuthenticator(address(authenticator)), deployer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will test_fallback_nonTeeBatcherDoesNotRequireAuth fail if we don't construct a BatchInbox with the nonTeeBatcher here, similar to test_fallback_unauthorizedAddressReverts? If so, do we have any setup for the teeBatcher? I guess there is, otherwise there's no way to distinguish authorized vs. unauthorized batchers, but I just don't find it in this file.

These are questions to check my understanding, not requesting any changes.

if allocType == AllocTypeEspressoWithoutEnclave {
batcherPk, err := crypto.HexToECDSA(ESPRESSO_PRE_APPROVED_BATCHER_PRIVATE_KEY)
// Configure Espresso allocation types
if allocType == AllocTypeEspresso || allocType == AllocTypeEspressoWithoutEnclave || allocType == AllocTypeEspressoWithEnclave {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have AllocTypeEspresso when we also have *WithEnclave and *WithoutEnclave?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh AllocTypeEspresso isn't introduced in this PR. @QuentinI looks like these three types were added from these two PRs on the same day: #110 and #144. Maybe there was some merge weirdness and we only wanted to keep the With and Without types?

if allocType == AllocTypeEspressoWithEnclave {
intent.Chains[0].EspressoEnabled = true
intent.Chains[0].NonTeeBatcher = crypto.PubkeyToAddress(batcherPk.PublicKey)
intent.Chains[0].TeeBatcher = crypto.PubkeyToAddress(batcherPk.PublicKey)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it for simplicity that we now set TeeBatcher even when allocType == AllocTypeEspressoWithoutEnclave? I think it's fine to set but not use it--just wanted to make sure it's intentional to put it in this condition clause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants