-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new node contract in registry (#107)
## tl;dr - Creates new `SmartContractRegistry` that polls the smart contract to get the latest state of the nodes - Refactored the config out of the `server` to avoid circular dependencies and allow config objects to be passed in to other modules - Added a `dev/run` command that populates all the environment variables required - Created a `notifier` struct to power the `SmartContractRegistry` and publish changes to subscriptions ## Why not use the indexer? We could get the same result from indexing the chain based on events. This seemed more straightforward. We don't care about historical state here, so processing old events is just going to create noise and complexity. When any node starts up it just needs a full picture of all the other nodes right now. We also don't have tight latency requirements: this contract moves in the cadence of days or weeks. Since we know the node list is going to be small forever, and this data is going to be frequently accessed, having it all live in memory is also way more performant.
- Loading branch information
Showing
29 changed files
with
1,568 additions
and
86 deletions.
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 |
---|---|---|
|
@@ -12,3 +12,6 @@ linters: | |
- ineffassign | ||
- staticcheck | ||
- unused | ||
issues: | ||
exclude-files: | ||
- tools.go |
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
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,11 @@ | ||
#!/bin/bash | ||
|
||
source dev/contracts/.env | ||
|
||
export CHAIN_RPC_URL=$DOCKER_RPC_URL # From contracts/.env | ||
export NODE_PRIVATE_KEY=$PRIVATE_KEY # From contracts/.env | ||
export WRITER_CONNECTION_STRING="postgres://postgres:xmtp@localhost:8765/postgres?sslmode=disable" | ||
NODES_CONTRACT_ADDRESS="$(jq -r '.deployedTo' build/Nodes.json)" # Built by contracts/deploy-local | ||
export NODES_CONTRACT_ADDRESS | ||
GROUP_MESSAGES_CONTRACT_ADDRESS="$(jq -r '.deployedTo' build/GroupMessages.json)" # Built by contracts/deploy-local | ||
export GROUP_MESSAGES_CONTRACT_ADDRESS |
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,12 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
. dev/local.env | ||
|
||
go run cmd/replication/main.go \ | ||
--db.writer-connection-string=$WRITER_CONNECTION_STRING \ | ||
--private-key=${NODE_PRIVATE_KEY} \ | ||
--contracts.nodes-address=$NODES_CONTRACT_ADDRESS \ | ||
--contracts.messages-address=$GROUP_MESSAGES_CONTRACT_ADDRESS \ | ||
--contracts.rpc-url=$CHAIN_RPC_URL |
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
Oops, something went wrong.