Skip to content

Commit 655c22b

Browse files
authored
disable insight rpc (#308)
* disable insight rpc * enable block receipts method * lag by blocks for live polling
1 parent 8343bf2 commit 655c22b

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

configs/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type Config struct {
6161
CommitterCompressionThresholdMB int `env:"COMMITTER_COMPRESSION_THRESHOLD_MB" envDefault:"50"`
6262
CommitterKafkaBatchSize int `env:"COMMITTER_KAFKA_BATCH_SIZE" envDefault:"500"`
6363
CommitterIsLive bool `env:"COMMITTER_IS_LIVE" envDefault:"false"`
64+
CommitterLagByBlocks uint64 `env:"COMMITTER_LAG_BY_BLOCKS" envDefault:"0"`
6465
StagingS3Bucket string `env:"STAGING_S3_BUCKET" envDefault:"thirdweb-insight-production"`
6566
StagingS3Region string `env:"STAGING_S3_REGION" envDefault:"us-west-2"`
6667
StagingS3AccessKeyID string `env:"STAGING_S3_ACCESS_KEY_ID"`
@@ -94,6 +95,9 @@ func LoadConfig(cfgFile string) error {
9495
panic(err)
9596
}
9697

98+
// Set default values for viper-managed configs
99+
viper.SetDefault("rpc.blockReceipts.enabled", true)
100+
97101
if cfgFile != "" {
98102
viper.SetConfigFile(cfgFile)
99103
if err := viper.ReadInConfig(); err != nil {

internal/committer/poollatest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func pollLatest() error {
2929
// Update latest block number metric
3030
metrics.CommitterLatestBlockNumber.WithLabelValues(indexerName, chainIdStr).Set(float64(latestBlock.Uint64()))
3131

32-
if nextBlockNumber >= latestBlock.Uint64() {
32+
if nextBlockNumber+config.Cfg.CommitterLagByBlocks >= latestBlock.Uint64() {
3333
time.Sleep(250 * time.Millisecond)
3434
continue
3535
}

internal/rpc/rpc.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,18 @@ func (rpc *Client) checkGetBlockByNumberSupport() error {
181181
}
182182

183183
func (rpc *Client) checkGetBlockReceiptsSupport() error {
184-
if config.Cfg.RPC.BlockReceipts.Enabled {
185-
var getBlockReceiptsResult interface{}
186-
receiptsErr := rpc.RPCClient.Call(&getBlockReceiptsResult, "eth_getBlockReceipts", "latest")
187-
if receiptsErr != nil {
188-
log.Warn().Err(receiptsErr).Msg("eth_getBlockReceipts method not supported")
189-
return fmt.Errorf("eth_getBlockReceipts method not supported: %v", receiptsErr)
190-
} else {
191-
rpc.supportsBlockReceipts = true
192-
log.Debug().Msg("eth_getBlockReceipts method supported")
193-
}
194-
} else {
184+
// Always probe to see if the method is supported
185+
var getBlockReceiptsResult interface{}
186+
receiptsErr := rpc.RPCClient.Call(&getBlockReceiptsResult, "eth_getBlockReceipts", "latest")
187+
188+
if receiptsErr != nil {
189+
// Method not supported by RPC endpoint
195190
rpc.supportsBlockReceipts = false
196-
log.Debug().Msg("eth_getBlockReceipts method disabled")
191+
log.Warn().Err(receiptsErr).Msg("eth_getBlockReceipts method not supported by RPC endpoint")
192+
} else {
193+
// Method supported and enabled
194+
rpc.supportsBlockReceipts = true
195+
log.Info().Msg("eth_getBlockReceipts method enabled")
197196
}
198197
return nil
199198
}

0 commit comments

Comments
 (0)