Skip to content
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

[P2P, Runtime] Update P2P & base config (part 2) #535

Merged
merged 22 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5ad835e
chore: add `hostname` p2p config field
bryanchriswhite Feb 22, 2023
e8934a7
chore: rename `consensus_port` config option to `port`
bryanchriswhite Feb 22, 2023
a350c20
chore: update default port number to 42069
bryanchriswhite Feb 22, 2023
e903a7c
chore: add `use_libp2p` config field
bryanchriswhite Feb 22, 2023
4b37d98
chore: update persistence state hash test
bryanchriswhite Feb 23, 2023
0ef6582
fix: docker composition / .env ports
bryanchriswhite Feb 24, 2023
0df649a
chore: update k8s manifests p2p config port
bryanchriswhite Feb 24, 2023
bf58cc5
chore: update changelogs
bryanchriswhite Feb 22, 2023
4c19fbb
fix: update port numbers in tests
bryanchriswhite Feb 24, 2023
2a379c3
chore: add `use_libp2p` to k8s configs
bryanchriswhite Feb 24, 2023
8643a0a
chore: update k8s validator template
bryanchriswhite Feb 24, 2023
7eb373c
chore: make ConfigMap a template
bryanchriswhite Feb 27, 2023
5b7c477
chore: add hostname to ConfigMap
bryanchriswhite Feb 27, 2023
a01610f
chore: update changelog
bryanchriswhite Feb 27, 2023
a073fae
Revert "chore: make ConfigMap a template"
bryanchriswhite Feb 28, 2023
fae0410
chore: add localnet hostname via env var
bryanchriswhite Feb 28, 2023
7e79a33
chore: update changelog
bryanchriswhite Feb 28, 2023
743d5cb
test: replace literal with constant
bryanchriswhite Feb 28, 2023
4278b65
chore: update changelog
bryanchriswhite Feb 28, 2023
06979c1
chore: update changelog
bryanchriswhite Feb 28, 2023
75e529d
Merge branch 'main' into chore/config
bryanchriswhite Mar 1, 2023
a931eb0
fix: state hash test post-merge
bryanchriswhite Mar 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build/config/config1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
"use_lib_p2p": false,
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
Expand Down Expand Up @@ -28,7 +29,8 @@
"health_check_period": "5m"
},
"p2p": {
"consensus_port": 8080,
"hostname": "node1.consensus",
"port": 42069,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
Expand Down
4 changes: 3 additions & 1 deletion build/config/config2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "ba81e6e56d293895b299bc495ae75d490644429a5e0028fabeb5e1871c1098e7eb2c78364525a210d994a83e02d18b4287ab81f6670cf4510ab6c9f51e296d91",
"use_lib_p2p": false,
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
Expand Down Expand Up @@ -28,7 +29,8 @@
"health_check_period": "5m"
},
"p2p": {
"consensus_port": 8080,
"hostname": "node2.consensus",
"port": 42069,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "ba81e6e56d293895b299bc495ae75d490644429a5e0028fabeb5e1871c1098e7eb2c78364525a210d994a83e02d18b4287ab81f6670cf4510ab6c9f51e296d91",
Expand Down
4 changes: 3 additions & 1 deletion build/config/config3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "25b385b367a827eaafcdb1003bd17a25f2ecc0d10d41f138846f52ae1015aa941041a9c76539791fef9bee5b4fcd5bf4a1a489e0790c44cbdfa776b901e13b50",
"use_lib_p2p": false,
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
Expand Down Expand Up @@ -28,7 +29,8 @@
"health_check_period": "5m"
},
"p2p": {
"consensus_port": 8080,
"hostname": "node3.consensus",
"port": 42069,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "25b385b367a827eaafcdb1003bd17a25f2ecc0d10d41f138846f52ae1015aa941041a9c76539791fef9bee5b4fcd5bf4a1a489e0790c44cbdfa776b901e13b50",
Expand Down
4 changes: 3 additions & 1 deletion build/config/config4.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "4ff3292ff14213149446f8208942b35439cb4b2c5e819f41fb612e880b5614bdd6cea8706f6ee6672c1e013e667ec8c46231e0e7abcf97ba35d89fceb8edae45",
"use_lib_p2p": false,
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
Expand Down Expand Up @@ -28,7 +29,8 @@
"health_check_period": "5m"
},
"p2p": {
"consensus_port": 8080,
"hostname": "node4.consensus",
"port": 42069,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "4ff3292ff14213149446f8208942b35439cb4b2c5e819f41fb612e880b5614bdd6cea8706f6ee6672c1e013e667ec8c46231e0e7abcf97ba35d89fceb8edae45",
Expand Down
12 changes: 6 additions & 6 deletions build/config/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -4040,7 +4040,7 @@
"address": "00104055c00bed7c983a48aac7dc6335d7c607a7",
"public_key": "dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
"chains": null,
"service_url": "node1.consensus:8080",
"service_url": "node1.consensus:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4051,7 +4051,7 @@
"address": "00204737d2a165ebe4be3a7d5b0af905b0ea91d8",
"public_key": "eb2c78364525a210d994a83e02d18b4287ab81f6670cf4510ab6c9f51e296d91",
"chains": null,
"service_url": "node2.consensus:8080",
"service_url": "node2.consensus:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4062,7 +4062,7 @@
"address": "00304d0101847b37fd62e7bebfbdddecdbb7133e",
"public_key": "1041a9c76539791fef9bee5b4fcd5bf4a1a489e0790c44cbdfa776b901e13b50",
"chains": null,
"service_url": "node3.consensus:8080",
"service_url": "node3.consensus:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4073,7 +4073,7 @@
"address": "00404a570febd061274f72b50d0a37f611dfe339",
"public_key": "d6cea8706f6ee6672c1e013e667ec8c46231e0e7abcf97ba35d89fceb8edae45",
"chains": null,
"service_url": "node4.consensus:8080",
"service_url": "node4.consensus:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4098,7 +4098,7 @@
"address": "43d9ea9d9ad9c58bb96ec41340f83cb2cabb6496",
"public_key": "16cd0a304c38d76271f74dd3c90325144425d904ef1b9a6fbab9b201d75a998b",
"chains": ["0001"],
"service_url": "node1.consensus:8080",
"service_url": "node1.consensus:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4111,7 +4111,7 @@
"address": "9ba047197ec043665ad3f81278ab1f5d3eaf6b8b",
"public_key": "68efd26af01692fcd77dc135ca1de69ede464e8243e6832bd6c37f282db8c9cb",
"chains": ["0001"],
"service_url": "node1.consensus:8080",
"service_url": "node1.consensus:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand Down
8 changes: 4 additions & 4 deletions build/deployments/.env.example
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# docker compose stuff
# override with your own values if the default host port mappings in docker-compose do not suit you
# NODE1_PORT_7081=127.0.0.1:7081
# NODE1_PORT_8081=127.0.0.1:8081
# NODE1_PORT_9081=127.0.0.1:9081
# NODE1_PORT_42070=127.0.0.1:42070
# NODE1_PORT_50832=127.0.0.1:50832
# NODE2_PORT_7081=127.0.0.1:7082
# NODE2_PORT_8081=127.0.0.1:8082
# NODE2_PORT_9081=127.0.0.1:9082
# NODE2_PORT_42070=127.0.0.1:42071
# NODE2_PORT_50832=127.0.0.1:50833
# NODE3_PORT_7081=127.0.0.1:7083
# NODE3_PORT_8081=127.0.0.1:8083
# NODE3_PORT_9081=127.0.0.1:9083
# NODE3_PORT_42070=127.0.0.1:42072
# NODE3_PORT_50832=127.0.0.1:50834
# NODE4_PORT_7081=127.0.0.1:7084
# NODE4_PORT_8081=127.0.0.1:8084
# NODE4_PORT_9081=127.0.0.1:9084
# NODE4_PORT_42070=127.0.0.1:42073
# NODE4_PORT_50832=127.0.0.1:50835
16 changes: 8 additions & 8 deletions build/deployments/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ services:
dockerfile: ./build/Dockerfile.localdev
expose:
- "7080" # dlv debug
- "8080"
- "9080"
- "9000"
- "42069"
- "50832"
ports:
- "${NODE1_PORT_7081:-0.0.0.0:7081}:7081"
- "${NODE1_PORT_8081:-0.0.0.0:8081}:8080"
- "${NODE1_PORT_9081:-0.0.0.0:9081}:9080"
- "${NODE1_PORT_42070:-0.0.0.0:42070}:42069"
- "${NODE1_PORT_50832:-0.0.0.0:50832}:50832"
volumes:
- ${PWD}:/go/src/github.com/pocket-network
Expand All @@ -68,14 +68,14 @@ services:
dockerfile: ./build/Dockerfile.localdev
expose:
- "7082" # dlv debug
- "8080"
- "42069"
- "9080"
- "9000"
- "50832"
ports:
- "${NODE2_PORT_7081:-0.0.0.0:7082}:7081"
- "${NODE2_PORT_8081:-0.0.0.0:8082}:8080"
- "${NODE2_PORT_9081:-0.0.0.0:9082}:9080"
- "${NODE2_PORT_42070:-0.0.0.0:42071}:42069"
- "${NODE2_PORT_50832:-0.0.0.0:50833}:50832"
volumes:
- ${PWD}:/go/src/github.com/pocket-network
Expand All @@ -96,14 +96,14 @@ services:
dockerfile: ./build/Dockerfile.localdev
expose:
- "7083" # dlv debug
- "8080"
- "42069"
- "9080"
- "9000"
- "50832"
ports:
- "${NODE3_PORT_7081:-0.0.0.0:7083}:7081"
- "${NODE3_PORT_8081:-0.0.0.0:8083}:8080"
- "${NODE3_PORT_9081:-0.0.0.0:9083}:9080"
- "${NODE3_PORT_42070:-0.0.0.0:42072}:42069"
- "${NODE3_PORT_50832:-0.0.0.0:50834}:50832"
volumes:
- ${PWD}:/go/src/github.com/pocket-network
Expand All @@ -124,14 +124,14 @@ services:
dockerfile: ./build/Dockerfile.localdev
expose:
- "7084" # dlv debug
- "8080"
- "42069"
- "9080"
- "9000"
- "50832"
ports:
- "${NODE4_PORT_7081:-0.0.0.0:7084}:7081"
- "${NODE4_PORT_8081:-0.0.0.0:8084}:8080"
- "${NODE4_PORT_9081:-0.0.0.0:9084}:9080"
- "${NODE4_PORT_42070:-0.0.0.0:42073}:42069"
- "${NODE4_PORT_50832:-0.0.0.0:50835}:50832"
volumes:
- ${PWD}:/go/src/github.com/pocket-network
Expand Down
7 changes: 7 additions & 0 deletions build/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.20] - 2023-03-01

