Commit dd4f5615 authored by Ethen Pociask's avatar Ethen Pociask

[indexer.l1height-param] Addressing PR comments

parent 877ecdf0
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
### Setup env ### Setup env
The `indexer.toml` stores a set of preset environmental variables that can be used to run the indexer with the exception of the network specific `l1-rpc` and `l2-rpc` variables. The `indexer.toml` file can be ran as a default config, otherwise a custom `.toml` config can provided via the `--config` flag when running the application. An optional `l1-starting-height` value can be provided to the indexer to specify the L1 starting block height to begin indexing from. This should be ideally be an L1 block that holds a correlated L2 genesis transaction. If no starting height value is provided and the database is empty, the indexer will begin sequentially processing from L1 genesis. The `indexer.toml` stores a set of preset environmental variables that can be used to run the indexer with the exception of the network specific `l1-rpc` and `l2-rpc` variables. The `indexer.toml` file can be ran as a default config, otherwise a custom `.toml` config can provided via the `--config` flag when running the application. An optional `l1-starting-height` value can be provided to the indexer to specify the L1 starting block height to begin indexing from. This should be ideally be an L1 block that holds a correlated L2 genesis commitment. Furthermore, this value must be less than the current L1 block height to pass validation. If no starting height value is provided and the database is empty, the indexer will begin sequentially processing from L1 genesis.
### Testing ### Testing
All tests can be ran by running `make test` from the `/indexer` directory. This will run all unit and e2e tests. All tests can be ran by running `make test` from the `/indexer` directory. This will run all unit and e2e tests.
......
...@@ -21,7 +21,7 @@ type L1ETL struct { ...@@ -21,7 +21,7 @@ type L1ETL struct {
// NewL1ETL creates a new L1ETL instance that will start indexing from different starting points // NewL1ETL creates a new L1ETL instance that will start indexing from different starting points
// depending on the state of the database and the supplied start height. // depending on the state of the database and the supplied start height.
func NewL1ETL(log log.Logger, db *database.DB, client node.EthClient, start *big.Int, func NewL1ETL(log log.Logger, db *database.DB, client node.EthClient, startHeight *big.Int,
contracts config.L1Contracts) (*L1ETL, error) { contracts config.L1Contracts) (*L1ETL, error) {
log = log.New("etl", "l1") log = log.New("etl", "l1")
...@@ -41,17 +41,17 @@ func NewL1ETL(log log.Logger, db *database.DB, client node.EthClient, start *big ...@@ -41,17 +41,17 @@ func NewL1ETL(log log.Logger, db *database.DB, client node.EthClient, start *big
log.Info("detected last indexed block", "number", latestHeader.Number.Int, "hash", latestHeader.Hash) log.Info("detected last indexed block", "number", latestHeader.Number.Int, "hash", latestHeader.Hash)
fromHeader = latestHeader.RLPHeader.Header() fromHeader = latestHeader.RLPHeader.Header()
} else if latestHeader != nil && latestHeader.Number.Int.Cmp(start) == 0 { } else if startHeight.BitLen() > 0 {
log.Info("no indexed state in storage, starting from L1 genesis") log.Info("no indexed state in storage, starting from supplied L1 height", "height", startHeight.String())
header, err := client.BlockHeaderByNumber(startHeight)
} else { // latestHeader == nil
log.Info("no indexed state in storage, starting from supplied L1 height", "height", start.String())
header, err := client.BlockHeaderByNumber(start)
if err != nil { if err != nil {
return nil, fmt.Errorf("could not fetch starting block header: %w", err) return nil, fmt.Errorf("could not fetch starting block header: %w", err)
} }
fromHeader = header fromHeader = header
} else {
log.Info("no indexed state in storage, starting from L1 genesis")
} }
// NOTE - The use of un-buffered channel here assumes that downstream consumers // NOTE - The use of un-buffered channel here assumes that downstream consumers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment