Skip to content

Commit

Permalink
Merge branch 'main' into docs/diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite authored Jun 24, 2024
2 parents 72b496e + 60fda01 commit 64d2015
Show file tree
Hide file tree
Showing 493 changed files with 70,659 additions and 10,360 deletions.
10 changes: 10 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This Dockerfile is used to build container image for development purposes.
# It intentionally contains no security features, ships with code and troubleshooting tools.

FROM mcr.microsoft.com/devcontainers/go:1-1.22-bookworm

RUN curl https://get.ignite.com/cli | bash
RUN mv ignite /usr/local/bin/

# enable faster module downloading.
ENV GOPROXY https://proxy.golang.org
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
"name": "Go",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"build": { "dockerfile": "Dockerfile" },

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "go install \"github.com/golang/mock/[email protected]\""

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
28 changes: 28 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file contains environment variables that are used in the development environment.
# It is a copy of what's in the Makefile but makes local development easier through
# a simple `source .env.dev` command.

POKTROLLD_HOME=./localnet/poktrolld
# The pocket node (validator in the localnet context)
POCKET_NODE=tcp://127.0.0.1:26657
# TestNet RPC endpoint for validator maintained by Grove. Needs to be updated if there's another "primary" testnet.
TESTNET_RPC=https://testnet-validated-validator-rpc.poktroll.com/
APPGATE_SERVER=http://localhost:42069
GATEWAY_URL=http://localhost:42079
POCKET_ADDR_PREFIX=pokt
CHAIN_ID=poktroll

# The domain ending in ".town" is staging, ".city" is production
GROVE_GATEWAY_STAGING_ETH_MAINNET=https://eth-mainnet.rpc.grove.town
# The "protocol" field here instructs the Grove gateway which network to use
JSON_RPC_DATA_ETH_BLOCK_HEIGHT='{"protocol": "shannon-testnet","jsonrpc":"2.0","id":"0","method":"eth_blockNumber", "params": []}'

# On-chain module account addresses. Search for `func TestModuleAddress` in the
# codebase to get an understanding of how we got these values.
APPLICATION_MODULE_ADDRESS=pokt1rl3gjgzexmplmds3tq3r3yk84zlwdl6djzgsvm
SUPPLIER_MODULE_ADDRESS=pokt1j40dzzmn6cn9kxku7a5tjnud6hv37vesr5ccaa
GATEWAY_MODULE_ADDRESS=pokt1f6j7u6875p2cvyrgjr0d2uecyzah0kget9vlpl
SERVICE_MODULE_ADDRESS=pokt1nhmtqf4gcmpxu0p6e53hpgtwj0llmsqpxtumcf
GOV_ADDRESS=pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t
# PNF acts on behalf of the DAO and who AUTHZ must delegate to
PNF_ADDRESS=pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw
16 changes: 14 additions & 2 deletions .github/label-actions.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# When `devnet-test-e2e` is added, also assign `devnet` and `push-image` to the PR.
devnet-test-e2e:
prs:
comment: The CI will now also run the e2e tests on devnet, which increases the time it takes to complete all CI checks. If you just created a pull request, you might need to push another commit to produce a container image DevNet can utilize to spin up infrastructure. You can use `make trigger_ci` to push an empty commit.
comment: |
The CI will now also run the e2e tests on devnet, which increases the time it takes to complete all CI checks.
You may need to run `make trigger_ci` to submit an empty commit that'll trigger the tests.
[GCP workloads (requires changing the namespace to {issue-id})](https://console.cloud.google.com/kubernetes/workload/overview?project=protocol-us-central1-d505&pageState=(%22savedViews%22:(%22c%22:%5B%5D,%22n%22:%5B%22devnet-issue-{issue-id}%22%5D)))
[Grafana network dashboard for devnet-issue-{issue-id}](https://grafana.poktroll.com/d/b799a130-3789-416d-aa7f-de5f4599cf03/network-overview?orgId=1&var-namespace=devnet-issue-{issue-id})
label:
- devnet
- push-image
Expand All @@ -27,7 +34,12 @@ devnet:
# Let the developer know that they need to push another commit after attaching the label to PR.
push-image:
prs:
comment: The image is going to be pushed after the next commit. You can use `make trigger_ci` to push an empty commit. If you also want to run an E2E test, please add `devnet-test-e2e` label.
comment: |
The image is going to be pushed after the next commit.
You can use `make trigger_ci` to push an empty commit.
If you also want to run E2E tests, please add `devnet-test-e2e` label.
# When `push-image` is removed, also delete `devnet` from the PR.
-push-image:
Expand Down
22 changes: 19 additions & 3 deletions .github/workflows-helpers/run-e2e-test-job-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ spec:
labels:
pokt.network/purpose: e2e-tests
spec:
initContainers:
# We need to make sure the services like validator, relayminer, appgate server, etc. work before we execute
# an e2e test.
- name: check-services
image: ruby:3.0
command: ["ruby"]
args:
# For reference, the script is located here:
# https://github.com/pokt-network/protocol-infra/blob/main/charts/full-network/templates/ConfigMap-e2e-tests-script.yaml#L4
- /e2e-script/check_services.rb
- ${NAMESPACE}
volumeMounts:
- mountPath: /e2e-script/
name: e2e-tests-check-services-script
containers:
- name: e2e-tests
image: ghcr.io/pokt-network/poktrolld:${IMAGE_TAG}
Expand Down Expand Up @@ -54,9 +68,11 @@ spec:
- name: non-writable-keys-volume
secret:
secretName: keys-${IMAGE_TAG}
- configMap:
defaultMode: 420
- name: configs-volume
configMap:
name: configs-${IMAGE_TAG}
name: configs-volume
- name: e2e-tests-check-services-script
configMap:
name: e2e-tests-check-services-script
serviceAccountName: default
backoffLimit: 0
12 changes: 0 additions & 12 deletions .github/workflows-helpers/run-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ echo "Environment variables:"
echo "NAMESPACE: ${NAMESPACE}"
echo "IMAGE_TAG: ${IMAGE_TAG}"

# TODO_TECHDEBT(@okdas): also check readiness of appgate and relayminer to avoid false negatives due to race-conditions

# Check if the pod with the matching image SHA and purpose is ready or needs recreation
echo "Checking for ready validator pod with image SHA ${IMAGE_TAG} or pods needing recreation..."
while :; do
Expand Down Expand Up @@ -34,16 +32,6 @@ while :; do
fi
done

# Check we can reach the validator endpoint
echo "Checking HTTP status for the validator endpoint..."
HTTP_STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://${NAMESPACE}-validator-poktrolld:36657)
if [[ "${HTTP_STATUS}" -eq 200 ]]; then
echo "HTTP request to ${NAMESPACE}-validator-poktrolld:36657 returned 200 OK."
else
echo "HTTP request to ${NAMESPACE}-validator-poktrolld:36657 did not return 200 OK. Status code: ${HTTP_STATUS}. Retrying in 10 seconds..."
sleep 10
fi

# Create a job to run the e2e tests
echo "Creating a job to run the e2e tests..."
envsubst <.github/workflows-helpers/run-e2e-test-job-template.yaml >job.yaml
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/label-actions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Label Actions'
name: "Label Actions"

on:
issues:
Expand All @@ -18,4 +18,5 @@ jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/label-actions@v3
# TODO: switch to `dessant/label-actions@v3` when https://github.com/dessant/label-actions/pull/29 is merged.
- uses: okdas/label-actions@patch-1
18 changes: 11 additions & 7 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ jobs:
- name: Install CI dependencies
run: make install_ci_deps

- name: Generate protobufs
run: make proto_regen
# This is commented out because proto generated code is now tracked in the
# repo so this step is skipped.
# TODO_IMPROVE(@okdas): Have a step that regenerates the proto files and ensures
# if they are up to date. See https://github.com/pokt-network/poktroll/pull/544#issuecomment-2123063491
# - name: Generate protobufs
# run: make proto_regen

- name: Build
run: ignite chain build -v --debug --skip-proto

- name: Set up Docker Buildx
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image')) || (contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e'))
uses: docker/setup-buildx-action@v3

- name: Docker Metadata action
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image')) || (contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e'))
id: meta
uses: docker/metadata-action@v5
env:
Expand All @@ -54,23 +58,23 @@ jobs:
type=sha,format=long
- name: Login to GitHub Container Registry
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image')) || (contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e'))
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Copy binaries to inside of the Docker context
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image')) || (contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e'))
run: |
mkdir -p ./bin # Make sure the bin directory exists
cp $(which ignite) ./bin # Copy ignite binary to the repo's bin directory
cp $(go env GOPATH)/bin/poktrolld ./bin # Copy the binary to the repo's bin directory
ls -la ./bin
- name: Build and push Docker image
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image')) || (contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e'))
uses: docker/build-push-action@v5
with:
push: true
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ jobs:
- name: Install CI dependencies
run: make install_ci_deps

- name: Generate protobufs
run: make proto_regen
# This is commented out because proto generated code is now tracked in the
# repo so this step is skipped.
# TODO_IMPROVE(@okdas): Have a step that regenerates the proto files and ensures
# if they are up to date. See https://github.com/pokt-network/poktroll/pull/544#issuecomment-2123063491
# - name: Generate protobufs
# run: make proto_regen

- name: Build and extract binaries for container build
run: |
Expand Down Expand Up @@ -75,7 +79,7 @@ jobs:
cache-to: type=gha,mode=max
context: .

# TODO(@okdas): use for releases (also change the "on" part at the top so it only tgirrered for tags/releases)
# TODO_TECHDEBT(@okdas): use for releases (also change the "on" part at the top so it only tgirrered for tags/releases)
- name: Add release and publish binaries
uses: softprops/action-gh-release@v1
with:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ jobs:
- name: Install CI dependencies
run: make install_ci_deps

- name: Generate protobufs
run: make proto_regen
# This is commented out because proto generated code is now tracked in the
# repo so this step is skipped.
# TODO_IMPROVE(@okdas): Have a step that regenerates the proto files and ensures
# if they are up to date. See https://github.com/pokt-network/poktroll/pull/544#issuecomment-2123063491
# - name: Generate protobufs
# run: make proto_regen

- name: Generate mocks
run: make go_mockgen
Expand All @@ -42,4 +46,4 @@ jobs:
run: make go_lint

- name: Test
run: make go_test
run: make test_all
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ localnet/*/config/*.json
.idea/
.mise.local.toml

# Compiled protos
**/*.pb.go
**/*.pb.gw.go

# Frontend utils
ts-client/

Expand Down Expand Up @@ -76,7 +72,7 @@ go.work.sum
**/gomock_reflect_*

# SMT KVStore files
# TODO_TECHDEBT(#126, @red-0ne): Rename `smt` to `smt_stores` and make it configurable so it can be stored anywhere on this
# TODO_TECHDEBT(@red-0ne, #126): Rename `smt` to `smt_stores` and make it configurable so it can be stored anywhere on this
smt
smt_stores

Expand All @@ -96,3 +92,6 @@ shannon_relayminer_config.yaml
shannon_supplier_config.yaml

gentx-*.json

# Binaries VSCode builds for debugging
cmd/poktrolld/*debug_bin*
15 changes: 15 additions & 0 deletions .prompts/test_suggestions.prompt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
temperature: 0.5
maxTokens: 4096
---
<system>
You are a principal software engineer.
</system>

{{{ input }}}

You have been provided two files:
1. A source code file
2. A unit test file

Please provide a list of unit test names/descriptions that you believe
are still missing. Do not actually implement them.
17 changes: 17 additions & 0 deletions .prompts/unit_tests.prompt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
temperature: 0.5
maxTokens: 4096
---
<system>
You are a principal software engineer.
</system>

{{{ input }}}

Write unit tests for the code selected., following each of these instructions:
- Follow the best and latests practices of golang
- Where appropriate use `github.com/stretchr/testify/require`
- If necessary, create a tests struct to iterate over: `tests := []struct {
- Include at least 2 edge cases and 5 core cases
- The tests should be complete and sophisticated
- Give the tests just as chat output, don't edit any file
- Just give the code, no need for an explanation
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN mv /poktroll/bin/ignite /usr/bin/ && mv /poktroll/bin/poktrolld /usr/bin/

RUN make localnet_regenesis

# TODO_TECHDEBT(@okdas): Ports are not documented as they will soon be changed with a document to follow
# TODO_DOCUMENT(@okdas): Ports are not documented as they will soon be changed with a document to follow
EXPOSE 8545
EXPOSE 8546
EXPOSE 8547
Expand Down
Loading

0 comments on commit 64d2015

Please sign in to comment.