- replace `consensus_port` with `port` in P2P config
- update default P2P config `port` to from `8080` to `42069`
- add `use_libp2p` field to base config
- add `hostname` field to P2P config

## [0.0.0.19] - 2023-02-28

- Renamed `generic_param` to `service_url` in the config files
Expand Down
3 changes: 2 additions & 1 deletion build/localnet/cluster-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func main() {
case watch.Added:
logger.Info().Str("validator", service.Name).Msg("Validator added to the cluster")
// TODO: consolidate args into constants
if err := stakeValidator(privateKey, "150000000001", []string{"0001"}, fmt.Sprintf("v1-validator%s:8080", validatorId)); err != nil {
validatorServiceUrl := fmt.Sprintf("v1-validator%s:%d", validatorId, defaults.DefaultP2PPort)
if err := stakeValidator(privateKey, "150000000001", []string{"0001"}, validatorServiceUrl); err != nil {
logger.Err(err).Msg("Error staking validator")
}
case watch.Deleted:
Expand Down
2 changes: 1 addition & 1 deletion build/localnet/manifests/cli-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
[
"sh",
"-c",
"until nc -z v1-validator001 8080; do echo waiting for v1-validator001...; sleep 2; done;",
"until nc -z v1-validator001 42069; do echo waiting for v1-validator001...; sleep 2; done;",
]
containers:
- name: pocket
Expand Down
2 changes: 1 addition & 1 deletion build/localnet/manifests/cluster-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
[
"sh",
"-c",
"until nc -z v1-validator001 8080; do echo waiting for v1-validator001...; sleep 2; done;",
"until nc -z v1-validator001 42069; do echo waiting for v1-validator001...; sleep 2; done;",
]
containers:
- name: cluster-manager
Expand Down
15 changes: 8 additions & 7 deletions build/localnet/manifests/configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data:
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "",
"use_libp2p": false,
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
Expand All @@ -34,7 +35,7 @@ data:
"health_check_period": "5m"
},
"p2p": {
"consensus_port": 8080,
"port": 42069,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
Expand Down Expand Up @@ -4102,7 +4103,7 @@ data:
"address": "00104055c00bed7c983a48aac7dc6335d7c607a7",
"public_key": "dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
"chains": null,
"service_url": "v1-validator001:8080",
"service_url": "v1-validator001:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4113,7 +4114,7 @@ data:
"address": "00204737d2a165ebe4be3a7d5b0af905b0ea91d8",
"public_key": "eb2c78364525a210d994a83e02d18b4287ab81f6670cf4510ab6c9f51e296d91",
"chains": null,
"service_url": "v1-validator002:8080",
"service_url": "v1-validator002:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4124,7 +4125,7 @@ data:
"address": "00304d0101847b37fd62e7bebfbdddecdbb7133e",
"public_key": "1041a9c76539791fef9bee5b4fcd5bf4a1a489e0790c44cbdfa776b901e13b50",
"chains": null,
"service_url": "v1-validator003:8080",
"service_url": "v1-validator003:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4135,7 +4136,7 @@ data:
"address": "00404a570febd061274f72b50d0a37f611dfe339",
"public_key": "d6cea8706f6ee6672c1e013e667ec8c46231e0e7abcf97ba35d89fceb8edae45",
"chains": null,
"service_url": "v1-validator004:8080",
"service_url": "v1-validator004:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4160,7 +4161,7 @@ data:
"address": "43d9ea9d9ad9c58bb96ec41340f83cb2cabb6496",
"public_key": "16cd0a304c38d76271f74dd3c90325144425d904ef1b9a6fbab9b201d75a998b",
"chains": ["0001"],
"service_url": "v1-validator001:8080",
"service_url": "v1-validator001:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand All @@ -4173,7 +4174,7 @@ data:
"address": "9ba047197ec043665ad3f81278ab1f5d3eaf6b8b",
"public_key": "68efd26af01692fcd77dc135ca1de69ede464e8243e6832bd6c37f282db8c9cb",
"chains": ["0001"],
"service_url": "v1-validator001:8080",
"service_url": "v1-validator001:42069",
"staked_amount": "1000000000000",
"paused_height": -1,
"unstaking_height": -1,
Expand Down
6 changes: 4 additions & 2 deletions build/localnet/templates/v1-validator-template.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
- -config=/configs/config.json
- -genesis=/genesis.json
ports:
- containerPort: 8080
- containerPort: 42069
name: consensus
- containerPort: 50832
name: rpc
bryanchriswhite marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -63,6 +63,8 @@ spec:
value: "postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST):$(POSTGRES_PORT)/$(POSTGRES_DB)"
- name: POCKET_PERSISTENCE_NODE_SCHEMA
value: validator${VALIDATOR_NUMBER}
- name: POCKET_P2P_HOSTNAME
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
value: "v1-validator${VALIDATOR_NUMBER}"
volumeMounts:
- name: config-volume
mountPath: /configs
Expand Down Expand Up @@ -106,7 +108,7 @@ metadata:
v1-purpose: validator
spec:
ports:
- port: 8080
- port: 42069
name: consensus
- port: 50832
name: rpc
Expand Down
6 changes: 5 additions & 1 deletion p2p/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.31] - 2023-03-01

- replace `consensus_port` with `port` in P2P config
- update default P2P config `port` to from `8080` to `42069`

## [0.0.0.30] - 2023-02-28

- Renamed package names and parameters to reflect changes in the rest of the codebase
Expand Down Expand Up @@ -64,7 +69,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.0.0.19] - 2023-01-19

- Rewrite `interface{}` to `any`

## [0.0.0.18] - 2023-01-11

- Add a lock to the mempool to avoid parallel messages which has caused the node to crash in the past
Expand Down
2 changes: 1 addition & 1 deletion p2p/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func Test_Create_configureBootstrapNodes(t *testing.T) {
{
name: "negative port number yields an error and empty list of bootstrap nodes",
args: args{
initialBootstrapNodesCsv: "udp://somenode:-8080",
initialBootstrapNodesCsv: "udp://somenode:-42069",
},
wantBootstrapNodes: []string(nil),
wantErr: true,
Expand Down
2 changes: 1 addition & 1 deletion p2p/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type tcpConn struct {
}

func createTCPListener(cfg *configs.P2PConfig) (*tcpConn, error) {
addr, err := net.ResolveTCPAddr(TCPNetworkLayerProtocol, fmt.Sprintf(":%d", cfg.ConsensusPort))
addr, err := net.ResolveTCPAddr(TCPNetworkLayerProtocol, fmt.Sprintf(":%d", cfg.Port))
if err != nil {
return nil, err
}
Expand Down
Loading