Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdiallam committed Jul 17, 2024
1 parent 68154b4 commit e7e5f0a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 39 deletions.
5 changes: 2 additions & 3 deletions anvil/anvil.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"

"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
)

var _ config.Chain = &Anvil{}
Expand All @@ -34,7 +33,7 @@ type Config struct {
config.ChainConfig

// only applicable when ForkConfig is not set
Genesis []byte
Genesis []byte
}

type Anvil struct {
Expand Down
38 changes: 19 additions & 19 deletions config/chain.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package config

import (
"context"
"fmt"
"context"
"strings"

"github.com/ethereum-optimism/supersim/hdaccount"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum"
)

var (
Expand All @@ -20,23 +20,23 @@ var (
}

DefaultChainConfigs = []ChainConfig{
{
Name: "SourceChain",
ChainID: 1,
SecretsConfig: DefaultSecretsConfig,
},
{
Name: "OPChainA",
ChainID: 10,
SourceChainID: 1,
SecretsConfig: DefaultSecretsConfig,
},
{
Name: "OPChainB",
ChainID: 30,
SourceChainID: 1,
SecretsConfig: DefaultSecretsConfig,
},
{
Name: "SourceChain",
ChainID: 1,
SecretsConfig: DefaultSecretsConfig,
},
{
Name: "OPChainA",
ChainID: 10,
SourceChainID: 1,
SecretsConfig: DefaultSecretsConfig,
},
{
Name: "OPChainB",
ChainID: 30,
SourceChainID: 1,
SecretsConfig: DefaultSecretsConfig,
},
}
)

Expand Down
22 changes: 11 additions & 11 deletions orchestrator/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

const blockTime = 2

func ChainConfigsFromForkCLIConfig(cfg *config.ForkCLIConfig) ([]config.ChainConfig, error) {
superchain := registry.Superchains[cfg.Network]
func ChainConfigsFromForkCLIConfig(forkConfig *config.ForkCLIConfig) ([]config.ChainConfig, error) {
superchain := registry.Superchains[forkConfig.Network]
chainConfigs := []config.ChainConfig{}

// L1
Expand All @@ -25,18 +25,18 @@ func ChainConfigsFromForkCLIConfig(cfg *config.ForkCLIConfig) ([]config.ChainCon
}

var l1ForkHeight *big.Int
if cfg.L1ForkHeight > 0 {
l1ForkHeight = new(big.Int).SetUint64(cfg.L1ForkHeight)
if forkConfig.L1ForkHeight > 0 {
l1ForkHeight = new(big.Int).SetUint64(forkConfig.L1ForkHeight)
}
l1Header, err := l1Client.HeaderByNumber(context.Background(), l1ForkHeight)
if err != nil {
return nil, fmt.Errorf("failed to retrieve L1 header: %w", err)
}

chainConfigs = append(chainConfigs, config.ChainConfig{
Port: 0,
Name: cfg.Network,
ChainID: superchain.Config.L1.ChainID,
Name: forkConfig.Network,
Port: 0,
ChainID: superchain.Config.L1.ChainID,
SecretsConfig: config.DefaultSecretsConfig,
ForkConfig: &config.ForkConfig{
RPCUrl: superchain.Config.L1.PublicRPC,
Expand All @@ -45,17 +45,17 @@ func ChainConfigsFromForkCLIConfig(cfg *config.ForkCLIConfig) ([]config.ChainCon
})

// L2s
for _, chain := range cfg.Chains {
for _, chain := range forkConfig.Chains {
chainCfg := registry.OPChains[config.OpChainToId[chain]]
l2ForkHeight, err := latestL2HeightFromL1Header(chainCfg, l1Header)
if err != nil {
return nil, fmt.Errorf("failed to find right l2 height: %w", err)
}

chainConfigs = append(chainConfigs, config.ChainConfig{
Name: chainCfg.Chain,
ChainID: chainCfg.ChainID,
SourceChainID: superchain.Config.L1.ChainID,
Name: chainCfg.Chain,
ChainID: chainCfg.ChainID,
SourceChainID: superchain.Config.L1.ChainID,
SecretsConfig: config.DefaultSecretsConfig,
ForkConfig: &config.ForkConfig{
RPCUrl: chainCfg.PublicRPC,
Expand Down
2 changes: 1 addition & 1 deletion orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewOrchestrator(log log.Logger, chainConfigs []config.ChainConfig) (*Orches
for _, chainConfig := range chainConfigs {
anvilConfig := &anvil.Config{ChainConfig: chainConfig}
if chainConfig.SourceChainID != 0 {
anvilConfig.Port = 0 // internally allocate anvil port as op-simulator port is exposed externally
anvilConfig.Port = 0 // internally allocate anvil port as op-simulator port is exposed externally
}

// Apply genesis if not forking from a live network
Expand Down
4 changes: 2 additions & 2 deletions orchestrator/orchestrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

type TestSuite struct {
t *testing.T
t *testing.T
orchestrator *Orchestrator
}

Expand Down Expand Up @@ -53,7 +53,7 @@ func TestStartup(t *testing.T) {
}

func TestTooManyL1sError(t *testing.T) {
chainConfigs := []config. ChainConfig{
chainConfigs := []config.ChainConfig{
{ChainID: 1, Port: 0},
{ChainID: 10, Port: 0},
{ChainID: 30, SourceChainID: 1, Port: 0},
Expand Down
5 changes: 2 additions & 3 deletions supersim.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package supersim

import (
"context"
"fmt"
"strings"
"context"

registry "github.com/ethereum-optimism/superchain-registry/superchain"

"github.com/ethereum-optimism/supersim/config"
"github.com/ethereum-optimism/supersim/orchestrator"

"github.com/ethereum/go-ethereum/log"
)

type Supersim struct {
log log.Logger
log log.Logger
Orchestrator *orchestrator.Orchestrator
}

Expand Down

0 comments on commit e7e5f0a

Please sign in to comment.