-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shutter service #560
Open
blockchainluffy
wants to merge
57
commits into
main
Choose a base branch
from
shutter-service
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Shutter service #560
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
ddb320a
shutter-service: basic setup
blockchainluffy 873d0a7
shutter-service: added trigger conditions
blockchainluffy a631319
shutter-service: implemented triggers
blockchainluffy 743de42
shutter-service: added command to run
blockchainluffy 6121f53
shutter-service: added msg middleware
blockchainluffy 7b9970a
shutter-service: implemented middleware for decryption keys message
blockchainluffy fb6db69
shutter-service: added message handlers
blockchainluffy c507bf1
shutter-service: update events table when keys are released
blockchainluffy 0c8529d
shutter-service: fixed executable to run commands
blockchainluffy bb706eb
shutter-service: added registry syncer
blockchainluffy 00f386a
shutter-service: updated database connectivity version
blockchainluffy 7454b26
shutter-service: updated get registration query
blockchainluffy a6d37a2
add filte test
faheelsattar 34e46c8
fix sql schema and queries
faheelsattar 5ce9983
add insert test
faheelsattar c83d171
update error message
faheelsattar 83cd239
fix logs
faheelsattar 7040b64
shutter-service: tested registry syncer
blockchainluffy 15cb080
shutter-service: updated queries and schema
blockchainluffy fd5253a
Merge pull request #564 from shutter-network/test/registry-event
faheelsattar 616305d
shutter-service: updated decryption trigger handling
blockchainluffy 4c505e9
shutter-service: updated decryption signature encoding
blockchainluffy 00e5747
shutter-service: updated decryption signature table
blockchainluffy 9e02271
add key share test
faheelsattar 4681096
dec keys release test
faheelsattar 146975d
upd doc
faheelsattar bade3e5
clean test
faheelsattar 554afe9
validate and handle dec keys test
faheelsattar 8964786
add invalidate dec key msg test
faheelsattar 6aab5f6
shutter-service: added identity to registered events table
blockchainluffy 4cfd837
shutter-service: fixed flag updation
blockchainluffy f52e859
Merge pull request #565 from shutter-network/test/new-handlers
blockchainluffy 89577e7
shutter-service: fix error check
faheelsattar 61a9f0b
process block test
faheelsattar f4e6001
add test for can be triggered
faheelsattar af1831b
shutter-serice: add test when decryption cant be triggered
faheelsattar 33bef97
shutter-service: fix update latest trigger time after err check
faheelsattar 3a615cf
shutter-service: remove unnecessary map initialization
faheelsattar 9b73241
shutter-service: update latest trigger time at last
faheelsattar 1a37167
shutter-service: fix pre commit
blockchainluffy 7c72e6c
upd latestTriggeredTime at start
faheelsattar 50e59ef
shutter-service: fix lint ci
blockchainluffy 219a7bc
shutter-service: remove math/rand pkg
faheelsattar 5f512cd
shutter-service: pass event without reference
faheelsattar b5c0de2
shutter-service: remove math/rand pkg
faheelsattar ba37ab3
shutter-service: upd random byte generator function
faheelsattar 7425f0c
Merge branch 'shutter-service' into test/newblock-dec-trigger
faheelsattar 5bb3141
Merge pull request #566 from shutter-network/test/newblock-dec-trigger
blockchainluffy 77148df
shutter-service: fix precommit ci
blockchainluffy 57f80ee
shutter-service: updated comment
blockchainluffy 85e4578
shutter-service: update protoc version
blockchainluffy f6dc1a2
shutter-service: added helpers to test
blockchainluffy c98b26a
shutter-service: added readme files
blockchainluffy dee7f84
shutter-service: refactor test
blockchainluffy 816c5e7
shutter-service: refactor test
blockchainluffy 4953891
shutter-service: updated contracts version
blockchainluffy 12c2328
shutter-service: updated contracts repo go module
blockchainluffy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package shutterservice | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v4/pgxpool" | ||
"github.com/pkg/errors" | ||
"github.com/rs/zerolog/log" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/shversion" | ||
keyper "github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/shutterservice" | ||
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/shutterservice/database" | ||
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/configuration/command" | ||
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/db" | ||
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/service" | ||
) | ||
|
||
func Cmd() *cobra.Command { | ||
builder := command.Build( | ||
main, | ||
command.Usage( | ||
"Run a Shutter keyper for Shutter Service", | ||
`This command runs a keyper node. It will connect to both a Shutter service and a | ||
Shuttermint node which have to be started separately in advance.`, | ||
), | ||
command.WithGenerateConfigSubcommand(), | ||
command.WithDumpConfigSubcommand(), | ||
) | ||
builder.AddInitDBCommand(initDB) | ||
return builder.Command() | ||
} | ||
|
||
func main(config *keyper.Config) error { | ||
log.Info(). | ||
Str("version", shversion.Version()). | ||
Str("address", config.GetAddress().Hex()). | ||
Str("shuttermint", config.Shuttermint.ShuttermintURL). | ||
Msg("starting shutter service keyper") | ||
|
||
kpr := keyper.New(config) | ||
return service.RunWithSighandler(context.Background(), kpr) | ||
} | ||
|
||
func initDB(cfg *keyper.Config) error { | ||
ctx := context.Background() | ||
dbpool, err := pgxpool.Connect(ctx, cfg.DatabaseURL) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to connect to database") | ||
} | ||
defer dbpool.Close() | ||
return db.InitDB(ctx, dbpool, database.Definition.Name(), database.Definition) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## rolling-shutter shutterservice | ||
|
||
Run a Shutter keyper for Shutter Service | ||
|
||
### Synopsis | ||
|
||
This command runs a keyper node. It will connect to both a Shutter service and a | ||
Shuttermint node which have to be started separately in advance. | ||
|
||
``` | ||
rolling-shutter shutterservice [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
--config string config file | ||
-h, --help help for shutterservice | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--logformat string set log format, possible values: min, short, long, max (default "long") | ||
--loglevel string set log level, possible values: warn, info, debug (default "info") | ||
--no-color do not write colored logs | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [rolling-shutter](rolling-shutter.md) - A collection of commands to run and interact with Rolling Shutter nodes | ||
* [rolling-shutter shutterservice dump-config](rolling-shutter_shutterservice_dump-config.md) - Dump a 'shutterservice' configuration file, based on given config and env vars | ||
* [rolling-shutter shutterservice generate-config](rolling-shutter_shutterservice_generate-config.md) - Generate a 'shutterservice' configuration file | ||
* [rolling-shutter shutterservice initdb](rolling-shutter_shutterservice_initdb.md) - Initialize the database of the 'shutterservice' | ||
|
29 changes: 29 additions & 0 deletions
29
rolling-shutter/docs/rolling-shutter_shutterservice_dump-config.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## rolling-shutter shutterservice dump-config | ||
|
||
Dump a 'shutterservice' configuration file, based on given config and env vars | ||
|
||
``` | ||
rolling-shutter shutterservice dump-config [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
--config string config file | ||
-f, --force overwrite existing file | ||
-h, --help help for dump-config | ||
--output string output file | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--logformat string set log format, possible values: min, short, long, max (default "long") | ||
--loglevel string set log level, possible values: warn, info, debug (default "info") | ||
--no-color do not write colored logs | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [rolling-shutter shutterservice](rolling-shutter_shutterservice.md) - Run a Shutter keyper for Shutter Service | ||
|
29 changes: 29 additions & 0 deletions
29
rolling-shutter/docs/rolling-shutter_shutterservice_generate-config.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## rolling-shutter shutterservice generate-config | ||
|
||
Generate a 'shutterservice' configuration file | ||
|
||
``` | ||
rolling-shutter shutterservice generate-config [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-f, --force overwrite existing file | ||
-h, --help help for generate-config | ||
--output string output file | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string config file | ||
--logformat string set log format, possible values: min, short, long, max (default "long") | ||
--loglevel string set log level, possible values: warn, info, debug (default "info") | ||
--no-color do not write colored logs | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [rolling-shutter shutterservice](rolling-shutter_shutterservice.md) - Run a Shutter keyper for Shutter Service | ||
|
27 changes: 27 additions & 0 deletions
27
rolling-shutter/docs/rolling-shutter_shutterservice_initdb.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## rolling-shutter shutterservice initdb | ||
|
||
Initialize the database of the 'shutterservice' | ||
|
||
``` | ||
rolling-shutter shutterservice initdb [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for initdb | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string config file | ||
--logformat string set log format, possible values: min, short, long, max (default "long") | ||
--loglevel string set log level, possible values: warn, info, debug (default "info") | ||
--no-color do not write colored logs | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [rolling-shutter shutterservice](rolling-shutter_shutterservice.md) - Run a Shutter keyper for Shutter Service | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,153 @@ | ||||||||||||
package shutterservice | ||||||||||||
|
||||||||||||
import ( | ||||||||||||
"io" | ||||||||||||
|
||||||||||||
"github.com/ethereum/go-ethereum/common" | ||||||||||||
|
||||||||||||
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyper/kprconfig" | ||||||||||||
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/configuration" | ||||||||||||
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/metricsserver" | ||||||||||||
"github.com/shutter-network/rolling-shutter/rolling-shutter/p2p" | ||||||||||||
) | ||||||||||||
|
||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing an assignment check to verify the structs actually satisfy the interface. See for example: rolling-shutter/rolling-shutter/keyperimpl/gnosis/config.go Lines 21 to 25 in bae90ac
|
||||||||||||
func NewConfig() *Config { | ||||||||||||
c := &Config{} | ||||||||||||
c.Init() | ||||||||||||
return c | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *Config) Init() { | ||||||||||||
c.P2P = p2p.NewConfig() | ||||||||||||
c.Shuttermint = kprconfig.NewShuttermintConfig() | ||||||||||||
c.Metrics = metricsserver.NewConfig() | ||||||||||||
c.Chain = NewChainConfig() | ||||||||||||
} | ||||||||||||
|
||||||||||||
type Config struct { | ||||||||||||
InstanceID uint64 `shconfig:",required"` | ||||||||||||
DatabaseURL string `shconfig:",required" comment:"If it's empty, we use the standard PG_ environment variables"` | ||||||||||||
|
||||||||||||
HTTPEnabled bool | ||||||||||||
HTTPListenAddress string | ||||||||||||
|
||||||||||||
Chain *ChainConfig | ||||||||||||
P2P *p2p.Config | ||||||||||||
Shuttermint *kprconfig.ShuttermintConfig | ||||||||||||
Metrics *metricsserver.MetricsConfig | ||||||||||||
|
||||||||||||
MaxNumKeysPerMessage uint64 | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *Config) Validate() error { | ||||||||||||
// TODO: needs to be implemented | ||||||||||||
return nil | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *Config) Name() string { | ||||||||||||
return "shutterservice" | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *Config) SetDefaultValues() error { | ||||||||||||
c.HTTPEnabled = false | ||||||||||||
c.HTTPListenAddress = ":3000" | ||||||||||||
c.MaxNumKeysPerMessage = 500 // TODO: need to confirm on this | ||||||||||||
return nil | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *Config) SetExampleValues() error { | ||||||||||||
err := c.SetDefaultValues() | ||||||||||||
if err != nil { | ||||||||||||
return err | ||||||||||||
} | ||||||||||||
c.InstanceID = 42 | ||||||||||||
c.DatabaseURL = "postgres://pguser:pgpassword@localhost:5432/shutter" | ||||||||||||
|
||||||||||||
return nil | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c Config) TOMLWriteHeader(_ io.Writer) (int, error) { | ||||||||||||
return 0, nil | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *Config) GetAddress() common.Address { | ||||||||||||
return c.Chain.Node.PrivateKey.EthereumAddress() | ||||||||||||
} | ||||||||||||
|
||||||||||||
type ChainConfig struct { | ||||||||||||
Node *configuration.EthnodeConfig `shconfig:",required"` | ||||||||||||
Contracts *ContractsConfig `shconfig:",required"` | ||||||||||||
SyncStartBlockNumber uint64 `shconfig:",required"` | ||||||||||||
} | ||||||||||||
|
||||||||||||
func NewChainConfig() *ChainConfig { | ||||||||||||
c := &ChainConfig{ | ||||||||||||
Node: configuration.NewEthnodeConfig(), | ||||||||||||
Contracts: NewContractsConfig(), | ||||||||||||
SyncStartBlockNumber: 0, | ||||||||||||
} | ||||||||||||
c.Init() | ||||||||||||
return c | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ChainConfig) Init() { | ||||||||||||
c.Node.Init() | ||||||||||||
c.Contracts.Init() | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ChainConfig) Name() string { | ||||||||||||
return "chain" | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ChainConfig) Validate() error { | ||||||||||||
return nil | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ChainConfig) SetDefaultValues() error { | ||||||||||||
c.SyncStartBlockNumber = 0 | ||||||||||||
return c.Contracts.SetDefaultValues() | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ChainConfig) SetExampleValues() error { | ||||||||||||
return nil | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ChainConfig) TOMLWriteHeader(_ io.Writer) (int, error) { | ||||||||||||
return 0, nil | ||||||||||||
} | ||||||||||||
|
||||||||||||
type ContractsConfig struct { | ||||||||||||
KeyperSetManager common.Address `shconfig:",required"` | ||||||||||||
ShutterRegistry common.Address `shconfig:",required"` | ||||||||||||
KeyBroadcastContract common.Address `shconfig:",required"` | ||||||||||||
} | ||||||||||||
|
||||||||||||
func NewContractsConfig() *ContractsConfig { | ||||||||||||
return &ContractsConfig{ | ||||||||||||
KeyperSetManager: common.Address{}, | ||||||||||||
ShutterRegistry: common.Address{}, | ||||||||||||
KeyBroadcastContract: common.Address{}, | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ContractsConfig) Init() {} | ||||||||||||
|
||||||||||||
func (c *ContractsConfig) Name() string { | ||||||||||||
return "contracts" | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ContractsConfig) Validate() error { | ||||||||||||
return nil | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ContractsConfig) SetDefaultValues() error { | ||||||||||||
return nil | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ContractsConfig) SetExampleValues() error { | ||||||||||||
return nil | ||||||||||||
} | ||||||||||||
|
||||||||||||
func (c *ContractsConfig) TOMLWriteHeader(_ io.Writer) (int, error) { | ||||||||||||
return 0, nil | ||||||||||||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other keyper implementations all have
keyper
in their command name. I think we should keep that convention.