Skip to content

Commit bae90ac

Browse files
author
ylembachar
committed
add sync monitor config
1 parent 9d611d1 commit bae90ac

File tree

7 files changed

+42
-26
lines changed

7 files changed

+42
-26
lines changed

play/manual/keyper-0.toml

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ CustomBootstrapAddresses = ['/ip4/127.0.0.1/tcp/2001/p2p/12D3KooWMyutShWdqYj7fre
1515
Environment = "local"
1616
DiscoveryNamespace = "shutter-42"
1717

18+
[P2P.FloodSubDiscovery]
19+
enabled = false
20+
1821
[Gnosis]
1922
EncryptedGasLimit = 1000000
2023
MinGasPerTransaction = 21000
@@ -23,6 +26,7 @@ SecondsPerSlot = 5
2326
SlotsPerEpoch = 16
2427
GenesisSlotTimestamp = 1665396300
2528
SyncStartBlockNumber = 0
29+
SyncMonitorCheckInterval = 30
2630

2731
[Gnosis.Node]
2832
PrivateKey = 'dcb23da56656b3c8a11e2b4cdd92f430c500862f7f7fc762807d11b734e9500c'

play/manual/keyper-1.toml

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ CustomBootstrapAddresses = ['/ip4/127.0.0.1/tcp/2001/p2p/12D3KooWMyutShWdqYj7fre
1515
Environment = "local"
1616
DiscoveryNamespace = "shutter-42"
1717

18+
[P2P.FloodSubDiscovery]
19+
enabled = false
20+
1821
[Gnosis]
1922
EncryptedGasLimit = 1000000
2023
MinGasPerTransaction = 21000
@@ -23,6 +26,7 @@ SecondsPerSlot = 5
2326
SlotsPerEpoch = 16
2427
GenesisSlotTimestamp = 1665396300
2528
SyncStartBlockNumber = 0
29+
SyncMonitorCheckInterval = 30
2630

2731
[Gnosis.Node]
2832
PrivateKey = '00b4a53228e3761ad78bd376b8293f19af36777f71d8e55a61975f8eecd8c1c1'

play/manual/keyper-2.toml

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ CustomBootstrapAddresses = ['/ip4/127.0.0.1/tcp/2001/p2p/12D3KooWMyutShWdqYj7fre
1515
Environment = "local"
1616
DiscoveryNamespace = "shutter-42"
1717

18+
[P2P.FloodSubDiscovery]
19+
enabled = false
20+
1821
[Gnosis]
1922
EncryptedGasLimit = 1000000
2023
MinGasPerTransaction = 21000
@@ -23,6 +26,7 @@ SecondsPerSlot = 5
2326
SlotsPerEpoch = 16
2427
GenesisSlotTimestamp = 1665396300
2528
SyncStartBlockNumber = 0
29+
SyncMonitorCheckInterval = 30
2630

2731
[Gnosis.Node]
2832
PrivateKey = 'a4e901b1df81ff8fc5fa77f5bf0c15a4c8410e85fcaf19fbec47a2241b9d65d6'

rolling-shutter/keyperimpl/gnosis/config.go

+21-18
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,30 @@ func (c *Config) GetAddress() common.Address {
9898
}
9999

100100
type GnosisConfig struct {
101-
Node *configuration.EthnodeConfig `shconfig:",required"`
102-
Contracts *GnosisContractsConfig `shconfig:",required"`
103-
EncryptedGasLimit uint64 `shconfig:",required"`
104-
MinGasPerTransaction uint64 `shconfig:",required"`
105-
MaxTxPointerAge uint64 `shconfig:",required"`
106-
SecondsPerSlot uint64 `shconfig:",required"`
107-
SlotsPerEpoch uint64 `shconfig:",required"`
108-
GenesisSlotTimestamp uint64 `shconfig:",required"`
109-
SyncStartBlockNumber uint64 `shconfig:",required"`
101+
Node *configuration.EthnodeConfig `shconfig:",required"`
102+
Contracts *GnosisContractsConfig `shconfig:",required"`
103+
EncryptedGasLimit uint64 `shconfig:",required"`
104+
MinGasPerTransaction uint64 `shconfig:",required"`
105+
MaxTxPointerAge uint64 `shconfig:",required"`
106+
SecondsPerSlot uint64 `shconfig:",required"`
107+
SlotsPerEpoch uint64 `shconfig:",required"`
108+
GenesisSlotTimestamp uint64 `shconfig:",required"`
109+
SyncStartBlockNumber uint64 `shconfig:",required"`
110+
SyncMonitorCheckInterval uint64 `shconfig:",required"`
110111
}
111112

112113
func NewGnosisConfig() *GnosisConfig {
113114
c := &GnosisConfig{
114-
Node: configuration.NewEthnodeConfig(),
115-
Contracts: NewGnosisContractsConfig(),
116-
EncryptedGasLimit: 0,
117-
MinGasPerTransaction: 0,
118-
MaxTxPointerAge: 0,
119-
SecondsPerSlot: 0,
120-
SlotsPerEpoch: 0,
121-
GenesisSlotTimestamp: 0,
122-
SyncStartBlockNumber: 0,
115+
Node: configuration.NewEthnodeConfig(),
116+
Contracts: NewGnosisContractsConfig(),
117+
EncryptedGasLimit: 0,
118+
MinGasPerTransaction: 0,
119+
MaxTxPointerAge: 0,
120+
SecondsPerSlot: 0,
121+
SlotsPerEpoch: 0,
122+
GenesisSlotTimestamp: 0,
123+
SyncStartBlockNumber: 0,
124+
SyncMonitorCheckInterval: 0,
123125
}
124126
c.Init()
125127
return c
@@ -156,6 +158,7 @@ func (c *GnosisConfig) SetExampleValues() error {
156158
c.SlotsPerEpoch = 16
157159
c.GenesisSlotTimestamp = 1665410700
158160
c.SyncStartBlockNumber = 0
161+
c.SyncMonitorCheckInterval = 30
159162
return nil
160163
}
161164

rolling-shutter/keyperimpl/gnosis/keyper.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ func (kpr *Keyper) Start(ctx context.Context, runner service.Runner) error {
157157
}
158158

159159
kpr.syncMonitor = &SyncMonitor{
160-
DBPool: kpr.dbpool,
160+
DBPool: kpr.dbpool,
161+
CheckInterval: time.Duration(kpr.config.Gnosis.SyncMonitorCheckInterval) * time.Second,
161162
}
162163

163164
runner.Go(func() error { return kpr.processInputs(ctx) })

rolling-shutter/keyperimpl/gnosis/syncmonitor.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ import (
1212
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/service"
1313
)
1414

15-
const (
16-
checkInterval = 30 * time.Second
17-
)
18-
1915
type SyncMonitor struct {
20-
DBPool *pgxpool.Pool
16+
DBPool *pgxpool.Pool
17+
CheckInterval time.Duration
2118
}
2219

2320
func (s *SyncMonitor) Start(ctx context.Context, runner service.Runner) error {
@@ -32,9 +29,11 @@ func (s *SyncMonitor) runMonitor(ctx context.Context) error {
3229
var lastBlockNumber int64
3330
db := database.New(s.DBPool)
3431

32+
log.Debug().Msg("starting the sync monitor")
33+
3534
for {
3635
select {
37-
case <-time.After(checkInterval):
36+
case <-time.After(s.CheckInterval):
3837
record, err := db.GetTransactionSubmittedEventsSyncedUntil(ctx)
3938
if err != nil {
4039
log.Warn().Err(err).Msg("error fetching block number")

rolling-shutter/keyperimpl/gnosis/syncmonitor_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ func TestSyncMonitor_ThrowsErrorWhenBlockNotIncreasing(t *testing.T) {
4343
}
4444

4545
monitor := &gnosis.SyncMonitor{
46-
DBPool: dbpool,
46+
DBPool: dbpool,
47+
CheckInterval: 30 * time.Second,
4748
}
4849

4950
errCh := make(chan error, 1)

0 commit comments

Comments
 (0)