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
9 changes: 4 additions & 5 deletions op-deployer/pkg/deployer/opcm/espresso.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ type DeployAWSNitroVerifierOutput struct {
}

type DeployEspressoInput struct {
Salt common.Hash
NitroTEEVerifier common.Address
NonTeeBatcher common.Address
TeeBatcher common.Address
PreRegisteredBatcher common.Address
Salt common.Hash
NitroTEEVerifier common.Address
NonTeeBatcher common.Address
TeeBatcher common.Address
}

type DeployEspressoOutput struct {
Expand Down
9 changes: 4 additions & 5 deletions op-deployer/pkg/deployer/pipeline/espresso.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ func DeployEspresso(env *Env, intent *state.Intent, st *state.State, chainID com
}

eo, err = opcm.DeployEspresso(env.L1ScriptHost, opcm.DeployEspressoInput{
Salt: st.Create2Salt,
NitroTEEVerifier: nvo.NitroTEEVerifierAddress,
NonTeeBatcher: chainIntent.NonTeeBatcher,
TeeBatcher: chainIntent.TeeBatcher,
PreRegisteredBatcher: chainIntent.PreRegisteredBatcher,
Salt: st.Create2Salt,
NitroTEEVerifier: nvo.NitroTEEVerifierAddress,
NonTeeBatcher: chainIntent.NonTeeBatcher,
TeeBatcher: chainIntent.TeeBatcher,
}, batchAuthenticatorOwnwerAddress)
if err != nil {
return fmt.Errorf("failed to deploy espresso contracts: %w", err)
Expand Down
7 changes: 3 additions & 4 deletions op-deployer/pkg/deployer/state/chain_intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ type ChainIntent struct {
L2DevGenesisParams *L2DevGenesisParams `json:"l2DevGenesisParams,omitempty" toml:"l2DevGenesisParams,omitempty"`

// Espresso-specific fields
EspressoEnabled bool `json:"espressoEnabled,omitzero" toml:"espressoEnabled,omitzero"`
NonTeeBatcher common.Address `json:"nonTeeBatcher,omitzero" toml:"nonTeeBatcher,omitzero"`
TeeBatcher common.Address `json:"teeBatcher,omitzero" toml:"teeBatcher,omitzero"`
PreRegisteredBatcher common.Address `json:"preRegisteredBatcher,omitzero" toml:"preRegisteredBatcher,omitzero"`
EspressoEnabled bool `json:"espressoEnabled,omitzero" toml:"espressoEnabled,omitzero"`
NonTeeBatcher common.Address `json:"nonTeeBatcher,omitzero" toml:"nonTeeBatcher,omitzero"`
TeeBatcher common.Address `json:"teeBatcher,omitzero" toml:"teeBatcher,omitzero"`
}

type ChainRoles struct {
Expand Down
8 changes: 0 additions & 8 deletions op-e2e/config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,6 @@ func initAllocType(root string, allocType AllocType) {
intent.L1DevGenesisParams.Prefund[nonTeeBatcherAddr] = millionEth
}

if allocType == AllocTypeEspressoWithoutEnclave {
ephemeralPk, err := crypto.HexToECDSA(ESPRESSO_TESTING_BATCHER_EPHEMERAL_KEY)
if err != nil {
panic(fmt.Errorf("failed to parse batcher private key: %w", err))
}
intent.Chains[0].PreRegisteredBatcher = crypto.PubkeyToAddress(ephemeralPk.PublicKey)
}

baseUpgradeSchedule := map[string]any{
"l2GenesisRegolithTimeOffset": nil,
"l2GenesisCanyonTimeOffset": nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ interface IBatchAuthenticator {
address _espressoTEEVerifier,
address _teeBatcher,
address _nonTeeBatcher,
address _preRegisteredBatcher,
address _owner
) external;
}
18 changes: 1 addition & 17 deletions packages/contracts-bedrock/scripts/deploy/DeployEspresso.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ contract DeployEspressoInput is BaseDeployIO {
address internal _nitroTEEVerifier;
address internal _nonTeeBatcher;
address internal _teeBatcher;
address internal _preRegisteredBatcher;

function set(bytes4 _sel, bytes32 _val) public {
if (_sel == this.salt.selector) _salt = _val;
Expand All @@ -32,8 +31,6 @@ contract DeployEspressoInput is BaseDeployIO {
_nonTeeBatcher = _val;
} else if (_sel == this.teeBatcher.selector) {
_teeBatcher = _val;
} else if (_sel == this.preRegisteredBatcher.selector) {
_preRegisteredBatcher = _val;
} else {
revert("DeployEspressoInput: unknown selector");
}
Expand All @@ -55,10 +52,6 @@ contract DeployEspressoInput is BaseDeployIO {
function teeBatcher() public view returns (address) {
return _teeBatcher;
}

function preRegisteredBatcher() public view returns (address) {
return _preRegisteredBatcher;
}
}

contract DeployEspressoOutput is BaseDeployIO {
Expand Down Expand Up @@ -106,23 +99,14 @@ contract DeployEspresso is Script {
{
bytes32 salt = input.salt();
vm.broadcast(msg.sender);
if (input.preRegisteredBatcher() != address(0)) {
console.log("WARNING: preRegisteredBatcher is set. This should not happen in production deployments");
}
IBatchAuthenticator impl = IBatchAuthenticator(
DeployUtils.create2({
_name: "BatchAuthenticator",
_salt: salt,
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IBatchAuthenticator.__constructor__,
(
address(teeVerifier),
input.teeBatcher(),
input.nonTeeBatcher(),
input.preRegisteredBatcher(),
owner
)
(address(teeVerifier), input.teeBatcher(), input.nonTeeBatcher(), owner)
)
)
})
Expand Down
16 changes: 4 additions & 12 deletions packages/contracts-bedrock/src/L1/BatchAuthenticator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ contract BatchAuthenticator is ISemver, Ownable {
/// @notice Address of the non-TEE (fallback) batcher that can post when TEE is inactive.
address public immutable nonTeeBatcher;

/// @notice Key of pre-registered TEE batcher that can authenticate batches without
/// calling registerSigner first. For testing only.
address public immutable preRegisteredBatcher;

IEspressoTEEVerifier public immutable espressoTEEVerifier;

/// @notice Flag indicating which batcher is currently active.
Expand All @@ -40,7 +36,6 @@ contract BatchAuthenticator is ISemver, Ownable {
IEspressoTEEVerifier _espressoTEEVerifier,
address _teeBatcher,
address _nonTeeBatcher,
address _preRegisteredBatcher,
address _owner
)
Ownable()
Expand All @@ -53,7 +48,6 @@ contract BatchAuthenticator is ISemver, Ownable {
nonTeeBatcher = _nonTeeBatcher;
// By default, start with the TEE batcher active.
activeIsTee = true;
preRegisteredBatcher = _preRegisteredBatcher;
_transferOwnership(_owner);
}

Expand All @@ -75,12 +69,10 @@ contract BatchAuthenticator is ISemver, Ownable {

require(signer != address(0), "BatchAuthenticator: invalid signature");

if (signer != preRegisteredBatcher) {
require(
espressoTEEVerifier.espressoNitroTEEVerifier().registeredSigners(signer),
"BatchAuthenticator: invalid signer"
);
}
require(
espressoTEEVerifier.espressoNitroTEEVerifier().registeredSigners(signer),
"BatchAuthenticator: invalid signer"
);

validBatchInfo[commitment] = true;
emit BatchInfoAuthenticated(commitment, signer);
Expand Down
20 changes: 6 additions & 14 deletions packages/contracts-bedrock/test/L1/BatchAuthenticator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ contract BatchAuthenticator_SwitchBatcher_Test is Test {

address public teeBatcher = address(0x1234);
address public nonTeeBatcher = address(0x5678);
address public preRegisteredBatcher = address(0x9ABC);

MockNitroTEEVerifier public nitroVerifier;
MockEspressoTEEVerifier public teeVerifier;
Expand All @@ -92,9 +91,8 @@ contract BatchAuthenticator_SwitchBatcher_Test is Test {
teeVerifier = new MockEspressoTEEVerifier(nitroVerifier);

vm.prank(deployer);
authenticator = new BatchAuthenticator(
IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, nonTeeBatcher, preRegisteredBatcher, deployer
);
authenticator =
new BatchAuthenticator(IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, nonTeeBatcher, deployer);
}

/// @notice Test that only the owner can switch the active batcher
Expand All @@ -117,7 +115,6 @@ contract BatchAuthenticator_SwitchBatcher_Test is Test {
contract BatchAuthenticator_Constructor_Test is Test {
address public teeBatcher = address(0x1234);
address public nonTeeBatcher = address(0x5678);
address public preRegisteredBatcher = address(0x9ABC);

address public owner = address(0xBEEF);

Expand All @@ -131,22 +128,17 @@ contract BatchAuthenticator_Constructor_Test is Test {

function test_constructor_revertsWhenTeeBatcherIsZero() external {
vm.expectRevert("BatchAuthenticator: zero tee batcher");
new BatchAuthenticator(
IEspressoTEEVerifier(address(teeVerifier)), address(0), nonTeeBatcher, preRegisteredBatcher, owner
);
new BatchAuthenticator(IEspressoTEEVerifier(address(teeVerifier)), address(0), nonTeeBatcher, owner);
}

function test_constructor_revertsWhenNonTeeBatcherIsZero() external {
vm.expectRevert("BatchAuthenticator: zero non-tee batcher");
new BatchAuthenticator(
IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, address(0), preRegisteredBatcher, owner
);
new BatchAuthenticator(IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, address(0), owner);
}

function test_constructor_succeedsWithValidAddresses() external {
BatchAuthenticator authenticator = new BatchAuthenticator(
IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, nonTeeBatcher, preRegisteredBatcher, owner
);
BatchAuthenticator authenticator =
new BatchAuthenticator(IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, nonTeeBatcher, owner);
assertEq(authenticator.teeBatcher(), teeBatcher);
assertEq(authenticator.nonTeeBatcher(), nonTeeBatcher);
}
Expand Down
9 changes: 3 additions & 6 deletions packages/contracts-bedrock/test/L1/BatchInbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ contract TestBatchAuthenticator is BatchAuthenticator {
IEspressoTEEVerifier _espressoTEEVerifier,
address _teeBatcher,
address _nonTeeBatcher,
address _preRegisteredBatcher,
address _owner
)
BatchAuthenticator(_espressoTEEVerifier, _teeBatcher, _nonTeeBatcher, _preRegisteredBatcher, _owner)
BatchAuthenticator(_espressoTEEVerifier, _teeBatcher, _nonTeeBatcher, _owner)
{ }

// Test helper to bypass signature verification in authenticateBatchInfo.
Expand All @@ -40,7 +39,6 @@ contract BatchInbox_Test is Test {

address public teeBatcher = address(0x1234);
address public nonTeeBatcher = address(0x5678);
address public preRegisteredBatcher = address(0x9ABC);
address public deployer = address(0xDEF0);
address public unauthorized = address(0xDEAD);

Expand All @@ -49,9 +47,8 @@ contract BatchInbox_Test is Test {
teeVerifier = new MockEspressoTEEVerifier(nitroVerifier);

vm.prank(deployer);
authenticator = new TestBatchAuthenticator(
IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, nonTeeBatcher, preRegisteredBatcher, deployer
);
authenticator =
new TestBatchAuthenticator(IEspressoTEEVerifier(address(teeVerifier)), teeBatcher, nonTeeBatcher, deployer);

inbox = new BatchInbox(IBatchAuthenticator(address(authenticator)), deployer);
}
Expand Down
Loading