booklearner / go-tableland

The Go implementation of a validator in Tableland.

Home Page:https://tableland.xyz/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

image

Go Tableland

This project is part of a POC of the Tableland project.

Tableland POC

It implements the validator as a JSON-RPC server responsible for updating a Postgres database.

API Spec

Postman Collection

Current state of the project (and design decisions)

  • It has a JSON-RPC server responsible for handling user calls such as createTable and runSQL
  • It has additional HTTP endpoints for getting data from the sytems
    • GET /tables/{id} for table's metadata
    • GET /tables/controller/{address} to get all tables a controller address owns
  • It uses JWT authentication on the JSON-RPC calls. The JWT is token is created in the client using textileio/storage-js
  • The JSON-RPC is implemented using Ethereum's implementation of the 2.0 spec
  • The JSON-RPC server is an HTTP server (Just for clarification. It could also be just a TCP server.)
  • The server is currently deployed as a docker container inside a Compute Engine VM
  • Configs can be passed with flags, config.json file or env variables (it uses the uConfig package)
  • There is a Postgres database running inside the same Compute Engine VM as the container
  • For local development, there is a docker-compose file. Just execute make up to have the validator up and running.
  • For local development, you need to connect to a Ethereum node. The best approach now is to run a local hardhat container using textileio/eth-tableland/pull/5

Contributing

More information to come about the required development environment and workflow.

Updating smart contract bindings

The go-tableland interactions with the registry and NFT smart contracts are done using generated Golang bindings in the pkg/tables/impl/ethereum and pkg/<fill me in> packages, respectively. The bindings are generated by running make ethereum, but rely on the presence of some manually imported/maintained files in each package: abi.json and bytecode.bin. If anything about the smart contract APIs changes, these files need to be updated, and the Go bindings re-generated. The contents of these files are created by compiling the smart contracts in eth-tableland and copying some of the resulting build output.

Building eth-tableland contracts

Check out the latest code from eth-tableland and follow the instructions in the README.md to setup and compile the contracts.

Then follow the instructions to extract the contract ABI and bytecode.

Copy the resulting abi.json and bytecode.bin files to the corresponding Go package in this repo, and then run make ethereum. If the contract API changed at all, you'll have to make the approprite updates to any code that consumes the generated bindings.

How to publish a new version

This project uses docker and Google's Artifact Registry for managing container images.

make image    # builds the image
make publish  # publishes to Artifact Registry

Make sure you have gcloud installed and configured. If you get an error while trying to publish, try to run gcloud auth configure-docker us-west1-docker.pkg.dev

How to deploy

docker run -d --name api -p 80:8080 --add-host=database:172.17.0.1 -e DB_HOST=database -e DB_PASS=[[PASSWORD]] -e DB_USER=validator -e DB_NAME=tableland -e DB_PORT=5432 -e REGISTRY_ETHENDPOINT=http://tableland.com:8545 -e REGISTRY_CONTRACTADDRESS=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 [[IMAGE]]

About

The Go implementation of a validator in Tableland.

https://tableland.xyz/


Languages

Language:Go 99.1%Language:Makefile 0.7%Language:Dockerfile 0.1%Language:Shell 0.1%