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
8ab7c2c1
Commit
8ab7c2c1
authored
Sep 15, 2023
by
Will Cory
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(indexer): Enable devnet indexer as a preset
parent
1c4599cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
6 deletions
+92
-6
config.go
indexer/config/config.go
+12
-6
devnet.go
indexer/config/devnet.go
+80
-0
No files found.
indexer/config/config.go
View file @
8ab7c2c1
...
@@ -140,6 +140,10 @@ type ServerConfig struct {
...
@@ -140,6 +140,10 @@ type ServerConfig struct {
Port
int
`toml:"port"`
Port
int
`toml:"port"`
}
}
var
(
DEVNET_CHAIN_ID
=
901
)
// LoadConfig loads the `indexer.toml` config file from a given path
// LoadConfig loads the `indexer.toml` config file from a given path
func
LoadConfig
(
log
log
.
Logger
,
path
string
)
(
Config
,
error
)
{
func
LoadConfig
(
log
log
.
Logger
,
path
string
)
(
Config
,
error
)
{
log
.
Debug
(
"loading config"
,
"path"
,
path
)
log
.
Debug
(
"loading config"
,
"path"
,
path
)
...
@@ -157,18 +161,20 @@ func LoadConfig(log log.Logger, path string) (Config, error) {
...
@@ -157,18 +161,20 @@ func LoadConfig(log log.Logger, path string) (Config, error) {
return
conf
,
err
return
conf
,
err
}
}
if
conf
.
Chain
.
Preset
!=
0
{
if
conf
.
Chain
.
Preset
==
DEVNET_CHAIN_ID
{
preset
,
err
:=
GetDevnetPreset
()
if
err
!=
nil
{
return
conf
,
err
}
conf
.
Chain
=
preset
.
ChainConfig
}
else
if
conf
.
Chain
.
Preset
!=
0
{
preset
,
ok
:=
Presets
[
conf
.
Chain
.
Preset
]
preset
,
ok
:=
Presets
[
conf
.
Chain
.
Preset
]
if
!
ok
{
if
!
ok
{
return
conf
,
fmt
.
Errorf
(
"unknown preset: %d"
,
conf
.
Chain
.
Preset
)
return
conf
,
fmt
.
Errorf
(
"unknown preset: %d"
,
conf
.
Chain
.
Preset
)
}
}
log
.
Info
(
"detected preset"
,
"preset"
,
conf
.
Chain
.
Preset
,
"name"
,
preset
.
Name
)
log
.
Info
(
"detected preset"
,
"preset"
,
conf
.
Chain
.
Preset
,
"name"
,
preset
.
Name
)
log
.
Info
(
"setting L1 information from preset"
)
log
.
Info
(
"setting L1 information from preset"
)
conf
.
Chain
.
L1Contracts
=
preset
.
ChainConfig
.
L1Contracts
conf
.
Chain
=
preset
.
ChainConfig
conf
.
Chain
.
L1StartingHeight
=
preset
.
ChainConfig
.
L1StartingHeight
conf
.
Chain
.
L1BedrockStartingHeight
=
preset
.
ChainConfig
.
L1BedrockStartingHeight
conf
.
Chain
.
L2BedrockStartingHeight
=
preset
.
ChainConfig
.
L1BedrockStartingHeight
}
}
// Setup L2Contracts from predeploys
// Setup L2Contracts from predeploys
...
...
indexer/config/devnet.go
0 → 100644
View file @
8ab7c2c1
package
config
import
(
"encoding/json"
"io/ioutil"
"os"
"github.com/ethereum/go-ethereum/common"
)
type
ethereumContracts
struct
{
AddressManager
string
`json:"AddressManager"`
BlockOracle
string
`json:"BlockOracle"`
DisputeGameFactory
string
`json:"DisputeGameFactory"`
DisputeGameFactoryProxy
string
`json:"DisputeGameFactoryProxy"`
L1CrossDomainMessenger
string
`json:"L1CrossDomainMessenger"`
L1CrossDomainMessengerProxy
string
`json:"L1CrossDomainMessengerProxy"`
L1ERC721Bridge
string
`json:"L1ERC721Bridge"`
L1ERC721BridgeProxy
string
`json:"L1ERC721BridgeProxy"`
L1StandardBridge
string
`json:"L1StandardBridge"`
L1StandardBridgeProxy
string
`json:"L1StandardBridgeProxy"`
L2OutputOracle
string
`json:"L2OutputOracle"`
L2OutputOracleProxy
string
`json:"L2OutputOracleProxy"`
Mips
string
`json:"Mips"`
OptimismMintableERC20Factory
string
`json:"OptimismMintableERC20Factory"`
OptimismMintableERC20FactoryProxy
string
`json:"OptimismMintableERC20FactoryProxy"`
OptimismPortal
string
`json:"OptimismPortal"`
OptimismPortalProxy
string
`json:"OptimismPortalProxy"`
PreimageOracle
string
`json:"PreimageOracle"`
ProxyAdmin
string
`json:"ProxyAdmin"`
SystemConfig
string
`json:"SystemConfig"`
SystemConfigProxy
string
`json:"SystemConfigProxy"`
}
func
readEthereumContracts
(
filename
string
)
(
*
ethereumContracts
,
error
)
{
// Check if the file exists
if
_
,
err
:=
os
.
Stat
(
filename
);
os
.
IsNotExist
(
err
)
{
return
nil
,
err
}
// Read the file
content
,
err
:=
ioutil
.
ReadFile
(
filename
)
if
err
!=
nil
{
return
nil
,
err
}
// Unmarshal the JSON
var
contracts
ethereumContracts
if
err
:=
json
.
Unmarshal
(
content
,
&
contracts
);
err
!=
nil
{
return
nil
,
err
}
return
&
contracts
,
nil
}
func
GetDevnetPreset
()
(
*
Preset
,
error
)
{
ethereumContracts
,
err
:=
readEthereumContracts
(
"../.devnet/addresses.json"
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
Preset
{
Name
:
"devnet"
,
ChainConfig
:
ChainConfig
{
L1StartingHeight
:
0
,
L1BedrockStartingHeight
:
0
,
L2BedrockStartingHeight
:
0
,
L1Contracts
:
L1Contracts
{
AddressManager
:
common
.
HexToAddress
(
ethereumContracts
.
AddressManager
),
SystemConfigProxy
:
common
.
HexToAddress
(
ethereumContracts
.
SystemConfigProxy
),
OptimismPortalProxy
:
common
.
HexToAddress
(
ethereumContracts
.
OptimismPortalProxy
),
L2OutputOracleProxy
:
common
.
HexToAddress
(
ethereumContracts
.
L2OutputOracleProxy
),
L1CrossDomainMessengerProxy
:
common
.
HexToAddress
(
ethereumContracts
.
L1CrossDomainMessengerProxy
),
L1StandardBridgeProxy
:
common
.
HexToAddress
(
ethereumContracts
.
L1StandardBridgeProxy
),
L1ERC721BridgeProxy
:
common
.
HexToAddress
(
ethereumContracts
.
L1ERC721BridgeProxy
),
LegacyCanonicalTransactionChain
:
common
.
HexToAddress
(
"0x0"
),
LegacyStateCommitmentChain
:
common
.
HexToAddress
(
"0x0"
),
},
},
},
nil
}
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