Skip to content

Commit

Permalink
handle pontusx to pontusx_dev rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew7234 committed May 27, 2024
1 parent bd2e705 commit 79be06c
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 181 deletions.
2 changes: 1 addition & 1 deletion analyzer/aggregate_stats/aggregate_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var statsLayers = []string{
string(common.RuntimeEmerald),
string(common.RuntimeSapphire),
string(common.RuntimePontusx),
string(common.RuntimePontusxdev),
string(common.RuntimePontusxDev),
string(common.RuntimeCipher),
}

Expand Down
4 changes: 2 additions & 2 deletions analyzer/evmverifier/sourcify/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ var sourcifyChains = map[common.ChainName]map[common.Runtime]string{
common.RuntimeEmerald: "42261",
common.RuntimeSapphire: "23295",
common.RuntimePontusx: "23295", // XXX: We're stealing sapphire data here. TODO: use dedicated verifications.
common.RuntimePontusxdev: "23295", // XXX: We're stealing sapphire data here. TODO: use dedicated verifications.
common.RuntimePontusxDev: "23295", // XXX: We're stealing sapphire data here. TODO: use dedicated verifications.
},
common.ChainNameMainnet: {
common.RuntimeEmerald: "42262",
common.RuntimeSapphire: "23294",
common.RuntimePontusx: "23294", // XXX: We're stealing sapphire data here. TODO: use dedicated verifications.
common.RuntimePontusxdev: "23294", // XXX: We're stealing sapphire data here. TODO: use dedicated verifications.
common.RuntimePontusxDev: "23294", // XXX: We're stealing sapphire data here. TODO: use dedicated verifications.
},
}

Expand Down
2 changes: 1 addition & 1 deletion api/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func RuntimeFromURLMiddleware(baseURL string) func(next http.Handler) http.Handl
case strings.HasPrefix(path, "/pontusx/"):
runtime = common.RuntimePontusx
case strings.HasPrefix(path, "/pontusxdev/"):
runtime = common.RuntimePontusxdev
runtime = common.RuntimePontusxDev
}

if runtime != "" {
Expand Down
60 changes: 30 additions & 30 deletions cmd/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ var (
syncTagSapphire = string(common.RuntimeSapphire)
syncTagCipher = string(common.RuntimeCipher)
syncTagPontusx = string(common.RuntimePontusx)
syncTagPontusxdev = string(common.RuntimePontusxdev)
syncTagPontusxDev = string(common.RuntimePontusxDev)
)

// NewService creates new Service.
Expand Down Expand Up @@ -331,7 +331,7 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
addFastSyncRuntimeAnalyzers(common.RuntimeEmerald, cfg.Analyzers.Emerald)
addFastSyncRuntimeAnalyzers(common.RuntimeSapphire, cfg.Analyzers.Sapphire)
addFastSyncRuntimeAnalyzers(common.RuntimePontusx, cfg.Analyzers.Pontusx)
addFastSyncRuntimeAnalyzers(common.RuntimePontusxdev, cfg.Analyzers.Pontusxdev)
addFastSyncRuntimeAnalyzers(common.RuntimePontusxDev, cfg.Analyzers.PontusxDev)
addFastSyncRuntimeAnalyzers(common.RuntimeCipher, cfg.Analyzers.Cipher)

// Initialize slow-sync analyzers.
Expand Down Expand Up @@ -375,14 +375,14 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return runtime.NewRuntimeAnalyzer(cfg.Source.ChainName, common.RuntimePontusx, runtimeMetadata, cfg.Analyzers.Pontusx.SlowSyncRange(), cfg.Analyzers.Pontusx.BatchSize, analyzer.SlowSyncMode, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.Pontusxdev != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxdev, func() (A, error) {
runtimeMetadata := cfg.Source.SDKParaTime(common.RuntimePontusxdev)
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxdev)
if cfg.Analyzers.PontusxDev != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxDev, func() (A, error) {
runtimeMetadata := cfg.Source.SDKParaTime(common.RuntimePontusxDev)
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxDev)
if err1 != nil {
return nil, err1
}
return runtime.NewRuntimeAnalyzer(cfg.Source.ChainName, common.RuntimePontusxdev, runtimeMetadata, cfg.Analyzers.Pontusxdev.SlowSyncRange(), cfg.Analyzers.Pontusx.BatchSize, analyzer.SlowSyncMode, sourceClient, dbClient, logger)
return runtime.NewRuntimeAnalyzer(cfg.Source.ChainName, common.RuntimePontusxDev, runtimeMetadata, cfg.Analyzers.PontusxDev.SlowSyncRange(), cfg.Analyzers.PontusxDev.BatchSize, analyzer.SlowSyncMode, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.Cipher != nil {
Expand Down Expand Up @@ -422,13 +422,13 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmtokens.NewAnalyzer(common.RuntimePontusx, cfg.Analyzers.PontusxEvmTokens.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxdevEvmTokens != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxdev, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxdev)
if cfg.Analyzers.PontusxDevEvmTokens != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxDev, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxDev)
if err1 != nil {
return nil, err1
}
return evmtokens.NewAnalyzer(common.RuntimePontusxdev, cfg.Analyzers.PontusxdevEvmTokens.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
return evmtokens.NewAnalyzer(common.RuntimePontusxDev, cfg.Analyzers.PontusxDevEvmTokens.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.EmeraldEvmNfts != nil {
Expand Down Expand Up @@ -470,17 +470,17 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmnfts.NewAnalyzer(common.RuntimePontusx, cfg.Analyzers.PontusxEvmNfts.ItemBasedAnalyzerConfig, sourceClient, ipfsClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxdevEvmNfts != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxdev, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxdev)
if cfg.Analyzers.PontusxDevEvmNfts != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxDev, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxDev)
if err1 != nil {
return nil, err1
}
ipfsClient, err1 := sources.IPFS(ctx)
if err1 != nil {
return nil, err1
}
return evmnfts.NewAnalyzer(common.RuntimePontusxdev, cfg.Analyzers.PontusxdevEvmNfts.ItemBasedAnalyzerConfig, sourceClient, ipfsClient, dbClient, logger)
return evmnfts.NewAnalyzer(common.RuntimePontusxDev, cfg.Analyzers.PontusxDevEvmNfts.ItemBasedAnalyzerConfig, sourceClient, ipfsClient, dbClient, logger)
})
}
if cfg.Analyzers.EmeraldEvmTokenBalances != nil {
Expand Down Expand Up @@ -513,14 +513,14 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmtokenbalances.NewAnalyzer(common.RuntimePontusx, cfg.Analyzers.PontusxEvmTokenBalances.ItemBasedAnalyzerConfig, runtimeMetadata, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxdevEvmTokenBalances != nil {
runtimeMetadata := cfg.Source.SDKParaTime(common.RuntimePontusxdev)
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxdev, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxdev)
if cfg.Analyzers.PontusxDevEvmTokenBalances != nil {
runtimeMetadata := cfg.Source.SDKParaTime(common.RuntimePontusxDev)
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxDev, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxDev)
if err1 != nil {
return nil, err1
}
return evmtokenbalances.NewAnalyzer(common.RuntimePontusxdev, cfg.Analyzers.PontusxdevEvmTokenBalances.ItemBasedAnalyzerConfig, runtimeMetadata, sourceClient, dbClient, logger)
return evmtokenbalances.NewAnalyzer(common.RuntimePontusxDev, cfg.Analyzers.PontusxDevEvmTokenBalances.ItemBasedAnalyzerConfig, runtimeMetadata, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.EmeraldContractCode != nil {
Expand Down Expand Up @@ -550,13 +550,13 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmcontractcode.NewAnalyzer(common.RuntimePontusx, cfg.Analyzers.PontusxContractCode.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxdevContractCode != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxdev, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxdev)
if cfg.Analyzers.PontusxDevContractCode != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxDev, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxDev)
if err1 != nil {
return nil, err1
}
return evmcontractcode.NewAnalyzer(common.RuntimePontusxdev, cfg.Analyzers.PontusxdevContractCode.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
return evmcontractcode.NewAnalyzer(common.RuntimePontusxDev, cfg.Analyzers.PontusxDevContractCode.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.EmeraldContractVerifier != nil {
Expand All @@ -574,9 +574,9 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmverifier.NewAnalyzer(cfg.Source.ChainName, common.RuntimePontusx, cfg.Analyzers.PontusxContractVerifier.ItemBasedAnalyzerConfig, cfg.Analyzers.PontusxContractVerifier.SourcifyServerUrl, dbClient, logger)
})
}
if cfg.Analyzers.PontusxdevContractVerifier != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxdev, func() (A, error) {
return evmverifier.NewAnalyzer(cfg.Source.ChainName, common.RuntimePontusxdev, cfg.Analyzers.PontusxdevContractVerifier.ItemBasedAnalyzerConfig, cfg.Analyzers.PontusxdevContractVerifier.SourcifyServerUrl, dbClient, logger)
if cfg.Analyzers.PontusxDevContractVerifier != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxDev, func() (A, error) {
return evmverifier.NewAnalyzer(cfg.Source.ChainName, common.RuntimePontusxDev, cfg.Analyzers.PontusxDevContractVerifier.ItemBasedAnalyzerConfig, cfg.Analyzers.PontusxDevContractVerifier.SourcifyServerUrl, dbClient, logger)
})
}
if cfg.Analyzers.EmeraldAbi != nil {
Expand All @@ -594,9 +594,9 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmabibackfill.NewAnalyzer(common.RuntimePontusx, cfg.Analyzers.PontusxAbi.ItemBasedAnalyzerConfig, dbClient, logger)
})
}
if cfg.Analyzers.PontusxdevAbi != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxdev, func() (A, error) {
return evmabibackfill.NewAnalyzer(common.RuntimePontusxdev, cfg.Analyzers.PontusxdevAbi.ItemBasedAnalyzerConfig, dbClient, logger)
if cfg.Analyzers.PontusxDevAbi != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxDev, func() (A, error) {
return evmabibackfill.NewAnalyzer(common.RuntimePontusxDev, cfg.Analyzers.PontusxDevAbi.ItemBasedAnalyzerConfig, dbClient, logger)
})
}
if cfg.Analyzers.MetadataRegistry != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func NewService(cfg *config.ServerConfig) (*Service, error) {
var networkConfig *sdkConfig.Network
if cfg.Source != nil {
networkConfig = cfg.Source.SDKNetwork()
apiRuntimes := []common.Runtime{common.RuntimeEmerald, common.RuntimeSapphire, common.RuntimePontusx, common.RuntimePontusxdev}
apiRuntimes := []common.Runtime{common.RuntimeEmerald, common.RuntimeSapphire, common.RuntimePontusx, common.RuntimePontusxDev}
for _, runtime := range apiRuntimes {
client, err2 := source.NewRuntimeClient(ctx, cfg.Source, runtime)
if err2 != nil {
Expand Down
4 changes: 2 additions & 2 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const (
LayerCipher Layer = "cipher"
LayerSapphire Layer = "sapphire"
LayerPontusx Layer = "pontusx"
LayerPontusxdev Layer = "pontusxdev"
LayerPontusxDev Layer = "pontusx_dev"
)

// Runtime is an identifier for a runtime on the Oasis Network.
Expand All @@ -240,7 +240,7 @@ const (
RuntimeCipher Runtime = "cipher"
RuntimeSapphire Runtime = "sapphire"
RuntimePontusx Runtime = "pontusx"
RuntimePontusxdev Runtime = "pontusxdev"
RuntimePontusxDev Runtime = "pontusx_dev"
)

type CallFormat string
Expand Down
31 changes: 23 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ func (cfg *AnalysisConfig) Validate() error {
return err
}
}
if cfg.Analyzers.Pontusx != nil {
if err := cfg.Analyzers.Pontusx.Validate(); err != nil {
return err
}
}
if cfg.Analyzers.PontusxDev != nil {
if err := cfg.Analyzers.PontusxDev.Validate(); err != nil {
return err
}
}
if cfg.Analyzers.MetadataRegistry != nil {
if err := cfg.Analyzers.MetadataRegistry.Validate(); err != nil {
return err
Expand Down Expand Up @@ -125,33 +135,33 @@ type AnalyzersList struct {
Emerald *BlockBasedAnalyzerConfig `koanf:"emerald"`
Sapphire *BlockBasedAnalyzerConfig `koanf:"sapphire"`
Pontusx *BlockBasedAnalyzerConfig `koanf:"pontusx"`
Pontusxdev *BlockBasedAnalyzerConfig `koanf:"pontusxdev"`
PontusxDev *BlockBasedAnalyzerConfig `koanf:"pontusx_dev"`
Cipher *BlockBasedAnalyzerConfig `koanf:"cipher"`

EmeraldEvmTokens *EvmTokensAnalyzerConfig `koanf:"evm_tokens_emerald"`
SapphireEvmTokens *EvmTokensAnalyzerConfig `koanf:"evm_tokens_sapphire"`
PontusxEvmTokens *EvmTokensAnalyzerConfig `koanf:"evm_tokens_pontusx"`
PontusxdevEvmTokens *EvmTokensAnalyzerConfig `koanf:"evm_tokens_pontusxdev"`
PontusxDevEvmTokens *EvmTokensAnalyzerConfig `koanf:"evm_tokens_pontusx_dev"`
EmeraldEvmNfts *EvmTokensAnalyzerConfig `koanf:"evm_nfts_emerald"`
SapphireEvmNfts *EvmTokensAnalyzerConfig `koanf:"evm_nfts_sapphire"`
PontusxEvmNfts *EvmTokensAnalyzerConfig `koanf:"evm_nfts_pontusx"`
PontusxdevEvmNfts *EvmTokensAnalyzerConfig `koanf:"evm_nfts_pontusxdev"`
PontusxDevEvmNfts *EvmTokensAnalyzerConfig `koanf:"evm_nfts_pontusx_dev"`
EmeraldEvmTokenBalances *EvmTokensAnalyzerConfig `koanf:"evm_token_balances_emerald"`
SapphireEvmTokenBalances *EvmTokensAnalyzerConfig `koanf:"evm_token_balances_sapphire"`
PontusxEvmTokenBalances *EvmTokensAnalyzerConfig `koanf:"evm_token_balances_pontusx"`
PontusxdevEvmTokenBalances *EvmTokensAnalyzerConfig `koanf:"evm_token_balances_pontusxdev"`
PontusxDevEvmTokenBalances *EvmTokensAnalyzerConfig `koanf:"evm_token_balances_pontusx_dev"`
EmeraldContractCode *EvmContractCodeAnalyzerConfig `koanf:"evm_contract_code_emerald"`
SapphireContractCode *EvmContractCodeAnalyzerConfig `koanf:"evm_contract_code_sapphire"`
PontusxContractCode *EvmContractCodeAnalyzerConfig `koanf:"evm_contract_code_pontusx"`
PontusxdevContractCode *EvmContractCodeAnalyzerConfig `koanf:"evm_contract_code_pontusxdev"`
PontusxDevContractCode *EvmContractCodeAnalyzerConfig `koanf:"evm_contract_code_pontusx_dev"`
EmeraldContractVerifier *EVMContractVerifierConfig `koanf:"evm_contract_verifier_emerald"`
SapphireContractVerifier *EVMContractVerifierConfig `koanf:"evm_contract_verifier_sapphire"`
PontusxContractVerifier *EVMContractVerifierConfig `koanf:"evm_contract_verifier_pontusx"`
PontusxdevContractVerifier *EVMContractVerifierConfig `koanf:"evm_contract_verifier_pontusxdev"`
PontusxDevContractVerifier *EVMContractVerifierConfig `koanf:"evm_contract_verifier_pontusx_dev"`
EmeraldAbi *EvmAbiAnalyzerConfig `koanf:"evm_abi_emerald"`
SapphireAbi *EvmAbiAnalyzerConfig `koanf:"evm_abi_sapphire"`
PontusxAbi *EvmAbiAnalyzerConfig `koanf:"evm_abi_pontusx"`
PontusxdevAbi *EvmAbiAnalyzerConfig `koanf:"evm_abi_pontusxdev"`
PontusxDevAbi *EvmAbiAnalyzerConfig `koanf:"evm_abi_pontusx_dev"`

MetadataRegistry *MetadataRegistryConfig `koanf:"metadata_registry"`
NodeStats *NodeStatsConfig `koanf:"node_stats"`
Expand Down Expand Up @@ -225,7 +235,12 @@ func (sc *SourceConfig) SDKNetwork() *sdkConfig.Network {
}

func (sc *SourceConfig) SDKParaTime(runtime common.Runtime) *sdkConfig.ParaTime {
return sc.SDKNetwork().ParaTimes.All[string(runtime)]
// TODO: remove this shim once pontusx_test is renamed to pontusx
sdkRuntimeName := string(runtime)
if sc.ChainName == "testnet" && runtime == common.RuntimePontusx {
sdkRuntimeName = "pontusx_test"
}
return sc.SDKNetwork().ParaTimes.All[sdkRuntimeName]
}

type CacheConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion config/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var DefaultChains = map[common.ChainName]*History{
common.RuntimeEmerald: 2627790,
common.RuntimeSapphire: 2995927,
common.RuntimePontusx: 0,
common.RuntimePontusxdev: 0,
common.RuntimePontusxDev: 0,
},
},
{
Expand Down
Loading

0 comments on commit 79be06c

Please sign in to comment.