-
Notifications
You must be signed in to change notification settings - Fork 33
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
[all] Communication #2234
[all] Communication #2234
Changes from 250 commits
1c39ae5
8f3fd07
2ceb862
2bf9f1a
00b4763
7322e4a
a015d9c
8b3781f
7e32266
068bf45
c26f784
3cd287a
19e6cca
ceecd0b
bb44ae2
c3cb568
72f2fff
c57fe11
e00e6bd
13adac2
9feba9c
b257ce3
f824f63
0afbc0a
2a1b3a7
171b5cc
d0d13d8
25cbbde
f6877eb
8dc26b3
ef389b6
bc775e6
1f32921
a46e5ce
a1b05c2
f231221
f84aea1
f968eb6
ec8cfdf
67f6dd6
666688b
09c4dff
e2644a9
d0c9449
784a36e
6f8ae1f
2c37a47
701c919
00da108
59e4d07
759f51e
c9a789f
e780c6a
52c0d64
169973a
d600050
485ef81
0fe13ff
3b35b11
d667beb
8dadc75
2d6dc04
60017a6
9fc12e9
82a00d6
80de15a
7f96319
353e4d3
ebb3300
83980dd
86ca547
f971f02
8930c83
fd0f3c1
999f496
a325fc9
e7ad96e
3e8aeee
43fe7a5
ed01ed5
207e894
b344693
3d99400
b388daf
b00033b
b58dd07
5fa006b
e5bd8e8
25d0311
a39ae11
1f2f20c
72766e2
e8fd130
d7f21bb
240eeba
e8cf23c
dd9e78c
45fa371
1ec8c79
7cb935f
3f52f27
b285fd1
86dfe08
6f057cb
f7f8924
4b764b0
879b6fd
240aa0f
747b8b9
10d22a5
11d8edb
d6c16d0
8d20d26
ffacb6a
c1a2c00
596c242
89a1f2a
024a059
2ee7e45
aa549c4
b424f10
e8194d3
f24071b
d2fe1d4
c2f6833
343f132
02d7e7d
9ff6ecf
09bf5a6
57306ac
932d5a4
b447050
8b03919
947d00e
cf43411
103eaa8
6052813
6b71b4e
99a3789
30a109e
ca15b8b
06c1575
68e6537
c8bbb0a
89071de
23b782d
91cfef4
cb15e8a
17780e2
5a42ebe
66eda32
ddd347d
2315360
b945b81
9263917
b1801ac
7020474
8515a04
732916d
d48dbe8
78ab9e6
c9d31cc
9a60930
7b516ba
5f44ae4
ca919c6
62e8c27
5b3b94b
49772bb
dbb8b66
7f45d1b
d590340
c1cfe4a
c807b4f
9a39094
2150013
6f96f5d
842c699
2e7d400
4f2d08a
565233c
55e655e
8130cc0
faab935
50296d3
0da3b2e
06aa96a
354dc13
30b387b
ce88f15
2596af4
5057635
bcb3741
f73ee51
4d7f846
0afc282
2c98aad
e756f47
0a09ba5
c444ce5
e4f4090
2a47c71
ce7d4e9
ae3b197
93e8af8
b0c0b02
7a43dd3
2cc0009
7fb3ec7
87ac5c3
092b578
55072b6
d2717b6
5fe38c4
bfb7343
2e00bf7
e372bd8
cf50b82
2cc0af4
3474489
91d68c3
c15ddf6
7fd2d8a
c9a24a8
1792ef2
3fbed08
32e4d8e
a77d8be
8e9ffa3
08421ad
679b474
a577904
9816040
d7da96c
d9ff4d7
7affb68
8ade4ba
611ac45
b8dfece
b69d0ea
ba2ffa7
e94a795
23a0eb3
4426ffd
34b4810
125cbdb
a6e6f06
13addf2
7347f47
fa5a09a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,4 @@ fastcache.tmp* | |
# ignore all go built files in local dirs | ||
main | ||
.devnet/ | ||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
project_name: committee | ||
|
||
monorepo: | ||
tag_prefix: committee/ | ||
dir: committee/ | ||
|
||
builds: | ||
# Linux AMD64 | ||
- id: committee | ||
binary: committee | ||
ldflags: | ||
# We need to build a static binary because we are building in a glibc based system and running in a musl container | ||
- -s -w -extldflags '-static' | ||
# see above about workaround | ||
tags: | ||
- netgo | ||
- osusergo | ||
env: | ||
- CC=gcc | ||
- CXX=g++ | ||
main: main.go | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
# add a source archive at release time | ||
source: | ||
enabled: true | ||
|
||
# Archives | ||
archives: | ||
- format: tar.gz | ||
wrap_in_directory: true | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
name_template: '{{.ProjectName}}-{{.Version}}_{{.Os}}_{{.Arch}}' | ||
files: | ||
- README.md | ||
|
||
checksum: | ||
name_template: checksums.txt | ||
|
||
# Add a changelog | ||
changelog: | ||
sort: asc | ||
|
||
dockers: | ||
# Linux AMD64 | ||
- goos: linux | ||
goarch: amd64 | ||
image_templates: | ||
- 'ghcr.io/synapsecns/sanguine/committee:latest' | ||
- 'ghcr.io/synapsecns/sanguine/committee:{{ .FullCommit }}' | ||
- 'ghcr.io/synapsecns/sanguine/committee:{{ .Tag }}' | ||
build_flag_templates: | ||
- '--label=org.opencontainers.image.created={{.Date}}' | ||
- '--label=org.opencontainers.image.name={{.ProjectName}}' | ||
- '--label=org.opencontainers.image.revision={{.FullCommit}}' | ||
- '--label=org.opencontainers.image.version={{.Version}}' | ||
- '--label=org.opencontainers.image.source={{.GitURL}}' | ||
dockerfile: ../docker/committee.Dockerfile | ||
ids: | ||
- committee |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include ../make/go.Makefile | ||
|
||
generate: ## Generate code | ||
cd $(GIT_ROOT)/packages/contracts-communication && yarn build:go | ||
go generate ./... | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Committee | ||
|
||
Committee is an example implementation of a SIN committee. It is based on libp2p. | ||
|
||
## Networking | ||
|
||
Committee uses libp2p for networking. It uses the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Package cmd provides the command line interface for the committee node. | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/synapsecns/sanguine/core/commandline" | ||
"github.com/synapsecns/sanguine/core/config" | ||
"github.com/synapsecns/sanguine/core/metrics" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
// Start starts the committee node. | ||
func Start(args []string, buildInfo config.BuildInfo) { | ||
app := cli.NewApp() | ||
app.Name = buildInfo.Name() | ||
app.Description = buildInfo.VersionString() + "committee provider for synapse" | ||
app.Usage = fmt.Sprintf("%s --help", buildInfo.Name()) | ||
app.EnableBashCompletion = true | ||
|
||
app.Before = func(c *cli.Context) error { | ||
// nolint:wrapcheck | ||
return metrics.Setup(c.Context, buildInfo) | ||
} | ||
|
||
// commands | ||
app.Commands = cli.Commands{runCommand} | ||
shellCommand := commandline.GenerateShellCommand(app.Commands) | ||
app.Commands = append(app.Commands, shellCommand) | ||
app.Action = shellCommand.Action | ||
|
||
err := app.Run(args) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/synapsecns/sanguine/committee/config" | ||
"github.com/synapsecns/sanguine/committee/node" | ||
"github.com/synapsecns/sanguine/core/commandline" | ||
"github.com/synapsecns/sanguine/core/metrics" | ||
"github.com/urfave/cli/v2" | ||
"gopkg.in/yaml.v2" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
var configFlag = &cli.StringFlag{ | ||
Name: "config", | ||
Usage: "path to the config file", | ||
TakesFile: true, | ||
} | ||
|
||
var runCommand = &cli.Command{ | ||
Name: "run", | ||
Description: "run the committee node", | ||
Flags: []cli.Flag{ | ||
configFlag, | ||
&commandline.LogLevel, | ||
}, | ||
Action: func(c *cli.Context) error { | ||
commandline.SetLogLevel(c) | ||
|
||
input, err := os.ReadFile(filepath.Clean(c.String(configFlag.Name))) | ||
if err != nil { | ||
return fmt.Errorf("could not read config file: %w", err) | ||
} | ||
|
||
metricsProvider := metrics.Get() | ||
|
||
var cfg config.Config | ||
// TODO: consider moving this for marshal/unmarshall tests | ||
err = yaml.Unmarshal(input, &cfg) | ||
if err != nil { | ||
return fmt.Errorf("could not unmarshal config: %w", err) | ||
} | ||
|
||
createdNode, err := node.NewNode(c.Context, metricsProvider, cfg) | ||
if err != nil { | ||
return fmt.Errorf("could not create node: %w", err) | ||
} | ||
|
||
err = createdNode.Start(c.Context) | ||
if err != nil { | ||
return fmt.Errorf("could not start node: %w", err) | ||
} | ||
return nil | ||
}, | ||
} | ||
trajan0x marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Package config provides the configuration for the Synapse module. | ||
package config | ||
|
||
import ( | ||
"github.com/synapsecns/sanguine/ethergo/signer/config" | ||
submitterConfig "github.com/synapsecns/sanguine/ethergo/submitter/config" | ||
) | ||
|
||
// Config is the config for the Synapse module. | ||
type Config struct { | ||
// Chains is a map of chain IDs to chain configs. | ||
Chains map[int]string `yaml:"chains"` | ||
// OmnirpcURL is the URL of the Omni RPC. | ||
OmnirpcURL string `yaml:"omnirpc_url"` | ||
// Database is the database config. | ||
Database DatabaseConfig `yaml:"database"` | ||
// Signer is the signer config. | ||
Signer config.SignerConfig `yaml:"signer"` | ||
// Submitter is the submitter config. | ||
SubmitterConfig submitterConfig.Config `yaml:"submitter_config"` | ||
// ShouldRelay is whether the node should relay. | ||
ShouldRelay bool `yaml:"should_relay"` | ||
// BootstrapPeers is the list of bootstrap peers. | ||
BootstrapPeers []string `yaml:"bootstrap_peers"` | ||
// P2PPort is the port for the p2p server. | ||
P2PPort int `yaml:"p2p_port"` | ||
// UsePeerID is wether or not to use the secp256k1 key for peer identification. This is a beta feature and currently can lead to rate limits/high bills on kms so should be turned off for now. | ||
UsePeerID bool `yaml:"use_peer_id"` | ||
} | ||
|
||
// DatabaseConfig represents the configuration for the database. | ||
type DatabaseConfig struct { | ||
Type string `yaml:"type"` | ||
DSN string `yaml:"dsn"` // Data Source Name | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package interchaindb contains the abi and contract bindings for the interchaindb contract. | ||
package interchaindb |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package interchaindb | ||
|
||
//go:generate go run github.com/synapsecns/sanguine/tools/abigen generate --sol ../../../packages/contracts-communication/flattened/InterchainDB.sol --pkg interchaindb --sol-version 0.8.20 --filename interchaindb --evm-version istanbul |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,35 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
package interchaindb | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
import ( | ||||||||||||||||||||||||||||||||||||||||||||||
"fmt" | ||||||||||||||||||||||||||||||||||||||||||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||||||||||||||||||||||||||||||||||||||||||||||
"github.com/ethereum/go-ethereum/common" | ||||||||||||||||||||||||||||||||||||||||||||||
"github.com/ethereum/go-ethereum/core/vm" | ||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// InterchainDBRef is a reference to a InterchainDB. | ||||||||||||||||||||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||||||||||||||||||||
// nolint: golint | ||||||||||||||||||||||||||||||||||||||||||||||
type InterchainDBRef struct { | ||||||||||||||||||||||||||||||||||||||||||||||
*InterchainDB | ||||||||||||||||||||||||||||||||||||||||||||||
address common.Address | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// Address is the contract address. | ||||||||||||||||||||||||||||||||||||||||||||||
func (s *InterchainDBRef) Address() common.Address { | ||||||||||||||||||||||||||||||||||||||||||||||
return s.address | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
// NewInterchainDBRef creates a new SynapseModulf with a contract ref. | ||||||||||||||||||||||||||||||||||||||||||||||
func NewInterchainDBRef(address common.Address, backend bind.ContractBackend) (*InterchainDBRef, error) { | ||||||||||||||||||||||||||||||||||||||||||||||
instance, err := NewInterchainDB(address, backend) | ||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||
return nil, fmt.Errorf("could not create instance of InterchainDB: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
return &InterchainDBRef{ | ||||||||||||||||||||||||||||||||||||||||||||||
InterchainDB: instance, | ||||||||||||||||||||||||||||||||||||||||||||||
address: address, | ||||||||||||||||||||||||||||||||||||||||||||||
}, nil | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+23
to
+33
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. The function - // NewInterchainDBRef creates a new SynapseModulf with a contract ref.
+ // NewInterchainDBRef creates a new InterchainDBRef with a contract ref. Additionally, consider adding more detailed documentation about the parameters and the return values for better clarity. Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
var _ vm.ContractRef = &InterchainDBRef{} |
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
generate
target correctly changes the directory to runyarn build:go
and then runsgo generate ./...
. To improve clarity and maintainability, consider using a subshell for the directory change or explicitly navigating back to the original directory. This ensures that the directory change is temporary and does not affect subsequent commands.For example, using a subshell:
Or, explicitly navigating back: