From df602b6c6dd9e5e5bcbbfa4fc68b4dc1425c95f3 Mon Sep 17 00:00:00 2001 From: Patrick Pfeiffer <patrick@bitfly.at> Date: Fri, 9 Aug 2024 08:51:16 +0200 Subject: [PATCH 1/4] (NOBIDS) eth1indexer: move ens-importing its own go-routine --- cmd/eth1indexer/main.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/cmd/eth1indexer/main.go b/cmd/eth1indexer/main.go index 1f435ec12b..9e26e19435 100644 --- a/cmd/eth1indexer/main.go +++ b/cmd/eth1indexer/main.go @@ -178,6 +178,10 @@ func main() { }() } + if *enableEnsUpdater { + go ImportEnsUpdatesLoop(bt, client, *ensBatchSize) + } + if *enableFullBalanceUpdater { ProcessMetadataUpdates(bt, client, balanceUpdaterPrefix, *balanceUpdaterBatchSize, -1) return @@ -378,14 +382,6 @@ 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) } @@ -393,6 +389,19 @@ func main() { // utils.WaitForCtrlC() } +func ImportEnsUpdatesLoop(bt *db.Bigtable, client *rpc.ErigonClient, batchSize int64) { + time.Sleep(time.Second * 5) + for { + err := bt.ImportEnsUpdates(client.GetNativeClient(), batchSize) + if err != nil { + logrus.WithError(err).Errorf("error importing ens updates") + } else { + services.ReportStatus("ensIndexer", "Running", nil) + } + time.Sleep(time.Second * 5) + } +} + func UpdateTokenPrices(bt *db.Bigtable, client *rpc.ErigonClient, tokenListPath string) error { tokenListContent, err := os.ReadFile(tokenListPath) From 8762740e89bd4c67a407f3db06ac0f1209168916 Mon Sep 17 00:00:00 2001 From: Patrick Pfeiffer <patrick@bitfly.at> Date: Fri, 9 Aug 2024 09:07:42 +0200 Subject: [PATCH 2/4] (NOBIDS) eth1indexer: less logging on ens --- db/ens.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/db/ens.go b/db/ens.go index a9e562e754..8904bc553e 100644 --- a/db/ens.go +++ b/db/ens.go @@ -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" @@ -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) } @@ -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) @@ -496,7 +495,7 @@ func validateEnsName(client *ethclient.Client, name string, alreadyChecked *EnsC 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) @@ -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) } @@ -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 } From b8057ae45d66e10ee2cd5a5b8fc05c615c8f3ef8 Mon Sep 17 00:00:00 2001 From: Patrick Pfeiffer <patrick@bitfly.at> Date: Mon, 12 Aug 2024 09:48:01 +0200 Subject: [PATCH 3/4] (NOBIDS) eth1indexer: fix error handling for resolve --- db/ens.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/ens.go b/db/ens.go index 8904bc553e..333fb83c11 100644 --- a/db/ens.go +++ b/db/ens.go @@ -490,7 +490,7 @@ 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" { From 79e839fbde9823509dd2cd898b742f21e8792193 Mon Sep 17 00:00:00 2001 From: Patrick Pfeiffer <patrick@bitfly.at> Date: Mon, 12 Aug 2024 13:43:17 +0200 Subject: [PATCH 4/4] (NOBIDS) eth1indexer: improve loop-sleep --- cmd/eth1indexer/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/eth1indexer/main.go b/cmd/eth1indexer/main.go index 9e26e19435..65ff085fb7 100644 --- a/cmd/eth1indexer/main.go +++ b/cmd/eth1indexer/main.go @@ -390,15 +390,14 @@ func main() { } func ImportEnsUpdatesLoop(bt *db.Bigtable, client *rpc.ErigonClient, batchSize int64) { - time.Sleep(time.Second * 5) 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) } - time.Sleep(time.Second * 5) } }