Skip to content

Commit 7425f0c

Browse files
authored
Merge branch 'shutter-service' into test/newblock-dec-trigger
2 parents ba37ab3 + 50e59ef commit 7425f0c

File tree

13 files changed

+33
-23
lines changed

13 files changed

+33
-23
lines changed

rolling-shutter/cmd/shutterservice/shutterservice.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import (
66
"github.com/jackc/pgx/v4/pgxpool"
77
"github.com/pkg/errors"
88
"github.com/rs/zerolog/log"
9+
"github.com/spf13/cobra"
10+
911
"github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/shversion"
1012
keyper "github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/shutterservice"
1113
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/shutterservice/database"
1214
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/configuration/command"
1315
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/db"
1416
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/service"
15-
"github.com/spf13/cobra"
1617
)
1718

1819
func Cmd() *cobra.Command {

rolling-shutter/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ require (
3131
github.com/pkg/errors v0.9.1
3232
github.com/prometheus/client_golang v1.19.1
3333
github.com/rs/zerolog v1.28.0
34+
github.com/shutter-network/contracts/v2 v2.0.0-beta.2.0.20241129172533-e843e747ddb1
3435
github.com/shutter-network/gnosh-contracts v0.4.0
3536
github.com/shutter-network/shop-contracts v0.0.0-20240407151512-08ef5d8355b6
3637
github.com/shutter-network/shutter/shlib v0.1.19
@@ -217,7 +218,6 @@ require (
217218
github.com/rs/cors v1.9.0 // indirect
218219
github.com/sasha-s/go-deadlock v0.3.1 // indirect
219220
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
220-
github.com/shutter-network/contracts/v2 v2.0.0-beta.2.0.20241129172533-e843e747ddb1 // indirect
221221
github.com/spaolacci/murmur3 v1.1.0 // indirect
222222
github.com/spf13/cast v1.5.1 // indirect
223223
github.com/spf13/jwalterweatherman v1.1.0 // indirect

rolling-shutter/keyperimpl/shutterservice/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"io"
55

66
"github.com/ethereum/go-ethereum/common"
7+
78
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyper/kprconfig"
89
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/configuration"
910
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/metricsserver"
@@ -39,7 +40,7 @@ type Config struct {
3940
}
4041

4142
func (c *Config) Validate() error {
42-
//TODO: needs to be implemented
43+
// TODO: needs to be implemented
4344
return nil
4445
}
4546

@@ -50,7 +51,7 @@ func (c *Config) Name() string {
5051
func (c *Config) SetDefaultValues() error {
5152
c.HTTPEnabled = false
5253
c.HTTPListenAddress = ":3000"
53-
c.MaxNumKeysPerMessage = 500 //TODO: need to confirm on this
54+
c.MaxNumKeysPerMessage = 500 // TODO: need to confirm on this
5455
return nil
5556
}
5657

@@ -104,7 +105,7 @@ func (c *ChainConfig) Validate() error {
104105

105106
func (c *ChainConfig) SetDefaultValues() error {
106107
c.SyncStartBlockNumber = 0
107-
return nil
108+
return c.Contracts.SetDefaultValues()
108109
}
109110

110111
func (c *ChainConfig) SetExampleValues() error {

rolling-shutter/keyperimpl/shutterservice/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
pubsub "github.com/libp2p/go-libp2p-pubsub"
99
"github.com/pkg/errors"
1010
"github.com/rs/zerolog/log"
11+
1112
obskeyperdatabase "github.com/shutter-network/rolling-shutter/rolling-shutter/chainobserver/db/keyper"
1213
corekeyperdatabase "github.com/shutter-network/rolling-shutter/rolling-shutter/keyper/database"
1314
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/shutterservice/database"
@@ -28,7 +29,6 @@ func (h *DecryptionKeySharesHandler) MessagePrototypes() []p2pmsg.Message {
2829
}
2930

3031
func (h *DecryptionKeySharesHandler) ValidateMessage(ctx context.Context, msg p2pmsg.Message) (pubsub.ValidationResult, error) {
31-
//TODO: should we implement some check that this identity is to be decrypted even or not, or this can be taken care of by implementing triggered block in decTrigger?
3232
keyShares := msg.(*p2pmsg.DecryptionKeyShares)
3333
extra, ok := keyShares.Extra.(*p2pmsg.DecryptionKeyShares_Service)
3434
if !ok {

rolling-shutter/keyperimpl/shutterservice/handlers_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88

99
"github.com/ethereum/go-ethereum/common"
1010
pubsub "github.com/libp2p/go-libp2p-pubsub"
11+
"gotest.tools/assert"
12+
1113
obskeyperdatabase "github.com/shutter-network/rolling-shutter/rolling-shutter/chainobserver/db/keyper"
1214
corekeyperdatabase "github.com/shutter-network/rolling-shutter/rolling-shutter/keyper/database"
1315
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/shutterservice/database"
@@ -16,7 +18,6 @@ import (
1618
"github.com/shutter-network/rolling-shutter/rolling-shutter/p2p"
1719
"github.com/shutter-network/rolling-shutter/rolling-shutter/p2pmsg"
1820
"github.com/shutter-network/rolling-shutter/rolling-shutter/shdb"
19-
"gotest.tools/assert"
2021
)
2122

2223
func TestHandleDecryptionKeySharesThresholdNotReached(t *testing.T) {

rolling-shutter/keyperimpl/shutterservice/keyper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/pkg/errors"
1010
"github.com/rs/zerolog/log"
1111
registryBindings "github.com/shutter-network/contracts/v2/bindings/shutterregistry"
12+
"golang.org/x/exp/slog"
13+
1214
"github.com/shutter-network/rolling-shutter/rolling-shutter/eonkeypublisher"
1315
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyper"
1416
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyper/epochkghandler"
@@ -20,7 +22,6 @@ import (
2022
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/db"
2123
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/service"
2224
"github.com/shutter-network/rolling-shutter/rolling-shutter/p2p"
23-
"golang.org/x/exp/slog"
2425
)
2526

2627
var ErrParseKeyperSet = errors.New("cannot parse KeyperSet")
@@ -153,7 +154,7 @@ func (kpr *Keyper) initRegistrySyncer(ctx context.Context) error {
153154
return err
154155
}
155156

156-
//TODO: need to update go module after contract is finalised
157+
// TODO: need to update go module after contract is finalized
157158
kpr.registrySyncer = &RegistrySyncer{
158159
Contract: contract,
159160
DBPool: kpr.dbpool,
@@ -185,7 +186,6 @@ func (kpr *Keyper) processInputs(ctx context.Context) error {
185186
err = kpr.processNewKeyperSet(ctx, ev)
186187
case ev := <-kpr.newEonPublicKeys:
187188
err = kpr.processNewEonPublicKey(ctx, ev)
188-
//TODO: handle explicit decryption trigger, if needed
189189
case <-ctx.Done():
190190
return ctx.Err()
191191
}

rolling-shutter/keyperimpl/shutterservice/messagingmiddleware.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
pubsub "github.com/libp2p/go-libp2p-pubsub"
1010
"github.com/pkg/errors"
1111
"github.com/rs/zerolog/log"
12+
"google.golang.org/protobuf/proto"
13+
1214
obskeyperdatabase "github.com/shutter-network/rolling-shutter/rolling-shutter/chainobserver/db/keyper"
1315
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/shutterservice/database"
1416
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/shutterservice/serviceztypes"
@@ -17,7 +19,6 @@ import (
1719
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/service"
1820
"github.com/shutter-network/rolling-shutter/rolling-shutter/p2p"
1921
"github.com/shutter-network/rolling-shutter/rolling-shutter/p2pmsg"
20-
"google.golang.org/protobuf/proto"
2122
)
2223

2324
type MessagingMiddleware struct {
@@ -175,7 +176,7 @@ func (i *MessagingMiddleware) interceptDecryptionKeys(
175176
ctx context.Context,
176177
originalMsg *p2pmsg.DecryptionKeys,
177178
) (p2pmsg.Message, error) {
178-
//TODO: update flag in event table to notify the decryption is already done
179+
// TODO: update flag in event table to notify the decryption is already done
179180
if originalMsg.Extra != nil {
180181
return originalMsg, nil
181182
}
@@ -204,7 +205,8 @@ func (i *MessagingMiddleware) interceptDecryptionKeys(
204205
Limit: keyperSet.Threshold,
205206
})
206207
if err != nil {
207-
return nil, errors.Wrapf(err, "failed to count decryption signatures for eon %d and keyperConfigIndex %d", originalMsg.Eon, keyperSet.KeyperConfigIndex)
208+
return nil, errors.Wrapf(err, "failed to count decryption signatures for eon %d and keyperConfigIndex %d",
209+
originalMsg.Eon, keyperSet.KeyperConfigIndex)
208210
}
209211

210212
if len(signatures) < int(keyperSet.Threshold) {

rolling-shutter/keyperimpl/shutterservice/newblock.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/jackc/pgx/v4"
1010
"github.com/pkg/errors"
1111
"github.com/rs/zerolog/log"
12+
1213
obskeyper "github.com/shutter-network/rolling-shutter/rolling-shutter/chainobserver/db/keyper"
1314
corekeyperdatabase "github.com/shutter-network/rolling-shutter/rolling-shutter/keyper/database"
1415
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyper/epochkghandler"
@@ -46,10 +47,11 @@ func (kpr *Keyper) maybeTriggerDecryption(ctx context.Context, block *syncevent.
4647
fmt.Println("--------------")
4748

4849
serviceDB := servicedatabase.New(kpr.dbpool)
49-
nonTriggeredEvents, err := serviceDB.GetNotDecryptedIdentityRegisteredEvents(ctx, servicedatabase.GetNotDecryptedIdentityRegisteredEventsParams{
50-
Timestamp: int64(lastTriggeredTime),
51-
Timestamp_2: int64(block.Header.Time),
52-
})
50+
nonTriggeredEvents, err := serviceDB.GetNotDecryptedIdentityRegisteredEvents(ctx,
51+
servicedatabase.GetNotDecryptedIdentityRegisteredEventsParams{
52+
Timestamp: int64(lastTriggeredTime),
53+
Timestamp_2: int64(block.Header.Time),
54+
})
5355
if err != nil && err != pgx.ErrNoRows {
5456
// pgx.ErrNoRows is expected if we're not part of the keyper set (which is checked later).
5557
// That's because non-keypers don't sync identity registered events. TODO: this needs to be implemented

rolling-shutter/keyperimpl/shutterservice/newkeyperset.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/jackc/pgx/v4"
77
"github.com/pkg/errors"
88
"github.com/rs/zerolog/log"
9+
910
obskeyper "github.com/shutter-network/rolling-shutter/rolling-shutter/chainobserver/db/keyper"
1011
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley"
1112
syncevent "github.com/shutter-network/rolling-shutter/rolling-shutter/medley/chainsync/event"

rolling-shutter/keyperimpl/shutterservice/registrysyncer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/pkg/errors"
1616
"github.com/rs/zerolog/log"
1717
registryBindings "github.com/shutter-network/contracts/v2/bindings/shutterregistry"
18+
1819
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/shutterservice/database"
1920
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley"
2021
"github.com/shutter-network/rolling-shutter/rolling-shutter/shdb"
@@ -263,7 +264,7 @@ func (s *RegistrySyncer) insertIdentityRegisteredEvents(
263264
}
264265

265266
func computeIdentity(event *registryBindings.ShutterregistryIdentityRegistered) []byte {
266-
//TODO: may need to change this if we want to create identity other way
267+
// TODO: may need to change this if we want to create identity other way
267268
var buf bytes.Buffer
268269
buf.Write(event.IdentityPrefix[:])
269270
buf.Write(event.Sender.Bytes())

0 commit comments

Comments
 (0)