Skip to content
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
16 changes: 16 additions & 0 deletions api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,10 @@ const docTemplate = `{
"type": "string",
"x-order:1": true
},
"evm_ret_cleanup_height": {
"type": "integer",
"x-order:6": true
},
"height": {
"type": "integer",
"x-order:3": true
Expand All @@ -1477,6 +1481,18 @@ const docTemplate = `{
"type": "integer",
"x-order:5": true
},
"tx_account_cleanup_deleted": {
"type": "integer",
"x-order:8": true
},
"tx_account_cleanup_inserted": {
"type": "integer",
"x-order:9": true
},
"tx_account_cleanup_sequence": {
"type": "integer",
"x-order:7": true
},
"version": {
"type": "string",
"x-order:0": true
Expand Down
16 changes: 16 additions & 0 deletions api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,10 @@
"type": "string",
"x-order:1": true
},
"evm_ret_cleanup_height": {
"type": "integer",
"x-order:6": true
},
"height": {
"type": "integer",
"x-order:3": true
Expand All @@ -1466,6 +1470,18 @@
"type": "integer",
"x-order:5": true
},
"tx_account_cleanup_deleted": {
"type": "integer",
"x-order:8": true
},
"tx_account_cleanup_inserted": {
"type": "integer",
"x-order:9": true
},
"tx_account_cleanup_sequence": {
"type": "integer",
"x-order:7": true
},
"version": {
"type": "string",
"x-order:0": true
Expand Down
12 changes: 12 additions & 0 deletions api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ definitions:
commit_hash:
type: string
x-order:1: true
evm_ret_cleanup_height:
type: integer
x-order:6: true
height:
type: integer
x-order:3: true
Expand All @@ -152,6 +155,15 @@ definitions:
rich_list_height:
type: integer
x-order:5: true
tx_account_cleanup_deleted:
type: integer
x-order:8: true
tx_account_cleanup_inserted:
type: integer
x-order:9: true
tx_account_cleanup_sequence:
type: integer
x-order:7: true
version:
type: string
x-order:0: true
Expand Down
49 changes: 29 additions & 20 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,27 @@ func SetBuildInfo(v, commit string) {
}

type Config struct {
listenPort string
recvBufSize uint
indexerListenPort string
dbConfig *dbconfig.Config
chainConfig *ChainConfig
logLevel string
logFormat string
coolingDuration time.Duration // for indexer only
queryTimeout time.Duration // for indexer only
maxConcurrentRequests int // for indexer only
cacheSize int
cacheTTL time.Duration // for api only
pollingInterval time.Duration // for api only
internalTxConfig *InternalTxConfig
richListConfig *RichListConfig
evmRetCleanupConfig *EvmRetCleanupConfig
metricsConfig *MetricsConfig
cacheConfig *CacheConfig
sentryConfig *SentryConfig
corsConfig *CORSConfig
listenPort string
recvBufSize uint
indexerListenPort string
dbConfig *dbconfig.Config
chainConfig *ChainConfig
logLevel string
logFormat string
coolingDuration time.Duration // for indexer only
queryTimeout time.Duration // for indexer only
maxConcurrentRequests int // for indexer only
cacheSize int
cacheTTL time.Duration // for api only
pollingInterval time.Duration // for api only
internalTxConfig *InternalTxConfig
richListConfig *RichListConfig
evmRetCleanupConfig *EvmRetCleanupConfig
txAccountCleanupConfig *TxAccountCleanupConfig
metricsConfig *MetricsConfig
cacheConfig *CacheConfig
sentryConfig *SentryConfig
corsConfig *CORSConfig

// Start height configuration
startHeight int64 // explicit start height when set
Expand Down Expand Up @@ -177,6 +178,7 @@ func setDefaults() {
viper.SetDefault("INTERNAL_TX_BATCH_SIZE", DefaultInternalTxBatchSize)
viper.SetDefault("INTERNAL_TX_QUEUE_SIZE", DefaultInternalTxQueueSize)
viper.SetDefault("RICH_LIST", true)
viper.SetDefault("TX_ACCOUNT_CLEANUP", true)
viper.SetDefault("METRICS_ENABLED", false)
viper.SetDefault("METRICS_PATH", DefaultMetricsPath)
viper.SetDefault("METRICS_PORT", DefaultMetricsPort)
Expand Down Expand Up @@ -297,6 +299,9 @@ func loadConfig() (*Config, error) {
evmRetCleanupConfig: &EvmRetCleanupConfig{
Enabled: viper.GetBool("EVM_RET_CLEANUP"),
},
txAccountCleanupConfig: &TxAccountCleanupConfig{
Enabled: viper.GetBool("TX_ACCOUNT_CLEANUP"),
},
metricsConfig: &MetricsConfig{
Enabled: viper.GetBool("METRICS_ENABLED"),
Path: viper.GetString("METRICS_PATH"),
Expand Down Expand Up @@ -471,6 +476,10 @@ func (c *Config) SetEvmRetCleanupConfig(evmRetCleanCgf *EvmRetCleanupConfig) {
c.evmRetCleanupConfig = evmRetCleanCgf
}

func (c Config) TxAccountCleanupEnabled() bool {
return c.txAccountCleanupConfig != nil && c.txAccountCleanupConfig.Enabled
}

func (c Config) GetSentryConfig() *SentryConfig {
if c.sentryConfig == nil || c.sentryConfig.DSN == "" {
return nil
Expand Down
5 changes: 5 additions & 0 deletions config/txaccountcleanup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package config

type TxAccountCleanupConfig struct {
Enabled bool
}
4 changes: 2 additions & 2 deletions indexer/collector/tx/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func findAllMoveHexAddress(attr string) []string {
return regexMoveHex.FindAllString(attr, -1)
}

func grepAddressesFromTx(events []abci.Event, tx *gorm.DB) (grepped []string, err error) {
storeAddrMap := make(map[string]interface{}) // set of fa store addrs
func GrepAddressesFromTx(events []abci.Event, tx *gorm.DB) (grepped []string, err error) {
storeAddrMap := make(map[string]any) // set of fa store addrs

for _, event := range events {
for idx, attr := range event.Attributes {
Expand Down
2 changes: 1 addition & 1 deletion indexer/collector/tx/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (sub *TxSubmodule) collect(block indexertypes.ScrapedBlock, tx *gorm.DB) er
}

// grep addresses from events
addrs, err := grepAddressesFromTx(res.Events, tx)
addrs, err := GrepAddressesFromTx(res.Events, tx)
if err != nil {
return err
}
Expand Down
5 changes: 5 additions & 0 deletions indexer/extension/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
evmret "github.com/initia-labs/rollytics/indexer/extension/evmret"
internaltx "github.com/initia-labs/rollytics/indexer/extension/internaltx"
richlist "github.com/initia-labs/rollytics/indexer/extension/richlist"
txaccountcleanup "github.com/initia-labs/rollytics/indexer/extension/txaccountcleanup"
"github.com/initia-labs/rollytics/indexer/extension/types"
"github.com/initia-labs/rollytics/orm"
)
Expand All @@ -36,6 +37,10 @@ func New(cfg *config.Config, logger *slog.Logger, db *orm.Database) *ExtensionMa
if retCleanup := evmret.New(cfg, logger, db); retCleanup != nil {
extensions = append(extensions, retCleanup)
}
// TX Account Cleanup
if taCleanup := txaccountcleanup.New(cfg, logger, db); taCleanup != nil {
extensions = append(extensions, taCleanup)
}
return &ExtensionManager{
cfg: cfg,
logger: logger,
Expand Down
Loading
Loading