Skip to content

Commit d016e03

Browse files
merge main to fix/compatibility-for-previous-eons
2 parents d143292 + a473e3e commit d016e03

40 files changed

+4458
-169
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
circleci 0.1.31425
2-
golang 1.23.6
2+
golang 1.24.5
33
golangci-lint 1.64.5
44
nodejs 18.17.0
55
postgres 14.2

rolling-shutter/chainobserver/db/collator/definition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var files embed.FS
1616
var Definition db.Definition
1717

1818
func init() {
19-
def, err := db.NewSQLCDefinition(files, "sql/", "chainobscollator", 1)
19+
def, err := db.NewSQLCDefinition(files, "sql/", "chainobscollator")
2020
if err != nil {
2121
log.Fatal().Err(err).Msg("failed to initialize DB metadata")
2222
}

rolling-shutter/chainobserver/db/keyper/definition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var files embed.FS
1616
var Definition db.Definition
1717

1818
func init() {
19-
def, err := db.NewSQLCDefinition(files, "sql/", "chainobskeyper", 1)
19+
def, err := db.NewSQLCDefinition(files, "sql/", "chainobskeyper")
2020
if err != nil {
2121
log.Fatal().Err(err).Msg("failed to initialize DB metadata")
2222
}

rolling-shutter/chainobserver/db/sync/definition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var Definition db.Definition
1616

1717
func init() {
1818
var err error
19-
Definition, err = db.NewSQLCDefinition(files, "sql/", "chainobssync", 1)
19+
Definition, err = db.NewSQLCDefinition(files, "sql/", "chainobssync")
2020
if err != nil {
2121
log.Fatal().Err(err).Msg("failed to initialize DB metadata")
2222
}

rolling-shutter/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ require (
3232
github.com/pkg/errors v0.9.1
3333
github.com/prometheus/client_golang v1.22.0
3434
github.com/rs/zerolog v1.28.0
35-
github.com/shutter-network/contracts/v2 v2.0.0-beta.2.0.20250108084129-3b743179373a
35+
github.com/shutter-network/contracts/v2 v2.0.0-beta.2.0.20250908105003-7e53b1579b04
3636
github.com/shutter-network/gnosh-contracts v0.4.0
3737
github.com/shutter-network/shop-contracts v0.0.0-20240407151512-08ef5d8355b6
3838
github.com/shutter-network/shutter/shlib v0.1.19

rolling-shutter/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,8 @@ github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.
873873
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
874874
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
875875
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
876-
github.com/shutter-network/contracts/v2 v2.0.0-beta.2.0.20250108084129-3b743179373a h1:hWw2nJLGPZU7Rvd6YmEEDfvlTUbwZKZl5UP2ThVVNSU=
877-
github.com/shutter-network/contracts/v2 v2.0.0-beta.2.0.20250108084129-3b743179373a/go.mod h1:V8KhVM75wyWVSzZJ6GeC9dWCjRrinIQVb7mYNP+knbg=
876+
github.com/shutter-network/contracts/v2 v2.0.0-beta.2.0.20250908105003-7e53b1579b04 h1:DfSfDw8IqXHqz6JXkZLIcvPS4CdoeXNaDhk+HEX61rM=
877+
github.com/shutter-network/contracts/v2 v2.0.0-beta.2.0.20250908105003-7e53b1579b04/go.mod h1:V8KhVM75wyWVSzZJ6GeC9dWCjRrinIQVb7mYNP+knbg=
878878
github.com/shutter-network/gnosh-contracts v0.4.0 h1:2GJcHK9w4lJZMsccklmxDhNnrkRLJDRwsL1acBnAeak=
879879
github.com/shutter-network/gnosh-contracts v0.4.0/go.mod h1:QB0d64ybbVFKMrLjrc1tldri87KNjTmKQjhk9jaso2E=
880880
github.com/shutter-network/shop-contracts v0.0.0-20240407151512-08ef5d8355b6 h1:m6Ti1/IH+GBTtGqyAX3xbh+ruUKvC+m+/uzYDUa+JDQ=

rolling-shutter/keyper/database/definition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var files embed.FS
2121
var Definition db.Definition
2222

2323
func init() {
24-
sqlcDB, err := db.NewSQLCDefinition(files, "sql/", "keyper", 1)
24+
sqlcDB, err := db.NewSQLCDefinition(files, "sql/", "keyper")
2525
if err != nil {
2626
log.Fatal().Err(err).Msg("failed to initialize DB")
2727
}

rolling-shutter/keyper/keypermetrics/metrics.go

Lines changed: 101 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package keypermetrics
33
import (
44
"context"
55
"strconv"
6+
"strings"
67

78
"github.com/jackc/pgx/v4/pgxpool"
89
"github.com/prometheus/client_golang/prometheus"
@@ -88,7 +89,7 @@ var MetricsKeyperBatchConfigInfo = prometheus.NewGaugeVec(
8889
},
8990
[]string{"batch_config_index", "keyper_addresses"})
9091

91-
var MetricsKeyperDKGstatus = prometheus.NewGaugeVec(
92+
var MetricsKeyperDKGStatus = prometheus.NewGaugeVec(
9293
prometheus.GaugeOpts{
9394
Namespace: "shutter",
9495
Subsystem: "keyper",
@@ -98,6 +99,23 @@ var MetricsKeyperDKGstatus = prometheus.NewGaugeVec(
9899
[]string{"eon"},
99100
)
100101

102+
var MetricsKeyperEthAddress = prometheus.NewGaugeVec(
103+
prometheus.GaugeOpts{
104+
Namespace: "shutter",
105+
Subsystem: "keyper",
106+
Name: "address",
107+
Help: "Ethereum address of the Keyper",
108+
}, []string{"address"})
109+
110+
var MetricsExecutionClientVersion = prometheus.NewGaugeVec(
111+
prometheus.GaugeOpts{
112+
Namespace: "shutter",
113+
Subsystem: "keyper",
114+
Name: "execution_client_version",
115+
Help: "Version of the execution client",
116+
},
117+
[]string{"version"})
118+
101119
func InitMetrics(dbpool *pgxpool.Pool, config kprconfig.Config) {
102120
prometheus.MustRegister(MetricsKeyperCurrentBlockL1)
103121
prometheus.MustRegister(MetricsKeyperCurrentBlockShuttermint)
@@ -107,69 +125,98 @@ func InitMetrics(dbpool *pgxpool.Pool, config kprconfig.Config) {
107125
prometheus.MustRegister(MetricsKeyperCurrentPhase)
108126
prometheus.MustRegister(MetricsKeyperCurrentBatchConfigIndex)
109127
prometheus.MustRegister(MetricsKeyperBatchConfigInfo)
110-
prometheus.MustRegister(MetricsKeyperDKGstatus)
128+
prometheus.MustRegister(MetricsKeyperDKGStatus)
129+
prometheus.MustRegister(MetricsKeyperEthAddress)
130+
prometheus.MustRegister(MetricsExecutionClientVersion)
111131

132+
ctx := context.Background()
112133
queries := database.New(dbpool)
113-
eons, err := queries.GetAllEons(context.Background())
114-
if err != nil {
115-
log.Error().Err(err).Msg("keypermetrics | Failed to get all eons")
116-
return
117-
}
118-
keyperIndex, isKeyper, err := queries.GetKeyperIndex(context.Background(), eons[len(eons)-1].KeyperConfigIndex, config.GetAddress())
119-
if err != nil {
120-
log.Error().Err(err).Msg("keypermetrics | Failed to get keyper index")
121-
return
122-
}
123-
if isKeyper {
124-
MetricsKeyperIsKeyper.WithLabelValues(strconv.FormatInt(keyperIndex, 10)).Set(1)
134+
135+
MetricsKeyperEthAddress.WithLabelValues(config.GetAddress().Hex()).Set(1)
136+
137+
if version, err := chainsync.GetClientVersion(ctx, config.Ethereum.EthereumURL); err != nil {
138+
log.Error().Err(err).Msg("keypermetrics | Failed to get execution client version")
125139
} else {
126-
MetricsKeyperIsKeyper.WithLabelValues(strconv.FormatInt(keyperIndex, 10)).Set(0)
140+
MetricsExecutionClientVersion.WithLabelValues(version).Set(1)
127141
}
128142

129-
dkgResult, err := queries.GetDKGResultForKeyperConfigIndex(context.Background(), eons[len(eons)-1].KeyperConfigIndex)
143+
eons, err := queries.GetAllEons(ctx)
130144
if err != nil {
131-
MetricsKeyperDKGstatus.WithLabelValues(strconv.FormatInt(eons[len(eons)-1].Eon, 10)).Set(0)
132-
log.Error().Err(err).Msg("keypermetrics | Failed to get dkg result")
133-
return
145+
log.Error().Err(err).Msg("keypermetrics | Failed to fetch eons")
146+
} else if len(eons) == 0 {
147+
log.Warn().Msg("keypermetrics | No eons found")
134148
}
135-
if dkgResult.Success {
136-
MetricsKeyperDKGstatus.WithLabelValues(strconv.FormatInt(eons[len(eons)-1].Eon, 10)).Set(1)
137-
} else {
138-
MetricsKeyperDKGstatus.WithLabelValues(strconv.FormatInt(eons[len(eons)-1].Eon, 10)).Set(0)
149+
150+
if len(eons) > 0 {
151+
currentEon := eons[len(eons)-1]
152+
153+
MetricsKeyperCurrentEon.Set(float64(currentEon.Eon))
154+
155+
MetricsKeyperCurrentBatchConfigIndex.Set(float64(currentEon.KeyperConfigIndex))
156+
157+
for _, eon := range eons {
158+
eonStr := strconv.FormatInt(eon.Eon, 10)
159+
MetricsKeyperEonStartBlock.WithLabelValues(eonStr).Set(float64(eon.ActivationBlockNumber))
160+
}
161+
162+
// Populate MetricsKeyperDKGStatus
163+
dkgResults, err := queries.GetAllDKGResults(ctx)
164+
if err != nil {
165+
log.Error().Err(err).Msg("keypermetrics | Failed to fetch DKG results")
166+
} else {
167+
dkgResultMap := make(map[int64]database.DkgResult)
168+
for _, result := range dkgResults {
169+
dkgResultMap[result.Eon] = result
170+
}
171+
172+
// Set DKG status for all eons
173+
for _, eon := range eons {
174+
eonStr := strconv.FormatInt(eon.Eon, 10)
175+
176+
if dkgResult, exists := dkgResultMap[eon.Eon]; exists {
177+
var dkgStatusValue float64
178+
if dkgResult.Success {
179+
dkgStatusValue = 1
180+
}
181+
MetricsKeyperDKGStatus.WithLabelValues(eonStr).Set(dkgStatusValue)
182+
} else {
183+
// No DKG result found for this eon, set to 0
184+
MetricsKeyperDKGStatus.WithLabelValues(eonStr).Set(0)
185+
}
186+
}
187+
}
139188
}
140189

141-
version, err := chainsync.GetClientVersion(context.Background(), config.Ethereum.EthereumURL)
190+
// Populate MetricsKeyperBatchConfigInfo && MetricsKeyperIsKeyper
191+
batchConfigs, err := queries.GetBatchConfigs(ctx)
142192
if err != nil {
143-
log.Error().Err(err).Msg("execution_client_version metrics | Failed to get execution client version")
144-
return
193+
log.Error().Err(err).Msg("keypermetrics | Failed to fetch batch configs")
194+
} else {
195+
currentAddress := config.GetAddress().Hex()
196+
197+
for _, batchConfig := range batchConfigs {
198+
batchConfigIndexStr := strconv.Itoa(int(batchConfig.KeyperConfigIndex))
199+
200+
// Join keyper addresses for the label
201+
keyperAddresses := strings.Join(batchConfig.Keypers, ",")
202+
MetricsKeyperBatchConfigInfo.WithLabelValues(batchConfigIndexStr, keyperAddresses).Set(1)
203+
204+
// Check if current node is a keyper in this batch config
205+
isKeyper := false
206+
for _, keyperAddr := range batchConfig.Keypers {
207+
if strings.EqualFold(keyperAddr, currentAddress) {
208+
isKeyper = true
209+
break
210+
}
211+
}
212+
213+
var isKeyperValue float64
214+
if isKeyper {
215+
isKeyperValue = 1
216+
}
217+
MetricsKeyperIsKeyper.WithLabelValues(batchConfigIndexStr).Set(isKeyperValue)
218+
}
145219
}
146220

147-
executionClientVersion := prometheus.NewGauge(
148-
prometheus.GaugeOpts{
149-
Namespace: "shutter",
150-
Subsystem: "keyper",
151-
Name: "execution_client_version",
152-
Help: "Version of the execution client",
153-
ConstLabels: prometheus.Labels{
154-
"version": version,
155-
},
156-
},
157-
)
158-
executionClientVersion.Set(1)
159-
160-
prometheus.MustRegister(executionClientVersion)
161-
metricsKeyperEthAddress := prometheus.NewGauge(
162-
prometheus.GaugeOpts{
163-
Namespace: "shutter",
164-
Subsystem: "keyper",
165-
Name: "address",
166-
Help: "Ethereum address of the Keyper",
167-
ConstLabels: prometheus.Labels{
168-
"address": config.GetAddress().Hex(),
169-
},
170-
},
171-
)
172-
metricsKeyperEthAddress.Set(1)
173-
174-
prometheus.MustRegister(metricsKeyperEthAddress)
221+
log.Info().Msg("keypermetrics | Metrics population completed")
175222
}

rolling-shutter/keyper/smobserver/smstate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ func (st *ShuttermintState) finalizeDKG(
489489
dkgresultmsg := shmsg.NewDKGResult(eon, err == nil)
490490

491491
if err != nil {
492-
keypermetrics.MetricsKeyperDKGstatus.WithLabelValues(strconv.FormatUint(eon, 10)).Set(0)
492+
keypermetrics.MetricsKeyperDKGStatus.WithLabelValues(strconv.FormatUint(eon, 10)).Set(0)
493493
log.Error().Err(err).Uint64("eon", eon).Bool("success", false).
494494
Msg("DKG process failed")
495495
dkgerror = sql.NullString{String: err.Error(), Valid: true}
@@ -498,7 +498,7 @@ func (st *ShuttermintState) finalizeDKG(
498498
return err
499499
}
500500
} else {
501-
keypermetrics.MetricsKeyperDKGstatus.WithLabelValues(strconv.FormatUint(eon, 10)).Set(1)
501+
keypermetrics.MetricsKeyperDKGStatus.WithLabelValues(strconv.FormatUint(eon, 10)).Set(1)
502502
log.Info().Uint64("eon", eon).Bool("success", true).Msg("DKG process succeeded")
503503
pureResult, err = shdb.EncodePureDKGResult(&dkgresult)
504504
if err != nil {

rolling-shutter/keyperimpl/gnosis/config.go

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,32 @@ func (c *Config) GetAddress() common.Address {
100100
}
101101

102102
type GnosisConfig struct {
103-
Node *configuration.EthnodeConfig `shconfig:",required"`
104-
Contracts *GnosisContractsConfig `shconfig:",required"`
105-
EncryptedGasLimit uint64 `shconfig:",required"`
106-
MinGasPerTransaction uint64 `shconfig:",required"`
107-
MaxTxPointerAge uint64 `shconfig:",required"`
108-
SecondsPerSlot uint64 `shconfig:",required"`
109-
SlotsPerEpoch uint64 `shconfig:",required"`
110-
GenesisSlotTimestamp uint64 `shconfig:",required"`
111-
SyncStartBlockNumber uint64 `shconfig:",required"`
112-
SyncMonitorCheckInterval uint64 `shconfig:",required"`
103+
Node *configuration.EthnodeConfig `shconfig:",required"`
104+
Contracts *GnosisContractsConfig `shconfig:",required"`
105+
EncryptedGasLimit uint64 `shconfig:",required"`
106+
MinGasPerTransaction uint64 `shconfig:",required"`
107+
MaxTxPointerAge uint64 `shconfig:",required"`
108+
SecondsPerSlot uint64 `shconfig:",required"`
109+
SlotsPerEpoch uint64 `shconfig:",required"`
110+
GenesisSlotTimestamp uint64 `shconfig:",required"`
111+
SyncStartBlockNumber uint64 `shconfig:",required"`
112+
SyncMonitorCheckInterval uint64 `shconfig:",required"`
113+
EnableAggregateValidatorRegistrationV1 bool `shconfig:",required"`
113114
}
114115

115116
func NewGnosisConfig() *GnosisConfig {
116117
c := &GnosisConfig{
117-
Node: configuration.NewEthnodeConfig(),
118-
Contracts: NewGnosisContractsConfig(),
119-
EncryptedGasLimit: 0,
120-
MinGasPerTransaction: 0,
121-
MaxTxPointerAge: 0,
122-
SecondsPerSlot: 0,
123-
SlotsPerEpoch: 0,
124-
GenesisSlotTimestamp: 0,
125-
SyncStartBlockNumber: 0,
126-
SyncMonitorCheckInterval: 0,
118+
Node: configuration.NewEthnodeConfig(),
119+
Contracts: NewGnosisContractsConfig(),
120+
EncryptedGasLimit: 0,
121+
MinGasPerTransaction: 0,
122+
MaxTxPointerAge: 0,
123+
SecondsPerSlot: 0,
124+
SlotsPerEpoch: 0,
125+
GenesisSlotTimestamp: 0,
126+
SyncStartBlockNumber: 0,
127+
SyncMonitorCheckInterval: 0,
128+
EnableAggregateValidatorRegistrationV1: false,
127129
}
128130
c.Init()
129131
return c
@@ -161,6 +163,7 @@ func (c *GnosisConfig) SetExampleValues() error {
161163
c.GenesisSlotTimestamp = 1665410700
162164
c.SyncStartBlockNumber = 0
163165
c.SyncMonitorCheckInterval = 30
166+
c.EnableAggregateValidatorRegistrationV1 = false
164167
return nil
165168
}
166169

0 commit comments

Comments
 (0)