Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(evmindexer): improve logging #1118

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions backend/cmd/evm_node_indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ func Run() {

// check config
{
log.InfoWithFields(log.Fields{"config": *configPath, "version": version.Version, "commit": version.GitCommit, "chainName": utils.Config.Chain.ClConfig.ConfigName}, "starting")
cfg := &types.Config{}
err := utils.ReadConfig(cfg, *configPath)
if err != nil {
Expand All @@ -167,6 +166,7 @@ func Run() {
log.Info("reading config completed")
}
utils.Config = cfg
log.InfoWithFields(log.Fields{"config": *configPath, "version": version.Version, "commit": version.GitCommit, "chainName": utils.Config.Chain.ClConfig.ConfigName}, "starting")

if len(utils.Config.Eth1ErigonEndpoint) > 0 {
eth1RpcEndpoint = utils.Config.Eth1ErigonEndpoint
Expand Down Expand Up @@ -270,14 +270,26 @@ func Run() {
if chainID != utils.Config.Chain.Id { // if the chain id is removed from the config, just remove this if, there is no point, except checking consistency
log.Fatal(err, "node chain different from config chain", 0) // fatal, config doesn't match node
}
log.Info("...check chain id done.")
log.InfoWithFields(log.Fields{"chainId": utils.Config.Chain.Id, "eth1RpcEndpoint": eth1RpcEndpoint, "bt.project": utils.Config.Bigtable.Project, "bt.instance": utils.Config.Bigtable.Instance}, "...check chain id done.")
}

// get latest block (as it's global, so we have a initial value)
log.Info("get latest block from node...")
updateBlockNumber(true, *noNewBlocks, time.Duration(*noNewBlocksThresholdSeconds)*time.Second, discordWebhookReportUrl, discordWebhookUser, discordWebhookAddTextFatal)
log.Infof("...get latest block (%s) from node done.", _formatInt64(currentNodeBlockNumber.Load()))

go func() {
for {
latestPGBlock, err := psqlGetLatestBlock(false)
if err != nil {
log.Fatal(err, "error while using psqlGetLatestBlock (start / read)", 0) // fatal, as if there is no initial value, we have nothing to start from
}

sendMessage(fmt.Sprintf("evmindexer for %s, version: %v, lastNodeBlock: %v, lastDbBlock: %v", getChainNamePretty(), version.Version, currentNodeBlockNumber.Load(), latestPGBlock), discordWebhookReportUrl, discordWebhookUser)
time.Sleep(time.Hour)
}
}()

// //////////////////////////////////////////
// Config done, now actually "doing" stuff //
// //////////////////////////////////////////
Expand Down
Loading