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

Add Session Primer with Qos and chain configuration in db #21

Merged
merged 52 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c174ed9
cherry pick from local repo for session primer and qos
Feb 4, 2024
e4c13a1
qos cleanup
Mar 15, 2024
fec4b8c
refractor relayer
Mar 16, 2024
1f3da8b
initialize time struct, change to next check time
Mar 17, 2024
9152c17
update QoS check documentation
Mar 19, 2024
9dcee3f
update to include time variable for QoS docs
Mar 19, 2024
c9a1a0d
rename qosjob to checkjob
Mar 19, 2024
8fc4e1d
update vocab on documentation
Mar 19, 2024
45e5a14
update node selection system architecture
Mar 19, 2024
d3c8443
update system architecture diagram
Mar 19, 2024
68342d6
update base check checker
Mar 19, 2024
6fb4fbe
regenerate optimized json
Mar 22, 2024
bf0e037
refractor get random element and data integrity cleanup
Mar 23, 2024
9cae8a7
refractor relay controller for cleaniness
Mar 24, 2024
7fcc697
fix relayer tests
Mar 24, 2024
190a55f
regenerate tests and fix tests
Mar 24, 2024
6ad0dbc
refractor altruist registry to chain configuration registry and add i…
Mar 24, 2024
814430c
update checks to use db driven configs
Mar 24, 2024
ac4c005
update checks
Mar 24, 2024
cff981c
fix compile error
Mar 24, 2024
da3729b
isolate checks into its own package
Mar 24, 2024
7d89bae
update documentation
Mar 24, 2024
b0c4495
add cicd for publishing docker file
Mar 24, 2024
b6a7e04
update ci/cd
Mar 24, 2024
23f2b57
update ci-cd pipeline name
Mar 24, 2024
a0b5077
only build on PR requests
Mar 24, 2024
8df0410
remove broken ci/cd
Mar 24, 2024
a642f79
Update CI/CD Pipeline for tests
nodiesBlade Mar 24, 2024
3bbc3c4
update ci/cd
Mar 24, 2024
8483be1
Update go.yml
nodiesBlade Mar 24, 2024
ad861d0
run tests on main as well
nodiesBlade Mar 24, 2024
080fbe7
Merge branch 'main' of github.com:baaspoolsllc/os-gateway into featur…
Mar 24, 2024
3cb2df2
add ci cd tests for main as well
Mar 24, 2024
3ffc4aa
Create build-images.yml ci cd
nodiesBlade Mar 24, 2024
e370adb
Add files via upload
nodiesBlade Mar 24, 2024
41e2e25
Update Repository Logo
nodiesBlade Mar 24, 2024
e406210
Merge branch 'main' of github.com:baaspoolsllc/os-gateway into featur…
Mar 25, 2024
38dadd2
add chain configuration documentation
Mar 25, 2024
9ac446d
update comment
Mar 25, 2024
5b97f0c
use evm_chain config
Mar 25, 2024
6abdd2a
update documentation with evm check
Mar 25, 2024
2147d7c
add additional checks
Mar 25, 2024
5ef69d7
remove magic number
Mar 25, 2024
ccfe5f8
update chain configuration docs with comment that it's not required
Mar 25, 2024
e38fa43
fix example altruist
Mar 25, 2024
21f4ad0
fix typo comment
Mar 25, 2024
2144281
add default altruist request timeout
Mar 25, 2024
cb7ba13
add docker image releases link in readme
Mar 25, 2024
a574265
update readme
Mar 25, 2024
470f0ef
update readme
Mar 25, 2024
5f070e9
update typo in quick onboaridng guide
Mar 25, 2024
b42fc75
update altruist documentation
Mar 25, 2024
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
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ ENVIRONMENT_STAGE=development
POKT_APPLICATIONS_ENCRYPTION_KEY=
SESSION_CACHE_TTL=75m
DB_CONNECTION_URL=postgres://postgres:mypassword@localhost:5432/postgres?sslmode=disable
API_KEY=
API_KEY=
ALTRUIST_REQUEST_TIMEOUT=10s
53 changes: 53 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow only handles build & push of images to GitHub Container Registry.
# We have other pipepines in CircleCI, such as tests, that are not migrated to GitHub Actions.

name: Build container and push images

on:
workflow_dispatch:
push:
branches: [main]
tags: ['*']
pull_request:
branches: [main]

jobs:
build-images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Docker Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Docker Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Docker Metadata action
id: meta
uses: docker/metadata-action@v4
env:
DOCKER_METADATA_PR_HEAD_SHA: "true"
with:
images: |
ghcr.io/pokt-network/pocket-gateway-server
tags: |
type=schedule
type=ref,event=tag
type=ref,event=branch
type=ref,event=pr
type=sha
type=sha,format=long
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
file: Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
5 changes: 2 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go
name: Build and Run Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
types: [opened, synchronize, reopened]

jobs:

build:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
/*.sqlite

## environment vars
.env
.env
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img src="https://github.com/baaspoolsllc/os-gateway/assets/99137075/ced8035d-87da-4fd3-a51b-6c336fadc14c" width="500" alt="POKT Gateway Stack">
<img src="https://github.com/pokt-network/gateway-server/blob/main/docs/resources/gateway-server-logo.jpg" width="500" alt="POKT Gateway Server">
</div>

## What is POKT Gateway Server?
Expand All @@ -11,7 +11,6 @@ Learn more about the vision and overall architecture [overview](docs%2Foverview.
## Gateway Operator Quick Getting Started
To onboard the gateway server without having to dig deep, you can follow the [Quick Onboarding Guide](docs%2Fquick-onboarding-guide.md)


#### Interested in learning more? We have an abdundance of information in [docs](docs)
1. [Gateway Server Overview](docs%2Foverview.md)
2. [Gateway Server API Endpoints](docs%2Fapi-endpoints.md)
Expand All @@ -20,6 +19,12 @@ To onboard the gateway server without having to dig deep, you can follow the [Qu
5. [POKT Primer](docs%2Fpokt-primer.md)
6. [POKT's Relay Specification](docs%2Fpokt-relay-specification.md)

## Docker Image Releases
Every release candidate is published to https://github.com/pokt-network/gateway-server/pkgs/container/pocket-gateway-server

## Docker Compose
There is an all-inclusive docker-compose file available for development [docker-compose.yml](docker-compose.yml)

## Creating a DB Migration
Migrations are like version control for your database, allowing your team to define and share the application's database schema definition.
Before running a migration make sure to install the go lang migration cli on your machine.
Expand Down Expand Up @@ -54,10 +59,6 @@ Run this command to run tests:
go test ./...
```

## Docker Compose
There is an all-inclusive docker-compose file available for usage [docker-compose.yml](docker-compose.yml)


## Contributing Guidelines
1. Create a Github Issue on the feature/issue you're working on.
2. Fork the project
Expand Down
Binary file added cmd/gateway_server/internal/.DS_Store
Binary file not shown.
58 changes: 38 additions & 20 deletions cmd/gateway_server/internal/config/dot_env_config_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,87 @@ import (
"fmt"
"github.com/joho/godotenv"
"os"
"pokt_gateway_server/internal/config"
"pokt_gateway_server/internal/global_config"
"strconv"
"time"
)

const (
defaultAltruistRequestTimeout = time.Second * 30
)

// Environment variable names
const (
poktRPCFullHostEnv = "POKT_RPC_FULL_HOST"
httpServerPortEnv = "HTTP_SERVER_PORT"
poktRPCTimeoutEnv = "POKT_RPC_TIMEOUT"
altruistRequestTimeoutEnv = "ALTRUIST_REQUEST_TIMEOUT"
dbConnectionUrlEnv = "DB_CONNECTION_URL"
sessionCacheTTLEnv = "SESSION_CACHE_TTL"
environmentStageEnv = "ENVIRONMENT_STAGE"
poktApplicationsEncryptionKeyEnv = "POKT_APPLICATIONS_ENCRYPTION_KEY"
apiKey = "API_KEY"
)

// DotEnvConfigProvider implements the GatewayServerProvider interface.
type DotEnvConfigProvider struct {
// DotEnvGlobalConfigProvider implements the GatewayServerProvider interface.
type DotEnvGlobalConfigProvider struct {
poktRPCFullHost string
httpServerPort uint
poktRPCTimeout time.Duration
poktRPCRequestTimeout time.Duration
sessionCacheTTL time.Duration
environmentStage config.EnvironmentStage
environmentStage global_config.EnvironmentStage
poktApplicationsEncryptionKey string
databaseConnectionUrl string
apiKey string
altruistRequestTimeout time.Duration
}

func (c DotEnvConfigProvider) GetAPIKey() string {
func (c DotEnvGlobalConfigProvider) GetAPIKey() string {
return c.apiKey
}

// GetPoktRPCFullHost returns the PoktRPCFullHost value.
func (c DotEnvConfigProvider) GetPoktRPCFullHost() string {
func (c DotEnvGlobalConfigProvider) GetPoktRPCFullHost() string {
return c.poktRPCFullHost
}

// GetHTTPServerPort returns the HTTPServerPort value.
func (c DotEnvConfigProvider) GetHTTPServerPort() uint {
func (c DotEnvGlobalConfigProvider) GetHTTPServerPort() uint {
return c.httpServerPort
}

// GetPoktRPCTimeout returns the PoktRPCTimeout value.
func (c DotEnvConfigProvider) GetPoktRPCTimeout() time.Duration {
return c.poktRPCTimeout
func (c DotEnvGlobalConfigProvider) GetPoktRPCRequestTimeout() time.Duration {
return c.poktRPCRequestTimeout
}

// GetSessionCacheTTL returns the time value for session to expire in cache.
func (c DotEnvConfigProvider) GetSessionCacheTTL() time.Duration {
return c.poktRPCTimeout
func (c DotEnvGlobalConfigProvider) GetSessionCacheTTL() time.Duration {
return c.poktRPCRequestTimeout
}

// GetEnvironmentStage returns the EnvironmentStage value.
func (c DotEnvConfigProvider) GetEnvironmentStage() config.EnvironmentStage {
func (c DotEnvGlobalConfigProvider) GetEnvironmentStage() global_config.EnvironmentStage {
return c.environmentStage
}

// GetPoktApplicationsEncryptionKey: Key used to decrypt pokt applications private key.
func (c DotEnvConfigProvider) GetPoktApplicationsEncryptionKey() string {
func (c DotEnvGlobalConfigProvider) GetPoktApplicationsEncryptionKey() string {
return c.poktApplicationsEncryptionKey
}

// GetDatabaseConnectionUrl returns the PoktRPCFullHost value.
func (c DotEnvConfigProvider) GetDatabaseConnectionUrl() string {
func (c DotEnvGlobalConfigProvider) GetDatabaseConnectionUrl() string {
return c.databaseConnectionUrl
}

// NewDotEnvConfigProvider creates a new instance of DotEnvConfigProvider.
func NewDotEnvConfigProvider() *DotEnvConfigProvider {
// GetDatabaseConnectionUrl returns the PoktRPCFullHost value.
func (c DotEnvGlobalConfigProvider) GetAltruistRequestTimeout() time.Duration {
return c.altruistRequestTimeout
}

// NewDotEnvConfigProvider creates a new instance of DotEnvGlobalConfigProvider.
func NewDotEnvConfigProvider() *DotEnvGlobalConfigProvider {
_ = godotenv.Load()

poktRPCTimeout, err := time.ParseDuration(getEnvVar(poktRPCTimeoutEnv))
Expand All @@ -91,15 +102,22 @@ func NewDotEnvConfigProvider() *DotEnvConfigProvider {
panic(fmt.Sprintf("Error parsing %s: %s", sessionCacheTTLDuration, err))
}

return &DotEnvConfigProvider{
altruistRequestTimeoutDuration, err := time.ParseDuration(getEnvVar(altruistRequestTimeoutEnv))
if err != nil {
// Provide a default to prevent any breaking changes with new env variable.
altruistRequestTimeoutDuration = defaultAltruistRequestTimeout
}

return &DotEnvGlobalConfigProvider{
poktRPCFullHost: getEnvVar(poktRPCFullHostEnv),
httpServerPort: uint(httpServerPort),
poktRPCTimeout: poktRPCTimeout,
poktRPCRequestTimeout: poktRPCTimeout,
sessionCacheTTL: sessionCacheTTLDuration,
databaseConnectionUrl: getEnvVar(dbConnectionUrlEnv),
environmentStage: config.EnvironmentStage(getEnvVar(environmentStageEnv)),
environmentStage: global_config.EnvironmentStage(getEnvVar(environmentStageEnv)),
poktApplicationsEncryptionKey: getEnvVar(poktApplicationsEncryptionKeyEnv),
apiKey: getEnvVar(apiKey),
altruistRequestTimeout: altruistRequestTimeoutDuration,
}
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/gateway_server/internal/config/provider.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package config

import (
"pokt_gateway_server/internal/config"
"pokt_gateway_server/internal/global_config"
)

type GatewayServerProvider interface {
GetHTTPServerPort() uint
config.DBCredentialsProvider
config.PoktNodeConfigProvider
config.SecretProvider
config.EnvironmentProvider
global_config.DBCredentialsProvider
global_config.PoktNodeConfigProvider
global_config.SecretProvider
global_config.EnvironmentProvider
}
14 changes: 7 additions & 7 deletions cmd/gateway_server/internal/controllers/pokt_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"pokt_gateway_server/cmd/gateway_server/internal/common"
"pokt_gateway_server/cmd/gateway_server/internal/models"
"pokt_gateway_server/cmd/gateway_server/internal/transform"
"pokt_gateway_server/internal/config"
"pokt_gateway_server/internal/apps_registry"
"pokt_gateway_server/internal/db_query"
"pokt_gateway_server/internal/pokt_apps_registry"
"pokt_gateway_server/internal/global_config"
"pokt_gateway_server/pkg/pokt/pokt_v0"
pokt_models "pokt_gateway_server/pkg/pokt/pokt_v0/models"
)
Expand All @@ -20,17 +20,17 @@ type addApplicationBody struct {
PrivateKey string `json:"private_key"`
}

// RelayController handles relay requests for a specific chain.
// PoktAppsController handles requests for staked applications
type PoktAppsController struct {
logger *zap.Logger
query db_query.Querier
poktClient pokt_v0.PocketService
appRegistry pokt_apps_registry.AppsRegistryService
secretProvider config.SecretProvider
appRegistry apps_registry.AppsRegistryService
secretProvider global_config.SecretProvider
}

// NewRelayController creates a new instance of RelayController.
func NewPoktAppsController(appRegistry pokt_apps_registry.AppsRegistryService, query db_query.Querier, secretProvider config.SecretProvider, logger *zap.Logger) *PoktAppsController {
// NewPoktAppsController creates a new instance of PoktAppsController.
func NewPoktAppsController(appRegistry apps_registry.AppsRegistryService, query db_query.Querier, secretProvider global_config.SecretProvider, logger *zap.Logger) *PoktAppsController {
return &PoktAppsController{appRegistry: appRegistry, query: query, secretProvider: secretProvider, logger: logger}
}

Expand Down
Loading
Loading