Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
aeeb1927
Unverified
Commit
aeeb1927
authored
Sep 05, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-e2e: Move geth init utils to e2eutils
parent
882e8011
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
43 deletions
+20
-43
fakepos.go
op-e2e/e2eutils/geth/fakepos.go
+1
-1
geth.go
op-e2e/e2eutils/geth/geth.go
+9
-33
l2_gossip_test.go
op-e2e/l2_gossip_test.go
+1
-1
op_geth.go
op-e2e/op_geth.go
+2
-1
setup.go
op-e2e/setup.go
+4
-4
system_test.go
op-e2e/system_test.go
+3
-3
No files found.
op-e2e/fakepos.go
→
op-e2e/
e2eutils/geth/
fakepos.go
View file @
aeeb1927
package
op_e2e
package
geth
import
(
import
(
"time"
"time"
...
...
op-e2e/geth.go
→
op-e2e/
e2eutils/geth/
geth.go
View file @
aeeb1927
package
op_e2e
package
geth
import
(
import
(
"crypto/ecdsa"
"fmt"
"fmt"
"math/big"
"math/big"
"github.com/ethereum-optimism/optimism/op-service/clock"
"github.com/ethereum-optimism/optimism/op-service/clock"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
...
@@ -23,9 +21,9 @@ import (
...
@@ -23,9 +21,9 @@ import (
_
"github.com/ethereum/go-ethereum/eth/tracers/native"
_
"github.com/ethereum/go-ethereum/eth/tracers/native"
)
)
func
initL1Geth
(
cfg
*
SystemConfig
,
genesis
*
core
.
Genesis
,
c
clock
.
Clock
,
opts
...
GethOption
)
(
*
node
.
Node
,
*
eth
.
Ethereum
,
error
)
{
func
InitL1
(
chainID
uint64
,
blockTime
uint64
,
genesis
*
core
.
Genesis
,
c
clock
.
Clock
,
opts
...
GethOption
)
(
*
node
.
Node
,
*
eth
.
Ethereum
,
error
)
{
ethConfig
:=
&
ethconfig
.
Config
{
ethConfig
:=
&
ethconfig
.
Config
{
NetworkId
:
c
fg
.
DeployConfig
.
L1C
hainID
,
NetworkId
:
chainID
,
Genesis
:
genesis
,
Genesis
:
genesis
,
}
}
nodeConfig
:=
&
node
.
Config
{
nodeConfig
:=
&
node
.
Config
{
...
@@ -38,7 +36,7 @@ func initL1Geth(cfg *SystemConfig, genesis *core.Genesis, c clock.Clock, opts ..
...
@@ -38,7 +36,7 @@ func initL1Geth(cfg *SystemConfig, genesis *core.Genesis, c clock.Clock, opts ..
HTTPModules
:
[]
string
{
"debug"
,
"admin"
,
"eth"
,
"txpool"
,
"net"
,
"rpc"
,
"web3"
,
"personal"
,
"engine"
},
HTTPModules
:
[]
string
{
"debug"
,
"admin"
,
"eth"
,
"txpool"
,
"net"
,
"rpc"
,
"web3"
,
"personal"
,
"engine"
},
}
}
l1Node
,
l1Eth
,
err
:=
createGethNode
(
false
,
nodeConfig
,
ethConfig
,
[]
*
ecdsa
.
PrivateKey
{
cfg
.
Secrets
.
CliqueSigner
},
opts
...
)
l1Node
,
l1Eth
,
err
:=
createGethNode
(
false
,
nodeConfig
,
ethConfig
,
opts
...
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
@@ -50,7 +48,7 @@ func initL1Geth(cfg *SystemConfig, genesis *core.Genesis, c clock.Clock, opts ..
...
@@ -50,7 +48,7 @@ func initL1Geth(cfg *SystemConfig, genesis *core.Genesis, c clock.Clock, opts ..
clock
:
c
,
clock
:
c
,
eth
:
l1Eth
,
eth
:
l1Eth
,
log
:
log
.
Root
(),
// geth logger is global anyway. Would be nice to replace with a local logger though.
log
:
log
.
Root
(),
// geth logger is global anyway. Would be nice to replace with a local logger though.
blockTime
:
cfg
.
DeployConfig
.
L1B
lockTime
,
blockTime
:
b
lockTime
,
// for testing purposes we make it really fast, otherwise we don't see it finalize in short tests
// for testing purposes we make it really fast, otherwise we don't see it finalize in short tests
finalizedDistance
:
8
,
finalizedDistance
:
8
,
safeDistance
:
4
,
safeDistance
:
4
,
...
@@ -77,8 +75,8 @@ func defaultNodeConfig(name string, jwtPath string) *node.Config {
...
@@ -77,8 +75,8 @@ func defaultNodeConfig(name string, jwtPath string) *node.Config {
type
GethOption
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
type
GethOption
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
//
init a
geth node.
//
InitL2 inits a L2
geth node.
func
initL2Geth
(
name
string
,
l2ChainID
*
big
.
Int
,
genesis
*
core
.
Genesis
,
jwtPath
string
,
opts
...
GethOption
)
(
*
node
.
Node
,
*
eth
.
Ethereum
,
error
)
{
func
InitL2
(
name
string
,
l2ChainID
*
big
.
Int
,
genesis
*
core
.
Genesis
,
jwtPath
string
,
opts
...
GethOption
)
(
*
node
.
Node
,
*
eth
.
Ethereum
,
error
)
{
ethConfig
:=
&
ethconfig
.
Config
{
ethConfig
:=
&
ethconfig
.
Config
{
NetworkId
:
l2ChainID
.
Uint64
(),
NetworkId
:
l2ChainID
.
Uint64
(),
Genesis
:
genesis
,
Genesis
:
genesis
,
...
@@ -93,14 +91,14 @@ func initL2Geth(name string, l2ChainID *big.Int, genesis *core.Genesis, jwtPath
...
@@ -93,14 +91,14 @@ func initL2Geth(name string, l2ChainID *big.Int, genesis *core.Genesis, jwtPath
},
},
}
}
nodeConfig
:=
defaultNodeConfig
(
fmt
.
Sprintf
(
"l2-geth-%v"
,
name
),
jwtPath
)
nodeConfig
:=
defaultNodeConfig
(
fmt
.
Sprintf
(
"l2-geth-%v"
,
name
),
jwtPath
)
return
createGethNode
(
true
,
nodeConfig
,
ethConfig
,
nil
,
opts
...
)
return
createGethNode
(
true
,
nodeConfig
,
ethConfig
,
opts
...
)
}
}
// createGethNode creates an in-memory geth node based on the configuration.
// createGethNode creates an in-memory geth node based on the configuration.
// The private keys are added to the keystore and are unlocked.
// The private keys are added to the keystore and are unlocked.
// If the node is l2, catalyst is enabled.
// If the node is l2, catalyst is enabled.
// The node should be started and then closed when done.
// The node should be started and then closed when done.
func
createGethNode
(
l2
bool
,
nodeCfg
*
node
.
Config
,
ethCfg
*
ethconfig
.
Config
,
privateKeys
[]
*
ecdsa
.
PrivateKey
,
opts
...
GethOption
)
(
*
node
.
Node
,
*
eth
.
Ethereum
,
error
)
{
func
createGethNode
(
l2
bool
,
nodeCfg
*
node
.
Config
,
ethCfg
*
ethconfig
.
Config
,
opts
...
GethOption
)
(
*
node
.
Node
,
*
eth
.
Ethereum
,
error
)
{
for
i
,
opt
:=
range
opts
{
for
i
,
opt
:=
range
opts
{
if
err
:=
opt
(
ethCfg
,
nodeCfg
);
err
!=
nil
{
if
err
:=
opt
(
ethCfg
,
nodeCfg
);
err
!=
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"failed to apply geth option %d: %w"
,
i
,
err
)
return
nil
,
nil
,
fmt
.
Errorf
(
"failed to apply geth option %d: %w"
,
i
,
err
)
...
@@ -113,28 +111,6 @@ func createGethNode(l2 bool, nodeCfg *node.Config, ethCfg *ethconfig.Config, pri
...
@@ -113,28 +111,6 @@ func createGethNode(l2 bool, nodeCfg *node.Config, ethCfg *ethconfig.Config, pri
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
if
!
l2
{
keydir
:=
n
.
KeyStoreDir
()
scryptN
:=
2
scryptP
:=
1
n
.
AccountManager
()
.
AddBackend
(
keystore
.
NewKeyStore
(
keydir
,
scryptN
,
scryptP
))
ks
:=
n
.
AccountManager
()
.
Backends
(
keystore
.
KeyStoreType
)[
0
]
.
(
*
keystore
.
KeyStore
)
password
:=
"foobar"
for
_
,
pk
:=
range
privateKeys
{
act
,
err
:=
ks
.
ImportECDSA
(
pk
,
password
)
if
err
!=
nil
{
n
.
Close
()
return
nil
,
nil
,
err
}
err
=
ks
.
Unlock
(
act
,
password
)
if
err
!=
nil
{
n
.
Close
()
return
nil
,
nil
,
err
}
}
}
backend
,
err
:=
eth
.
New
(
n
,
ethCfg
)
backend
,
err
:=
eth
.
New
(
n
,
ethCfg
)
if
err
!=
nil
{
if
err
!=
nil
{
n
.
Close
()
n
.
Close
()
...
...
op-e2e/l2_gossip_test.go
View file @
aeeb1927
...
@@ -11,7 +11,7 @@ import (
...
@@ -11,7 +11,7 @@ import (
func
TestTxGossip
(
t
*
testing
.
T
)
{
func
TestTxGossip
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
InitParallel
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
gethOpts
:=
[]
GethOption
{
gethOpts
:=
[]
geth
.
GethOption
{
geth
.
WithP2P
(),
geth
.
WithP2P
(),
}
}
cfg
.
GethOptions
[
"sequencer"
]
=
gethOpts
cfg
.
GethOptions
[
"sequencer"
]
=
gethOpts
...
...
op-e2e/op_geth.go
View file @
aeeb1927
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/geth"
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
...
@@ -72,7 +73,7 @@ func NewOpGeth(t *testing.T, ctx context.Context, cfg *SystemConfig) (*OpGeth, e
...
@@ -72,7 +73,7 @@ func NewOpGeth(t *testing.T, ctx context.Context, cfg *SystemConfig) (*OpGeth, e
SystemConfig
:
e2eutils
.
SystemConfigFromDeployConfig
(
cfg
.
DeployConfig
),
SystemConfig
:
e2eutils
.
SystemConfigFromDeployConfig
(
cfg
.
DeployConfig
),
}
}
node
,
_
,
err
:=
initL2Geth
(
"l2"
,
big
.
NewInt
(
int64
(
cfg
.
DeployConfig
.
L2ChainID
)),
l2Genesis
,
cfg
.
JWTFilePath
)
node
,
_
,
err
:=
geth
.
InitL2
(
"l2"
,
big
.
NewInt
(
int64
(
cfg
.
DeployConfig
.
L2ChainID
)),
l2Genesis
,
cfg
.
JWTFilePath
)
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
node
.
Start
())
require
.
Nil
(
t
,
node
.
Start
())
...
...
op-e2e/setup.go
View file @
aeeb1927
...
@@ -139,7 +139,7 @@ func DefaultSystemConfig(t *testing.T) SystemConfig {
...
@@ -139,7 +139,7 @@ func DefaultSystemConfig(t *testing.T) SystemConfig {
"batcher"
:
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
.
New
(
"role"
,
"batcher"
),
"batcher"
:
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
.
New
(
"role"
,
"batcher"
),
"proposer"
:
testlog
.
Logger
(
t
,
log
.
LvlCrit
)
.
New
(
"role"
,
"proposer"
),
"proposer"
:
testlog
.
Logger
(
t
,
log
.
LvlCrit
)
.
New
(
"role"
,
"proposer"
),
},
},
GethOptions
:
map
[
string
][]
GethOption
{},
GethOptions
:
map
[
string
][]
geth
.
GethOption
{},
P2PTopology
:
nil
,
// no P2P connectivity by default
P2PTopology
:
nil
,
// no P2P connectivity by default
NonFinalizedProposals
:
false
,
NonFinalizedProposals
:
false
,
ExternalL2Shim
:
config
.
ExternalL2Shim
,
ExternalL2Shim
:
config
.
ExternalL2Shim
,
...
@@ -174,7 +174,7 @@ type SystemConfig struct {
...
@@ -174,7 +174,7 @@ type SystemConfig struct {
Premine
map
[
common
.
Address
]
*
big
.
Int
Premine
map
[
common
.
Address
]
*
big
.
Int
Nodes
map
[
string
]
*
rollupNode
.
Config
// Per node config. Don't use populate rollup.Config
Nodes
map
[
string
]
*
rollupNode
.
Config
// Per node config. Don't use populate rollup.Config
Loggers
map
[
string
]
log
.
Logger
Loggers
map
[
string
]
log
.
Logger
GethOptions
map
[
string
][]
GethOption
GethOptions
map
[
string
][]
geth
.
GethOption
ProposerLogger
log
.
Logger
ProposerLogger
log
.
Logger
BatcherLogger
log
.
Logger
BatcherLogger
log
.
Logger
...
@@ -425,7 +425,7 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste
...
@@ -425,7 +425,7 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste
sys
.
RollupConfig
=
&
defaultConfig
sys
.
RollupConfig
=
&
defaultConfig
// Initialize nodes
// Initialize nodes
l1Node
,
l1Backend
,
err
:=
initL1Geth
(
&
cfg
,
l1Genesis
,
c
,
cfg
.
GethOptions
[
"l1"
]
...
)
l1Node
,
l1Backend
,
err
:=
geth
.
InitL1
(
cfg
.
DeployConfig
.
L1ChainID
,
cfg
.
DeployConfig
.
L1BlockTime
,
l1Genesis
,
c
,
cfg
.
GethOptions
[
"l1"
]
...
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -442,7 +442,7 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste
...
@@ -442,7 +442,7 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste
for
name
:=
range
cfg
.
Nodes
{
for
name
:=
range
cfg
.
Nodes
{
var
ethClient
EthInstance
var
ethClient
EthInstance
if
cfg
.
ExternalL2Shim
==
""
{
if
cfg
.
ExternalL2Shim
==
""
{
node
,
backend
,
err
:=
initL2Geth
(
name
,
big
.
NewInt
(
int64
(
cfg
.
DeployConfig
.
L2ChainID
)),
l2Genesis
,
cfg
.
JWTFilePath
,
cfg
.
GethOptions
[
name
]
...
)
node
,
backend
,
err
:=
geth
.
InitL2
(
name
,
big
.
NewInt
(
int64
(
cfg
.
DeployConfig
.
L2ChainID
)),
l2Genesis
,
cfg
.
JWTFilePath
,
cfg
.
GethOptions
[
name
]
...
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
op-e2e/system_test.go
View file @
aeeb1927
...
@@ -260,14 +260,14 @@ func TestPendingGasLimit(t *testing.T) {
...
@@ -260,14 +260,14 @@ func TestPendingGasLimit(t *testing.T) {
// configure the L2 gas limit to be high, and the pending gas limits to be lower for resource saving.
// configure the L2 gas limit to be high, and the pending gas limits to be lower for resource saving.
cfg
.
DeployConfig
.
L2GenesisBlockGasLimit
=
30
_000_000
cfg
.
DeployConfig
.
L2GenesisBlockGasLimit
=
30
_000_000
cfg
.
GethOptions
[
"sequencer"
]
=
[]
GethOption
{
cfg
.
GethOptions
[
"sequencer"
]
=
[]
geth
.
GethOption
{
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
{
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
{
ethCfg
.
Miner
.
GasCeil
=
10
_000_000
ethCfg
.
Miner
.
GasCeil
=
10
_000_000
ethCfg
.
Miner
.
RollupComputePendingBlock
=
true
ethCfg
.
Miner
.
RollupComputePendingBlock
=
true
return
nil
return
nil
},
},
}
}
cfg
.
GethOptions
[
"verifier"
]
=
[]
GethOption
{
cfg
.
GethOptions
[
"verifier"
]
=
[]
geth
.
GethOption
{
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
{
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
{
ethCfg
.
Miner
.
GasCeil
=
9
_000_000
ethCfg
.
Miner
.
GasCeil
=
9
_000_000
ethCfg
.
Miner
.
RollupComputePendingBlock
=
true
ethCfg
.
Miner
.
RollupComputePendingBlock
=
true
...
@@ -701,7 +701,7 @@ func TestSystemP2PAltSync(t *testing.T) {
...
@@ -701,7 +701,7 @@ func TestSystemP2PAltSync(t *testing.T) {
},
},
}
}
configureL1
(
syncNodeCfg
,
sys
.
EthInstances
[
"l1"
])
configureL1
(
syncNodeCfg
,
sys
.
EthInstances
[
"l1"
])
syncerL2Engine
,
_
,
err
:=
initL2Geth
(
"syncer"
,
big
.
NewInt
(
int64
(
cfg
.
DeployConfig
.
L2ChainID
)),
sys
.
L2GenesisCfg
,
cfg
.
JWTFilePath
)
syncerL2Engine
,
_
,
err
:=
geth
.
InitL2
(
"syncer"
,
big
.
NewInt
(
int64
(
cfg
.
DeployConfig
.
L2ChainID
)),
sys
.
L2GenesisCfg
,
cfg
.
JWTFilePath
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
syncerL2Engine
.
Start
())
require
.
NoError
(
t
,
syncerL2Engine
.
Start
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment