Skip to content

Commit

Permalink
Merge pull request #701 from oasisprotocol/andrew7234/pontusx_test-fix
Browse files Browse the repository at this point in the history
pontusx/pontusx_dev post-launch bugfixes
  • Loading branch information
Andrew7234 authored Jun 25, 2024
2 parents 81911f2 + fedb7a8 commit bb46907
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 115 deletions.
1 change: 1 addition & 0 deletions .changelog/701.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
handle edge case for pontusx_test to pontusx rename
2 changes: 1 addition & 1 deletion analyzer/aggregate_stats/aggregate_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var statsLayers = []string{
layerConsensus,
string(common.RuntimeEmerald),
string(common.RuntimeSapphire),
string(common.RuntimePontusx),
string(common.RuntimePontusxTest),
string(common.RuntimePontusxDev),
string(common.RuntimeCipher),
}
Expand Down
16 changes: 8 additions & 8 deletions analyzer/evmverifier/sourcify/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ const (
// https://docs.sourcify.dev/docs/chains/
var sourcifyChains = map[common.ChainName]map[common.Runtime]string{
common.ChainNameTestnet: {
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.RuntimeEmerald: "42261",
common.RuntimeSapphire: "23295",
common.RuntimePontusxTest: "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.RuntimeEmerald: "42262",
common.RuntimeSapphire: "23294",
common.RuntimePontusxTest: "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
4 changes: 2 additions & 2 deletions analyzer/node_stats/node_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func NewAnalyzer(
cfg.Interval = 3 * time.Second
}
logger = logger.With("analyzer", nodeStatsAnalyzerName)
// Default to [consensus, emerald, sapphire, pontusx] if layers is not specified.
// Default to [consensus, emerald, sapphire, pontusx_test, pontusx_dev] if layers is not specified.
if len(layers) == 0 {
layers = []common.Layer{common.LayerConsensus, common.LayerEmerald, common.LayerSapphire, common.LayerPontusx}
layers = []common.Layer{common.LayerConsensus, common.LayerEmerald, common.LayerSapphire, common.LayerPontusxTest, common.LayerPontusxDev}
}
p := &processor{
layers: layers,
Expand Down
4 changes: 2 additions & 2 deletions analyzer/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func setupAnalyzer(t *testing.T, testDb *postgres.Client, node *mockNode) analyz
sourceConfig := config.SourceConfig{
ChainName: "testnet",
}
runtimeMetadata := sourceConfig.SDKParaTime("pontusx")
runtimeMetadata := sourceConfig.SDKParaTime("pontusx_dev")

// Determine the min and max rounds at which the mock node has data.
minRound := math.MaxInt64
Expand All @@ -148,7 +148,7 @@ func setupAnalyzer(t *testing.T, testDb *postgres.Client, node *mockNode) analyz

analyzer, err := runtime.NewRuntimeAnalyzer(
"testnet",
"pontusx", // We borrow a real runtime's name to comply with DB's enums.
"pontusx_dev", // We borrow a real runtime's name to comply with DB's enums.
runtimeMetadata,
config.BlockRange{From: uint64(minRound), To: uint64(maxRound)},
10 /*batchSize*/, analyzer.SlowSyncMode, node, testDb, logger)
Expand Down
4 changes: 2 additions & 2 deletions api/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ func RuntimeFromURLMiddleware(baseURL string) func(next http.Handler) http.Handl
runtime = common.RuntimeSapphire
case strings.HasPrefix(path, "/cipher/"):
runtime = common.RuntimeCipher
case strings.HasPrefix(path, "/pontusx/"):
runtime = common.RuntimePontusx
case strings.HasPrefix(path, "/pontusxtest/"):
runtime = common.RuntimePontusxTest
case strings.HasPrefix(path, "/pontusxdev/"):
runtime = common.RuntimePontusxDev
}
Expand Down
4 changes: 2 additions & 2 deletions api/spec/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1226,13 +1226,13 @@ components:
type: string
# NOTE: Change IsValid() in util.go if you change this.
# https://github.com/oasisprotocol/nexus/blob/v0.0.16/api/v1/types/util.go#L40
enum: [emerald, sapphire, pontusx, pontusxdev, cipher, consensus]
enum: [emerald, sapphire, pontusxtest, pontusxdev, cipher, consensus]

Runtime:
type: string
# NOTE: Change IsValid() in util.go if you change this.
# https://github.com/oasisprotocol/nexus/blob/v0.0.16/api/v1/types/util.go#L49
enum: [emerald, sapphire, pontusx, pontusxdev, cipher]
enum: [emerald, sapphire, pontusxtest, pontusxdev, cipher]

StakingAddress:
type: string
Expand Down
4 changes: 2 additions & 2 deletions api/v1/types/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (c ConsensusEventType) IsValid() bool {

func (c Layer) IsValid() bool {
switch c {
case LayerConsensus, LayerCipher, LayerEmerald, LayerSapphire, LayerPontusx, LayerPontusxdev:
case LayerConsensus, LayerCipher, LayerEmerald, LayerSapphire, LayerPontusxtest, LayerPontusxdev:
return true
default:
return false
Expand All @@ -52,7 +52,7 @@ func (c Layer) IsValid() bool {

func (c Runtime) IsValid() bool {
switch c {
case RuntimeCipher, RuntimeEmerald, RuntimeSapphire, RuntimePontusx, RuntimePontusxdev:
case RuntimeCipher, RuntimeEmerald, RuntimeSapphire, RuntimePontusxtest, RuntimePontusxdev:
return true
default:
return false
Expand Down
72 changes: 36 additions & 36 deletions cmd/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ func addAnalyzer(analyzers []SyncedAnalyzer, errSoFar error, syncTag string, ana
}

var (
syncTagConsensus = "consensus"
syncTagEmerald = string(common.RuntimeEmerald)
syncTagSapphire = string(common.RuntimeSapphire)
syncTagCipher = string(common.RuntimeCipher)
syncTagPontusx = string(common.RuntimePontusx)
syncTagPontusxDev = string(common.RuntimePontusxDev)
syncTagConsensus = "consensus"
syncTagEmerald = string(common.RuntimeEmerald)
syncTagSapphire = string(common.RuntimeSapphire)
syncTagCipher = string(common.RuntimeCipher)
syncTagPontusxTest = string(common.RuntimePontusxTest)
syncTagPontusxDev = string(common.RuntimePontusxDev)
)

// NewService creates new Service.
Expand Down Expand Up @@ -330,7 +330,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.RuntimePontusxTest, cfg.Analyzers.PontusxTest)
addFastSyncRuntimeAnalyzers(common.RuntimePontusxDev, cfg.Analyzers.PontusxDev)
addFastSyncRuntimeAnalyzers(common.RuntimeCipher, cfg.Analyzers.Cipher)

Expand Down Expand Up @@ -365,14 +365,14 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return runtime.NewRuntimeAnalyzer(cfg.Source.ChainName, common.RuntimeSapphire, runtimeMetadata, cfg.Analyzers.Sapphire.SlowSyncRange(), cfg.Analyzers.Sapphire.BatchSize, analyzer.SlowSyncMode, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.Pontusx != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusx, func() (A, error) {
runtimeMetadata := cfg.Source.SDKParaTime(common.RuntimePontusx)
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusx)
if cfg.Analyzers.PontusxTest != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxTest, func() (A, error) {
runtimeMetadata := cfg.Source.SDKParaTime(common.RuntimePontusxTest)
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxTest)
if err1 != nil {
return nil, err1
}
return runtime.NewRuntimeAnalyzer(cfg.Source.ChainName, common.RuntimePontusx, runtimeMetadata, cfg.Analyzers.Pontusx.SlowSyncRange(), cfg.Analyzers.Pontusx.BatchSize, analyzer.SlowSyncMode, sourceClient, dbClient, logger)
return runtime.NewRuntimeAnalyzer(cfg.Source.ChainName, common.RuntimePontusxTest, runtimeMetadata, cfg.Analyzers.PontusxTest.SlowSyncRange(), cfg.Analyzers.PontusxTest.BatchSize, analyzer.SlowSyncMode, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxDev != nil {
Expand Down Expand Up @@ -413,13 +413,13 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmtokens.NewAnalyzer(common.RuntimeSapphire, cfg.Analyzers.SapphireEvmTokens.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxEvmTokens != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusx, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusx)
if cfg.Analyzers.PontusxTestEvmTokens != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxTest, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxTest)
if err1 != nil {
return nil, err1
}
return evmtokens.NewAnalyzer(common.RuntimePontusx, cfg.Analyzers.PontusxEvmTokens.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
return evmtokens.NewAnalyzer(common.RuntimePontusxTest, cfg.Analyzers.PontusxTestEvmTokens.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxDevEvmTokens != nil {
Expand Down Expand Up @@ -457,17 +457,17 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmnfts.NewAnalyzer(common.RuntimeSapphire, cfg.Analyzers.SapphireEvmNfts.ItemBasedAnalyzerConfig, sourceClient, ipfsClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxEvmNfts != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusx, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusx)
if cfg.Analyzers.PontusxTestEvmNfts != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxTest, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxTest)
if err1 != nil {
return nil, err1
}
ipfsClient, err1 := sources.IPFS(ctx)
if err1 != nil {
return nil, err1
}
return evmnfts.NewAnalyzer(common.RuntimePontusx, cfg.Analyzers.PontusxEvmNfts.ItemBasedAnalyzerConfig, sourceClient, ipfsClient, dbClient, logger)
return evmnfts.NewAnalyzer(common.RuntimePontusxTest, cfg.Analyzers.PontusxTestEvmNfts.ItemBasedAnalyzerConfig, sourceClient, ipfsClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxDevEvmNfts != nil {
Expand Down Expand Up @@ -503,14 +503,14 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmtokenbalances.NewAnalyzer(common.RuntimeSapphire, cfg.Analyzers.SapphireEvmTokenBalances.ItemBasedAnalyzerConfig, runtimeMetadata, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxEvmTokenBalances != nil {
runtimeMetadata := cfg.Source.SDKParaTime(common.RuntimePontusx)
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusx, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusx)
if cfg.Analyzers.PontusxTestEvmTokenBalances != nil {
runtimeMetadata := cfg.Source.SDKParaTime(common.RuntimePontusxTest)
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxTest, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxTest)
if err1 != nil {
return nil, err1
}
return evmtokenbalances.NewAnalyzer(common.RuntimePontusx, cfg.Analyzers.PontusxEvmTokenBalances.ItemBasedAnalyzerConfig, runtimeMetadata, sourceClient, dbClient, logger)
return evmtokenbalances.NewAnalyzer(common.RuntimePontusxTest, cfg.Analyzers.PontusxTestEvmTokenBalances.ItemBasedAnalyzerConfig, runtimeMetadata, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxDevEvmTokenBalances != nil {
Expand Down Expand Up @@ -541,13 +541,13 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmcontractcode.NewAnalyzer(common.RuntimeSapphire, cfg.Analyzers.SapphireContractCode.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxContractCode != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusx, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusx)
if cfg.Analyzers.PontusxTestContractCode != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxTest, func() (A, error) {
sourceClient, err1 := sources.Runtime(ctx, common.RuntimePontusxTest)
if err1 != nil {
return nil, err1
}
return evmcontractcode.NewAnalyzer(common.RuntimePontusx, cfg.Analyzers.PontusxContractCode.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
return evmcontractcode.NewAnalyzer(common.RuntimePontusxTest, cfg.Analyzers.PontusxTestContractCode.ItemBasedAnalyzerConfig, sourceClient, dbClient, logger)
})
}
if cfg.Analyzers.PontusxDevContractCode != nil {
Expand All @@ -569,9 +569,9 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmverifier.NewAnalyzer(cfg.Source.ChainName, common.RuntimeSapphire, cfg.Analyzers.SapphireContractVerifier.ItemBasedAnalyzerConfig, cfg.Analyzers.SapphireContractVerifier.SourcifyServerUrl, dbClient, logger)
})
}
if cfg.Analyzers.PontusxContractVerifier != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusx, func() (A, error) {
return evmverifier.NewAnalyzer(cfg.Source.ChainName, common.RuntimePontusx, cfg.Analyzers.PontusxContractVerifier.ItemBasedAnalyzerConfig, cfg.Analyzers.PontusxContractVerifier.SourcifyServerUrl, dbClient, logger)
if cfg.Analyzers.PontusxTestContractVerifier != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxTest, func() (A, error) {
return evmverifier.NewAnalyzer(cfg.Source.ChainName, common.RuntimePontusxTest, cfg.Analyzers.PontusxTestContractVerifier.ItemBasedAnalyzerConfig, cfg.Analyzers.PontusxTestContractVerifier.SourcifyServerUrl, dbClient, logger)
})
}
if cfg.Analyzers.PontusxDevContractVerifier != nil {
Expand All @@ -589,9 +589,9 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
return evmabibackfill.NewAnalyzer(common.RuntimeSapphire, cfg.Analyzers.SapphireAbi.ItemBasedAnalyzerConfig, dbClient, logger)
})
}
if cfg.Analyzers.PontusxAbi != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusx, func() (A, error) {
return evmabibackfill.NewAnalyzer(common.RuntimePontusx, cfg.Analyzers.PontusxAbi.ItemBasedAnalyzerConfig, dbClient, logger)
if cfg.Analyzers.PontusxTestAbi != nil {
analyzers, err = addAnalyzer(analyzers, err, syncTagPontusxTest, func() (A, error) {
return evmabibackfill.NewAnalyzer(common.RuntimePontusxTest, cfg.Analyzers.PontusxTestAbi.ItemBasedAnalyzerConfig, dbClient, logger)
})
}
if cfg.Analyzers.PontusxDevAbi != nil {
Expand All @@ -615,7 +615,7 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
// fail if the node does not support the runtime, which is valid. If
// the analyzer expects the node to support the runtime but it does not,
// the analyzer will log an error.
for _, runtime := range []common.Runtime{common.RuntimeEmerald, common.RuntimeCipher, common.RuntimeSapphire, common.RuntimePontusx} {
for _, runtime := range []common.Runtime{common.RuntimeEmerald, common.RuntimeCipher, common.RuntimeSapphire, common.RuntimePontusxTest, common.RuntimePontusxDev} {
client, err2 := sources.Runtime(ctx, runtime)
if err2 != nil {
logger.Warn("unable to instantiate runtime client for node stats analyzer", "runtime", runtime)
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.RuntimePontusxTest, common.RuntimePontusxDev}
for _, runtime := range apiRuntimes {
client, err2 := source.NewRuntimeClient(ctx, cfg.Source, runtime)
if err2 != nil {
Expand Down
22 changes: 11 additions & 11 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,23 @@ const (
type Layer string

const (
LayerConsensus Layer = "consensus"
LayerEmerald Layer = "emerald"
LayerCipher Layer = "cipher"
LayerSapphire Layer = "sapphire"
LayerPontusx Layer = "pontusx"
LayerPontusxDev Layer = "pontusx_dev"
LayerConsensus Layer = "consensus"
LayerEmerald Layer = "emerald"
LayerCipher Layer = "cipher"
LayerSapphire Layer = "sapphire"
LayerPontusxTest Layer = "pontusx_test"
LayerPontusxDev Layer = "pontusx_dev"
)

// Runtime is an identifier for a runtime on the Oasis Network.
type Runtime string

const (
RuntimeEmerald Runtime = "emerald"
RuntimeCipher Runtime = "cipher"
RuntimeSapphire Runtime = "sapphire"
RuntimePontusx Runtime = "pontusx"
RuntimePontusxDev Runtime = "pontusx_dev"
RuntimeEmerald Runtime = "emerald"
RuntimeCipher Runtime = "cipher"
RuntimeSapphire Runtime = "sapphire"
RuntimePontusxTest Runtime = "pontusx_test"
RuntimePontusxDev Runtime = "pontusx_dev"
)

type CallFormat string
Expand Down
Loading

0 comments on commit bb46907

Please sign in to comment.