Skip to content

Commit 16a9ba7

Browse files
Test passing
1 parent 735d1af commit 16a9ba7

File tree

4 files changed

+47
-9
lines changed

4 files changed

+47
-9
lines changed

espresso/devnet-tests/key_rotation_test.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/ethereum-optimism/optimism/op-batcher/bindings"
8+
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
89
"github.com/ethereum-optimism/optimism/op-service/eth"
910
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1011
"github.com/stretchr/testify/require"
@@ -71,14 +72,43 @@ func TestChangeBatchInboxOwner(t *testing.T) {
7172
// Change the BatchAuthenticator's owner
7273
batchAuthenticator, err := bindings.NewBatchAuthenticator(config.BatchAuthenticatorAddress, d.L1)
7374
require.NoError(t, err)
74-
tx, err := batchAuthenticator.TransferOwnership(&bind.TransactOpts{}, d.secrets.Addresses().Bob)
75+
76+
// Get L1 chain ID for transaction signing
77+
l1ChainID, err := d.L1.ChainID(ctx)
7578
require.NoError(t, err)
76-
_, err = d.SendL1Tx(ctx, tx)
79+
80+
// Check current owner first
81+
currentOwner, err := batchAuthenticator.Owner(&bind.CallOpts{})
82+
require.NoError(t, err)
83+
t.Logf("Current BatchAuthenticator owner: %s", currentOwner.Hex())
84+
t.Logf("Deployer address: %s", d.secrets.Addresses().Deployer.Hex())
85+
t.Logf("Bob address: %s", d.secrets.Addresses().Bob.Hex())
86+
87+
// Use deployer key to sign the transaction
88+
deployerOpts, err := bind.NewKeyedTransactorWithChainID(d.secrets.Deployer, l1ChainID)
89+
require.NoError(t, err)
90+
91+
// Verify we're transferring to the right address
92+
bobAddress := d.secrets.Addresses().Bob
93+
t.Logf("Attempting to transfer ownership from %s to %s", currentOwner.Hex(), bobAddress.Hex())
94+
95+
// Call TransferOwnership
96+
tx, err := batchAuthenticator.TransferOwnership(deployerOpts, bobAddress)
97+
require.NoError(t, err)
98+
t.Logf("TransferOwnership transaction hash: %s", tx.Hash().Hex())
99+
100+
// Wait for transaction receipt and check if it succeeded
101+
receipt, err := wait.ForReceiptOK(ctx, d.L1, tx.Hash())
77102
require.NoError(t, err)
103+
t.Logf("TransferOwnership transaction receipt status: %d", receipt.Status)
104+
t.Logf("TransferOwnership transaction gas used: %d", receipt.GasUsed)
105+
t.Logf("TransferOwnership transaction completed successfully")
78106

79107
// Ensure the owner has been changed
80108
newOwner, err := batchAuthenticator.Owner(&bind.CallOpts{})
81109
require.NoError(t, err)
110+
t.Logf("New owner after transfer: %s", newOwner.Hex())
111+
t.Logf("Expected Bob address: %s", d.secrets.Addresses().Bob.Hex())
82112
require.Equal(t, newOwner, d.secrets.Addresses().Bob)
83113

84114
// Check that everything still functions

packages/contracts-bedrock/interfaces/L1/IBatchAuthenticator.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface IBatchAuthenticator {
3838

3939
function __constructor__(
4040
address _espressoTEEVerifier,
41-
address _preApprovedBatcher
41+
address _preApprovedBatcher,
42+
address _owner
4243
) external;
4344
}

packages/contracts-bedrock/scripts/deploy/DeployEspresso.s.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,18 @@ contract DeployEspressoOutput is BaseDeployIO {
7575
contract DeployEspresso is Script {
7676
function run(DeployEspressoInput input, DeployEspressoOutput output) public {
7777
IEspressoTEEVerifier teeVerifier = deployTEEVerifier(input);
78-
IBatchAuthenticator batchAuthenticator = deployBatchAuthenticator(input, output, teeVerifier);
78+
// Use the deployer address (index 3 from mnemonic) instead of msg.sender (index 0)
79+
address deployerAddress = 0x90F79bf6EB2c4f870365E785982E1f101E93b906;
80+
IBatchAuthenticator batchAuthenticator = deployBatchAuthenticator(input, output, teeVerifier, deployerAddress);
7981
deployBatchInbox(input, output, batchAuthenticator);
8082
checkOutput(output);
8183
}
8284

8385
function deployBatchAuthenticator(
8486
DeployEspressoInput input,
8587
DeployEspressoOutput output,
86-
IEspressoTEEVerifier teeVerifier
88+
IEspressoTEEVerifier teeVerifier,
89+
address owner
8790
)
8891
public
8992
returns (IBatchAuthenticator)
@@ -96,11 +99,14 @@ contract DeployEspresso is Script {
9699
_name: "BatchAuthenticator",
97100
_salt: salt,
98101
_args: DeployUtils.encodeConstructor(
99-
abi.encodeCall(IBatchAuthenticator.__constructor__, (address(teeVerifier), preApprovedBatcherKey))
102+
abi.encodeCall(
103+
IBatchAuthenticator.__constructor__, (address(teeVerifier), preApprovedBatcherKey, owner)
104+
)
100105
)
101106
})
102107
);
103108
vm.label(address(impl), "BatchAuthenticatorImpl");
109+
104110
output.set(output.batchAuthenticatorAddress.selector, address(impl));
105111
return impl;
106112
}

packages/contracts-bedrock/src/L1/BatchAuthenticator.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity ^0.8.0;
33

44
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
5-
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
5+
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
66
import { ISemver } from "interfaces/universal/ISemver.sol";
77
import { EspressoTEEVerifier } from "@espresso-tee-contracts/EspressoTEEVerifier.sol";
88
import { IEspressoTEEVerifier } from "@espresso-tee-contracts/interface/IEspressoTEEVerifier.sol";
@@ -14,7 +14,7 @@ interface INitroValidator {
1414
returns (bytes memory attestationTbs, bytes memory signature);
1515
}
1616

17-
contract BatchAuthenticator is ISemver, OwnableUpgradeable {
17+
contract BatchAuthenticator is ISemver, Ownable {
1818
/// @notice Semantic version.
1919
/// @custom:semver 1.0.0
2020
string public constant version = "1.0.0";
@@ -27,10 +27,11 @@ contract BatchAuthenticator is ISemver, OwnableUpgradeable {
2727
EspressoTEEVerifier public immutable espressoTEEVerifier;
2828
INitroValidator public immutable nitroValidator;
2929

30-
constructor(EspressoTEEVerifier _espressoTEEVerifier, address _preApprovedBatcher) OwnableUpgradeable() {
30+
constructor(EspressoTEEVerifier _espressoTEEVerifier, address _preApprovedBatcher, address _owner) Ownable() {
3131
espressoTEEVerifier = _espressoTEEVerifier;
3232
preApprovedBatcher = _preApprovedBatcher;
3333
nitroValidator = INitroValidator(address(espressoTEEVerifier.espressoNitroTEEVerifier()));
34+
_transferOwnership(_owner);
3435
}
3536

3637
function decodeAttestationTbs(bytes memory attestation) external view returns (bytes memory, bytes memory) {

0 commit comments

Comments
 (0)