Giter Site home page Giter Site logo

nezz0746 / anvil-instancing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saucepoint/anvil-instancing

0.0 1.0 0.0 40 KB

Dockerizing anvil to run on digital ocean

License: MIT License

Python 32.49% HCL 37.96% Dockerfile 12.98% Solidity 16.56%

anvil-instancing's Introduction

anvil-instancing

Dockerizing anvil from foundry to run on Digital Ocean Droplets, to act as lightweight private chains

The instance(s) are accessible through typical JSON RPC clients (ethers.js, web3py).

i.e. web clients can submit free transactions to the RPC to represent progression or outcomes of a game. Events can be parsed (via the RPC) and used for rendering the outcomes.


Features

  • Simplified infrastructure deployment and container initialization via Terraform. No need to click through web interfaces; minimal command-lines

  • Host a multitude of anvil instances for scaling

  • Automated state-instantiation. Define game logic as a contract, and automatically deploy it to the private chain when anvil instances are created

  • Anvil is fast -- it runs on affordable, lightweight instances (1 vCPU / 1GB RAM) - Benchmarks

  • Flexible -- modify the Dockerfile to add additional parameters to the anvil instance (i.e. block times, gas limit, starting balances, etc)

Trade Offs

  • To minimize memory and disk consumption, anvil instances should be restarted or reset occasionally. This means the chain's state should be considered emphemeral

Configuration

Off-the-shelf modifications to tailor your private anvil node:

  1. Modify/Replace src/Counter.sol and script/Counter.s.sol with any contracts you want to deploy when starting the private anvil node
    1. For example: deploy game logic, assets-as-NFTs, etc
  2. Find ANVIL_START in the Dockerfile and attach additional anvil flags

Setup

Requirements & Dependencies:

  • Docker installed & configured with Docker Hub. You should be able to push your docker container to the Hub
  • Terraform installed
  • Copy .env.sample to .env
    1. See in-line comments on how to set the values
    2. Note: it is recommended to create an SSH key separate from your default github SSH key. This separate SSH key will be used for SSH'ing into the droplets, and can be shared with teammates.
  1. Build the Docker Image for Digital Ocean Droplets (take note of --platform flag, especially on Apple Silicon machines)

    docker build --platform linux/amd64 --tag saucepoint/anvil-instancing .

    (replace the docker repository with your own)

  2. Push to Docker Hub

    docker push saucepoint/anvil-instancing

    (replace the docker repository with your own)

  3. Create & start the Anvil instances (Droplets), via Terraform

    1. cd terraform
    2. source ../.env -- set variables for Terraform
    3. terraform init -- installs the DigitalOcean provider
    4. terraform apply -- creates required infrastructure; starts the containers on the newly created droplets

    If you are using a new SSH key, you may need to add it to your agent:

    eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_NEW_SSH_KEY_NON_PUB

  4. Verify that clients can connect to the RPCs. Run the liveness.py in /python directory

Destroying

Great for starting over or shutting down your prototype

To destroy the instances, firewall, and SSH key:

cd terraform
terraform destroy

anvil-instancing's People

Contributors

mattsse avatar saucepoint avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.