emerald-web3-gateway

command module
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2022 License: GPL-3.0 Imports: 22 Imported by: 0

README

emerald-web3-gateway

ci-lint ci-test codecov

Web3 Gateway for Oasis Emerald EVM.

Building and Testing

Prerequisites
  • Go (at least version 1.17.3).
  • PostgreSQL (at least version 13.3).

Additionally, for testing:

Build

To build the binary run:

make build
Test

To run tests:

Start PostgreSQL (for testing Postgres Docker container can be used):

docker run --rm --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:13.3-alpine

In a separate terminal, start an Oasis development network:

export OASIS_EMERALD_VERSION=6.0.0
export OASIS_NET_RUNNER=<path-to-oasis-core-artifacts>/oasis-net-runner
export OASIS_NODE=<path-to-oasis-core-artifacts>/oasis-node
export OASIS_EMERALD_PARATIME=<path-to-emerald-paratime>/emerald-paratime
export OASIS_NODE_DATADIR=/tmp/oasis-evm-gateway-tests

./tests/tools/spinup-oasis-stack.sh

Run tests:

make test

Running the Gateway on Testnet/Mainnet

The gateway connects to an Emerald enabled Oasis Paratime Client Node.

Set up the config file (e.g. gateway.yml) appropriately:

runtime_id: <emerald_paratime_id>
node_address: "unix:<path-to-oasis-node-unix-socket>"
enable_pruning: false
pruning_step: 100000
indexing_start: 0

log:
  level: debug
  format: json

database:
  host: <postgresql_host>
  port: <postgresql_port>
  db: <postgresql_db>
  user: <postgresql_user>
  password: <postgresql_password>
  dial_timeout: 5
  read_timeout: 10
  write_timeout: 5
  max_open_conns: 0

gateway:
  chain_id: <emerald_chain_id>
  http:
    host: <gateway_listen_interface>
    port: <gateway_listen_port>
    cors: ["*"]
  ws:
    host: <gateway_listen_interface>
    port: <gateway_listen_websocket_port>
    origins: ["*"]
  method_limits:
    get_logs_max_rounds: 100

Note: all configuration settings can also be set via environment variables. For example to set the database password use:

DATABASE__PASSWORD: <postgresql_password>

environment variable.

Start the gateway by running the emerald-web3-gateway binary:

emerald-web3-gateway --config gateway.yml
Wipe state to force a complete reindex

To wipe the DB state and force a reindexing use the truncate-db subcommand:

emerald-web3-gateway truncate-db --config gateway.yml --unsafe

Warning: this will wipe all existing state in the Postgres DB and can lead to extended downtime while the Web3 Gateway is reindexing the blocks.

Contributing

See our Contributing Guidelines.

Versioning

See our Versioning document.

Release Process

See our Release Process document.

Credits

Parts of the code heavily based on go-ethereum.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
benchmarks module
db
migrator
Package migrator implements a custom migrator inspired by the upstram [migrator](https://github.com/uptrace/bun/blob/master/migrate/migrator.go).
Package migrator implements a custom migrator inspired by the upstram [migrator](https://github.com/uptrace/bun/blob/master/migrate/migrator.go).
rpc
eth
net
rpc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL