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

(NOBIDS) eth1indexer: move ens-importing its own go-routine #2932

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
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
24 changes: 16 additions & 8 deletions cmd/eth1indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ func main() {
}()
}

if *enableEnsUpdater {
go ImportEnsUpdatesLoop(bt, client, *ensBatchSize)
}

if *enableFullBalanceUpdater {
ProcessMetadataUpdates(bt, client, balanceUpdaterPrefix, *balanceUpdaterBatchSize, -1)
return
Expand Down Expand Up @@ -378,21 +382,25 @@ func main() {
ProcessMetadataUpdates(bt, client, balanceUpdaterPrefix, *balanceUpdaterBatchSize, 10)
}

if *enableEnsUpdater {
err := bt.ImportEnsUpdates(client.GetNativeClient(), *ensBatchSize)
if err != nil {
utils.LogError(err, "error importing ens updates", 0, nil)
continue
}
}

logrus.Infof("index run completed")
services.ReportStatus("eth1indexer", "Running", nil)
}

// utils.WaitForCtrlC()
}

func ImportEnsUpdatesLoop(bt *db.Bigtable, client *rpc.ErigonClient, batchSize int64) {
for {
time.Sleep(time.Second * 5)
err := bt.ImportEnsUpdates(client.GetNativeClient(), batchSize)
if err != nil {
logrus.WithError(err).Errorf("error importing ens updates")
} else {
services.ReportStatus("ensIndexer", "Running", nil)
}
}
}

func UpdateTokenPrices(bt *db.Bigtable, client *rpc.ErigonClient, tokenListPath string) error {

tokenListContent, err := os.ReadFile(tokenListPath)
Expand Down
23 changes: 11 additions & 12 deletions db/ens.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/gobitfly/eth2-beaconchain-explorer/metrics"
"github.com/gobitfly/eth2-beaconchain-explorer/types"
"github.com/gobitfly/eth2-beaconchain-explorer/utils"
"github.com/sirupsen/logrus"

gcp_bigtable "cloud.google.com/go/bigtable"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -439,7 +438,7 @@ func validateEnsAddress(client *ethclient.Client, address common.Address, alread
err.Error() == "no resolution" ||
err.Error() == "execution reverted" ||
strings.HasPrefix(err.Error(), "name is not valid") {
logger.Warnf("reverse resolving address [%v] resulted in a skippable error [%s], skipping it", address, err.Error())
// logger.Warnf("reverse resolving address [%v] resulted in a skippable error [%s], skipping it", address, err.Error())
} else {
return fmt.Errorf("error could not reverse resolve address [%v]: %w", address, err)
}
Expand Down Expand Up @@ -478,7 +477,7 @@ func validateEnsName(client *ethclient.Client, name string, alreadyChecked *EnsC

nameHash, err := go_ens.NameHash(name)
if err != nil {
logger.Warnf("error could not hash name [%v]: %v -> removing ens entry", name, err)
// logger.Warnf("error could not hash name [%v]: %v -> removing ens entry", name, err)
err = removeEnsName(client, name)
if err != nil {
return fmt.Errorf("error removing ens name [%v]: %w", name, err)
Expand All @@ -491,12 +490,12 @@ func validateEnsName(client *ethclient.Client, name string, alreadyChecked *EnsC
if err.Error() == "unregistered name" ||
err.Error() == "no address" ||
err.Error() == "no resolver" ||
err.Error() == "abi: attempting to unmarshall an empty string while arguments are expected" ||
err.Error() == "abi: attempting to unmarshal an empty string while arguments are expected" ||
strings.Contains(err.Error(), "execution reverted") ||
err.Error() == "invalid jump destination" ||
err.Error() == "invalid opcode: INVALID" {
// the given name is not available anymore or resolving it did not work properly => we can remove it from the db (if it is there)
logger.WithField("error", err).WithField("name", name).Warnf("could not resolve name")
// logger.WithField("error", err).WithField("name", name).Warnf("could not resolve name")
err = removeEnsName(client, name)
if err != nil {
return fmt.Errorf("error removing ens name after resolve failed [%v]: %w", name, err)
Expand Down Expand Up @@ -532,7 +531,7 @@ func validateEnsName(client *ethclient.Client, name string, alreadyChecked *EnsC
reverseName, err := go_ens.ReverseResolve(client, addr)
if err != nil {
if err.Error() == "not a resolver" || err.Error() == "no resolution" || err.Error() == "execution reverted" {
logger.Warnf("reverse resolving address [%v] for name [%v] resulted in an error [%s], marking entry as not primary", addr, name, err.Error())
// logger.Warnf("reverse resolving address [%v] for name [%v] resulted in an error [%s], marking entry as not primary", addr, name, err.Error())
} else {
return fmt.Errorf("error could not reverse resolve address [%v]: %w", addr, err)
}
Expand Down Expand Up @@ -565,12 +564,12 @@ func validateEnsName(client *ethclient.Client, name string, alreadyChecked *EnsC
return fmt.Errorf("error writing ens data for name [%v]: %w", name, err)
}

logrus.WithFields(logrus.Fields{
"name": name,
"address": addr,
"expires": expires,
"reverseName": reverseName,
}).Infof("validated ens name")
// logrus.WithFields(logrus.Fields{
// "name": name,
// "address": addr,
// "expires": expires,
// "reverseName": reverseName,
// }).Infof("validated ens name")
return nil
}

Expand Down
Loading