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

[LocalNet] Add Path to LocalNet #879

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
17 changes: 17 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ localnet_config_defaults = {
"rest": {
"enabled": True,
},
"path_gateways": {
"count": 1,
},
# By default, we use the `helm_repo` function below to point to the remote repository
# but can update it to the locally cloned repo for testing & development
"helm_chart_local_repo": {"enabled": False, "path": "../helm-charts"},
Expand Down Expand Up @@ -383,3 +386,17 @@ if localnet_config["rest"]["enabled"]:
print("REST enabled: " + str(localnet_config["rest"]["enabled"]))
deployment_create("rest", image="davarski/go-rest-api-demo")
k8s_resource("rest", labels=["data_nodes"], port_forwards=["10000"])

path_deployment_yaml = str(read_file("./localnet/kubernetes/path.yaml", "r"))
actor_number = 0
for x in range(localnet_config["path_gateways"]["count"]):
actor_number = actor_number + 1
configmap_create("path-config" + str(actor_number), from_file="localnet/kubernetes/path-config-"+str(actor_number)+".yaml")
formatted_path_deployment_yaml = path_deployment_yaml.format(actor_number=actor_number, port=2999 + actor_number)
k8s_yaml(blob(formatted_path_deployment_yaml))
k8s_resource(
"path-gateway" + str(actor_number),
labels=["gateways"],
resource_deps=["validator"],
port_forwards=[str(2999 + actor_number)+":3000"],
)
10 changes: 5 additions & 5 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ genesis:
denom: upokt
applicationList:
- address: pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4
delegatee_gateway_addresses: []
delegatee_gateway_addresses: [pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4]
service_configs:
- service_id: anvil
- service_id: "0021"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tl;dr I'm changing this back

I understand why you did this, but:

  1. This is legacy from Morse adopted into PATH
  • I'd rather change PATH and move forward
  1. If we make this change, you'll need to change a lot more (see the search result below)
  • This requires a TODO_IN_THIS_PR

Screenshot 2024-10-16 at 12 20 31 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, Path does not know about / have "anvil" as an EVM service.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it. PR incoming soon.

- service_id: rest
- service_id: ollama
stake:
Expand All @@ -184,7 +184,7 @@ genesis:
- address: pokt1ad28jdap2zfanjd7hpkh984yveney6k9a42man
delegatee_gateway_addresses: []
service_configs:
- service_id: anvil
- service_id: "0021"
- service_id: rest
- service_id: ollama
stake:
Expand All @@ -202,7 +202,7 @@ genesis:
- owner_address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
operator_address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
services:
- service_id: anvil
- service_id: "0021"
endpoints:
- configs: []
rpc_type: JSON_RPC
Expand Down Expand Up @@ -250,7 +250,7 @@ genesis:
amount: "1000000000"
denom: upokt
serviceList:
- id: anvil
- id: "0021"
name: "anvil"
compute_units_per_relay: 1
owner_address: pokt1cwnu460557x0z78jv3hhc7356hhkrgc86c87q5
Expand Down
8 changes: 4 additions & 4 deletions e2e/tests/0_settlement.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: Tokenomics Namespace
And the "supplier" account for "supplier1" is staked
And an account exists for "app1"
And the "application" account for "app1" is staked
And the service "anvil" registered for application "app1" has a compute units per relay of "1"
And the service "0021" registered for application "app1" has a compute units per relay of "1"
# Start servicing relays
# Set proof_requirement_threshold to 839 < num_relays (20) * compute_units_per_relay (1) * compute_units_to_tokens_multiplier (42)
# to make sure a proof is required.
Expand All @@ -28,7 +28,7 @@ Feature: Tokenomics Namespace
And the "shared" module parameters are set as follows
| compute_units_to_tokens_multiplier | 42 | int64 |
And all "shared" module params should be updated
When the supplier "supplier1" has serviced a session with "20" relays for service "anvil" for application "app1"
When the supplier "supplier1" has serviced a session with "20" relays for service "0021" for application "app1"
# Wait for the Claim & Proof lifecycle
And the user should wait for the "proof" module "CreateClaim" Message to be submitted
And the user should wait for the "proof" module "SubmitProof" Message to be submitted
Expand All @@ -48,7 +48,7 @@ Feature: Tokenomics Namespace
And the "supplier" account for "supplier1" is staked
And an account exists for "app1"
And the "application" account for "app1" is staked
And the service "anvil" registered for application "app1" has a compute units per relay of "1"
And the service "0021" registered for application "app1" has a compute units per relay of "1"
# Set proof_request_probability to 0 and proof_requirement_threshold to
# 421 > num_relays (10) * compute_units_per_relay (1) * compute_units_to_tokens_multiplier (42)
# to make sure a proof is not required.
Expand All @@ -63,7 +63,7 @@ Feature: Tokenomics Namespace
| compute_units_to_tokens_multiplier | 42 | int64 |
And all "shared" module params should be updated
# Start servicing
When the supplier "supplier1" has serviced a session with "10" relays for service "anvil" for application "app1"
When the supplier "supplier1" has serviced a session with "10" relays for service "0021" for application "app1"
# Wait for the Claim & Proof lifecycle
And the user should wait for the "proof" module "CreateClaim" Message to be submitted
# No proof should be submitted, don't wait for one.
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var (
flagFeaturesPath string
keyRingFlag = "--keyring-backend=test"
chainIdFlag = "--chain-id=poktroll"
appGateServerUrl = "http://localhost:42069" // Keeping localhost by default because that is how we run the tests on our machines locally
appGateServerUrl = "localhost:3000" // Keeping localhost by default because that is how we run the tests on our machines locally
)

func init() {
Expand Down
13 changes: 6 additions & 7 deletions e2e/tests/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ var (
defaultAppGateServerURL = os.Getenv("APPGATE_SERVER")
// defaultDebugOutput provides verbose output on manipulations with binaries (cli command, stdout, stderr)
defaultDebugOutput = os.Getenv("E2E_DEBUG_OUTPUT")
// serviceIdToAliasMap maps service IDs to their respective aliases
serviceIdToAliasMap = map[string]string{
"0021": "anvil",
}
)

func isVerbose() bool {
Expand Down Expand Up @@ -172,13 +176,8 @@ func (p *pocketdBin) runPocketCmd(args ...string) (*commandResult, error) {

// runCurlPostCmd is a helper to run a command using the local pocketd binary with the flags provided
func (p *pocketdBin) runCurlCmd(rpcUrl, service, method, path, data string, args ...string) (*commandResult, error) {
// Ensure that if a path is provided, it starts with a "/".
// This is required for RESTful APIs that use a path to identify resources.
// For JSON-RPC APIs, the resource path should be empty, so empty paths are allowed.
if len(path) > 0 && path[0] != '/' {
path = "/" + path
}
urlStr := fmt.Sprintf("%s/%s%s", rpcUrl, service, path)
serviceAlias := serviceIdToAliasMap[service]
urlStr := fmt.Sprintf("http://%s.%s/v1%s", serviceAlias, rpcUrl, path)
base := []string{
"-v", // verbose output
"-sS", // silent with error
Expand Down
8 changes: 4 additions & 4 deletions e2e/tests/relay.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Feature: Relay Namespace
# NB: `make acc_initialize_pubkeys` must have been executed before this test is run
Scenario: App can send a JSON-RPC relay to Supplier
Given the user has the pocketd binary installed
And the application "app1" is staked for service "anvil"
And the supplier "supplier1" is staked for service "anvil"
And the session for application "app1" and service "anvil" contains the supplier "supplier1"
Then the application "app1" sends the supplier "supplier1" a successful request for service "anvil" with path "" and data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
And the application "app1" is staked for service "0021"
And the supplier "supplier1" is staked for service "0021"
And the session for application "app1" and service "0021" contains the supplier "supplier1"
Then the application "app1" sends the supplier "supplier1" a successful request for service "0021" with path "" and data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Scenario: App can send a REST relay to Supplier
Given the user has the pocketd binary installed
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/session.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Feature: Session Namespace
And the "shared" module parameters are set as follows
| compute_units_to_tokens_multiplier | 42 | int64 |
And all "shared" module params should be updated
When the supplier "supplier1" has serviced a session with "5" relays for service "anvil" for application "app1"
When the supplier "supplier1" has serviced a session with "5" relays for service "0021" for application "app1"
And the user should wait for the "proof" module "CreateClaim" Message to be submitted
And the user should wait for the "proof" module "ClaimCreated" tx event to be broadcast
Then the claim created by supplier "supplier1" for service "svc1" for application "app1" should be persisted on-chain
And the user should wait for the "proof" module "SubmitProof" Message to be submitted
And the user should wait for the "proof" module "ProofSubmitted" tx event to be broadcast
Then the claim created by supplier "supplier1" for service "anvil" for application "app1" should be successfully settled
Then the claim created by supplier "supplier1" for service "0021" for application "app1" should be successfully settled

# TODO_BLOCKER(@red-0ne): Make sure to implement and validate this test
# One way to exercise this behavior is to close the `RelayMiner` port to prevent
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/session_steps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
eventTimeout = 100 * time.Second
// testServiceId is the service ID used for testing purposes that is
// expected to be available in LocalNet.
testServiceId = "anvil"
testServiceId = "0021"
// defaultJSONPRCPath is the default path used for sending JSON-RPC relay requests.
defaultJSONPRCPath = ""

Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/stake_app.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Feature: Stake App Namespaces
Given the user has the pocketd binary installed
And the user verifies the "application" for account "app2" is not staked
And the account "app2" has a balance greater than "1000070" uPOKT
When the user stakes a "application" with "1000070" uPOKT for "anvil" service from the account "app2"
When the user stakes a "application" with "1000070" uPOKT for "0021" service from the account "app2"
Then the user should be able to see standard output containing "txhash:"
And the user should be able to see standard output containing "code: 0"
And the pocketd binary should exit without error
Expand Down
10 changes: 5 additions & 5 deletions e2e/tests/stake_supplier.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Feature: Stake Supplier Namespace
Given the user has the pocketd binary installed
And the user verifies the "supplier" for account "supplier2" is not staked
And the account "supplier2" has a balance greater than "1000070" uPOKT
When the user stakes a "supplier" with "1000070" uPOKT for "anvil" service from the account "supplier2"
When the user stakes a "supplier" with "1000070" uPOKT for "0021" service from the account "supplier2"
Then the user should be able to see standard output containing "txhash:"
And the user should be able to see standard output containing "code: 0"
And the pocketd binary should exit without error
Expand Down Expand Up @@ -34,12 +34,12 @@ Feature: Stake Supplier Namespace
# Reduce the application unbonding period to avoid timeouts and speed up scenarios.
And the "supplier" unbonding period param is successfully set to "1" sessions of "2" blocks
And the user verifies the "supplier" for account "supplier2" is not staked
Then the user stakes a "supplier" with "1000070" uPOKT for "anvil" service from the account "supplier2"
Then the user stakes a "supplier" with "1000070" uPOKT for "0021" service from the account "supplier2"
And the user should wait for the "supplier" module "StakeSupplier" message to be submitted
Then the user should see that the supplier for account "supplier2" is staked
But the session for application "app1" and service "anvil" does not contain "supplier2"
When the user waits for supplier "supplier2" to become active for service "anvil"
Then the session for application "app1" and service "anvil" contains the supplier "supplier2"
But the session for application "app1" and service "0021" does not contain "supplier2"
When the user waits for supplier "supplier2" to become active for service "0021"
Then the session for application "app1" and service "0021" contains the supplier "supplier2"
# Cleanup to make this feature idempotent.
And the user unstakes a "supplier" from the account "supplier2"
And the supplier for account "supplier2" is unbonding
Expand Down
17 changes: 17 additions & 0 deletions localnet/kubernetes/path-config-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
shannon_config:
full_node_config:
rpc_url: tcp://validator-poktroll-validator:26657
grpc_config:
host_port: validator-poktroll-validator:9090
insecure: true
# TODO: Allow sovereign soverign apps to sign their own relay requests.

Check warning on line 7 in localnet/kubernetes/path-config-1.yaml

View workflow job for this annotation

GitHub Actions / misspell

[misspell] localnet/kubernetes/path-config-1.yaml#L7

"soverign" is a misspelling of "sovereign"
Raw output
./localnet/kubernetes/path-config-1.yaml:7:28: "soverign" is a misspelling of "sovereign"
gateway_address: pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4
gateway_private_key: cf09805c952fa999e9a63a9f434147b0a5abfd10f268879694c6b5a70e1ae177
# TODO: Populate delegated_app_addresses from on-chain records.
delegated_app_addresses:
- pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4

services:
# Path needs 0021 service ID to handle EVM relays.
"0021":
alias: anvil
14 changes: 14 additions & 0 deletions localnet/kubernetes/path-config-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
shannon_config:
full_node_config:
rpc_url: tcp://validator-poktroll-validator:26657
grpc_config:
host_port: validator-poktroll-validator:9090
insecure: true
gateway_address: pokt15w3fhfyc0lttv7r585e2ncpf6t2kl9uh8rsnyz
gateway_private_key: 177ba43cec962ea407f71da9c3994ba685708e82d5d7a6d7da3268e74119bf88
delegated_app_addresses:
- pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4

services:
"0021":
alias: anvil
14 changes: 14 additions & 0 deletions localnet/kubernetes/path-config-3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
shannon_config:
full_node_config:
rpc_url: tcp://validator-poktroll-validator:26657
grpc_config:
host_port: validator-poktroll-validator:9090
insecure: true
gateway_address: pokt1zhmkkd0rh788mc9prfq0m2h88t9ge0j83gnxya
gateway_private_key: f73b6f7f0b9c99603c7eeddbf1c419c6f6bbc241f3798e3e4c8da9769ca81c26
delegated_app_addresses:
- pokt1mrqt5f7qh8uxs27cjm9t7v9e74a9vvdnq5jva4

services:
"0021":
alias: anvil
45 changes: 45 additions & 0 deletions localnet/kubernetes/path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: path-gateway{actor_number}
spec:
replicas: 1
selector:
matchLabels:
app: path-gateway{actor_number}
template:
metadata:
labels:
app: path-gateway{actor_number}
spec:
# TODO: Add resource limits
containers:
- name: path-gateway
image: ghcr.io/buildwithgrove/path:sha-fcf75fe-rc
ports:
- containerPort: 3000
volumeMounts:
- name: path-config{actor_number}
mountPath: /app/.config.yaml
subPath: .config.yaml
volumes:
- name: path-config{actor_number}
configMap:
name: path-config{actor_number}
items:
- key: path-config-{actor_number}.yaml
path: .config.yaml
---
apiVersion: v1
kind: Service
metadata:
name: path-gateway{actor_number}
spec:
selector:
app: path-gateway{actor_number}
ports:
- protocol: TCP
name: rpc
port: {port}
targetPort: 3000
2 changes: 1 addition & 1 deletion localnet/kubernetes/values-appgateserver.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config:
query_node_rpc_url: tcp://validator-poktroll-validator:26657
query_node_grpc_url: tcp://validator-poktroll-validator:9090
query_node_grpc_url: validator-poktroll-validator:9090
metrics:
enabled: true
addr: :9090
Expand Down
2 changes: 1 addition & 1 deletion localnet/kubernetes/values-relayminer-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ config:

default_signing_key_names: [supplier1]
suppliers:
- service_id: anvil
- service_id: "0021"
listen_url: http://0.0.0.0:8545
service_config:
backend_url: http://anvil:8547/
Expand Down
Loading