From 955c112f4031d1b3ef2caf9354e8a2e29de583c5 Mon Sep 17 00:00:00 2001 From: Matt <98158711+BedrockSquirrel@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:23:06 +0000 Subject: [PATCH] Sim: permission enclaveID for sequencer (#2212) --- integration/simulation/network/geth_utils.go | 24 ++++++++++++++++++++ integration/simulation/network/socket.go | 14 ++++++++++++ 2 files changed, 38 insertions(+) diff --git a/integration/simulation/network/geth_utils.go b/integration/simulation/network/geth_utils.go index 99a03954c9..f0803a5806 100644 --- a/integration/simulation/network/geth_utils.go +++ b/integration/simulation/network/geth_utils.go @@ -149,6 +149,30 @@ func DeployTenNetworkContracts(client ethadapter.EthClient, wallets *params.SimW }, nil } +func PermissionTenSequencerEnclave(mcOwner wallet.Wallet, client ethadapter.EthClient, mcAddress common.Address, seqEnclaveID common.Address) error { + ctr, err := ManagementContract.NewManagementContract(mcAddress, client.EthClient()) + if err != nil { + return err + } + + opts, err := bind.NewKeyedTransactorWithChainID(mcOwner.PrivateKey(), mcOwner.ChainID()) + if err != nil { + return err + } + + tx, err := ctr.GrantSequencerEnclave(opts, seqEnclaveID) + if err != nil { + return err + } + + _, err = integrationCommon.AwaitReceiptEth(context.Background(), client.EthClient(), tx.Hash(), 25*time.Second) + if err != nil { + return err + } + + return nil +} + func StopEth2Network(clients []ethadapter.EthClient, network eth2network.PosEth2Network) { // Stop the clients first for _, c := range clients { diff --git a/integration/simulation/network/socket.go b/integration/simulation/network/socket.go index 20afad5572..2e79d4fca5 100644 --- a/integration/simulation/network/socket.go +++ b/integration/simulation/network/socket.go @@ -147,6 +147,20 @@ func (n *networkOfSocketNodes) Create(simParams *params.SimParams, _ *stats.Stat } walletClients := createAuthClientsPerWallet(n.l2Clients, simParams.Wallets) + // permission the sequencer enclaveID + seqHealth, err := n.tenClients[0].Health() + if err != nil { + return nil, fmt.Errorf("unable to get sequencer enclaveID: %w", err) + } + if seqHealth.Enclaves == nil || len(seqHealth.Enclaves) == 0 { + return nil, fmt.Errorf("no enclaves found in health response") + } + seqEnclaveID := seqHealth.Enclaves[0].EnclaveID + err = PermissionTenSequencerEnclave(n.wallets.MCOwnerWallet, n.gethClients[0], simParams.L1TenData.MgmtContractAddress, seqEnclaveID) + if err != nil { + return nil, fmt.Errorf("unable to permission sequencer enclaveID: %w", err) + } + return &RPCHandles{ EthClients: n.gethClients, TenClients: n.tenClients,