Skip to content

Commit

Permalink
Sim: permission enclaveID for sequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel committed Dec 17, 2024
1 parent 7141014 commit 8d1cfef
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions integration/simulation/network/geth_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions integration/simulation/network/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8d1cfef

Please sign in to comment.