Skip to content

Commit

Permalink
Donut hardfork preparation + release v0.8.2 (#164)
Browse files Browse the repository at this point in the history
* Update kliento dep with celo-blockchain module rename

* Rename all github...go-ethereum -> celo-blockchain

* Readd kliento to go.mod

* Change hdwallet import

* Fix compile errors

* Fix conflict between kliento and celo-blockchain deps

* Fix marshalling null gatewayfee test and gofmt

* Update kliento with cleaned deps

* More updates to kliento and cip35 branch

* Go mod tidy

* Update go.sum

* Update to official blockchain v1.3.0

* Bump version for release to 0.8.2

* Remove stale TODO
  • Loading branch information
eelanagaraj authored May 3, 2021
1 parent dcc32ea commit 5e63a3c
Show file tree
Hide file tree
Showing 61 changed files with 235 additions and 298 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ RUN go build --tags musl -o rosetta .
# Integrates celo-blockchain & rosetta builds into a single container
# Outputs: rosetta & geth binaries on /usr/loca/bin
#---------------------------------------------------------------------
# geth mainnet (1.2.4)
FROM us.gcr.io/celo-org/geth:8ae8f032979aba42ad64a0ba67a3a5585dd9c63b
# geth mainnet (1.3.0)
FROM us.gcr.io/celo-org/geth:1.3.0
ARG COMMIT_SHA

RUN apk add --no-cache ca-certificates
Expand Down
82 changes: 41 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ A monitoring server for celo-blockchain

Celo Rosetta is an RPC server that exposes an API to:

* Query Celo's Blockchain
* Obtain Balance Changing Operations
* Construct Airgapped Transactions
- Query Celo's Blockchain
- Obtain Balance Changing Operations
- Construct Airgapped Transactions

With a special focus on getting balance change operations, Celo Rosetta provides an easy way to obtain changes that are not easily queryable using
the celo-blockchain rpc; such as:

* Gas Fee distribution
* Gold transfers (internal & external). Taking in account Tobin Tax
* Epoch Rewards Distribution
* LockedGold & Election Operations
- Gas Fee distribution
- Gold transfers (internal & external). Taking in account Tobin Tax
- Epoch Rewards Distribution
- LockedGold & Election Operations

## RPC endpoints

Rosetta exposes the following endpoints:

* `POST /network/list`: Get List of Available Networks
* `POST /network/status`: Get Network Status
* `POST /network/options`: Get Network Options
* `POST /block`: Get a Block
* `POST /block/transaction`: Get a Block Transaction
* `POST /mempool`: Get All Mempool Transactions
* `POST /mempool/transaction`: Get a Mempool Transaction
* `POST /account/balance`: Get an Account Balance
* `POST /construction/metadata`: Get Transaction Construction Metadata
* `POST /construction/submit`: Submit a Signed Transaction
- `POST /network/list`: Get List of Available Networks
- `POST /network/status`: Get Network Status
- `POST /network/options`: Get Network Options
- `POST /block`: Get a Block
- `POST /block/transaction`: Get a Block Transaction
- `POST /mempool`: Get All Mempool Transactions
- `POST /mempool/transaction`: Get a Mempool Transaction
- `POST /account/balance`: Get an Account Balance
- `POST /construction/metadata`: Get Transaction Construction Metadata
- `POST /construction/submit`: Submit a Signed Transaction

For an understanding of inputs & outputs check [servicer.go](./service/rpc/servicer.go)

Expand Down Expand Up @@ -79,21 +79,21 @@ Running the Rosetta RPC Server from scratch will take some time to sync, since i

You will need the following three repositories cloned locally:

* `rosetta` (this repo)
* [`celo-blockchain`](https://github.com/celo-org/celo-blockchain)
- `rosetta` (this repo)
- [`celo-blockchain`](https://github.com/celo-org/celo-blockchain)

You also need the following dependencies to be met:

* `go >= 1.14`
* `golangci` ([installation instructions](https://golangci-lint.run/usage/install/#local-installation)) (linter dependency for the Makefile)
- `go >= 1.14`
- `golangci` ([installation instructions](https://golangci-lint.run/usage/install/#local-installation)) (linter dependency for the Makefile)

#### Running on Alfajores (Testnet)

Prerequisites:

* Checkout `celo-blockchain` tag `v1.2.4` (`git fetch --all && git checkout v1.2.4`) (NOTE: check that this matches the version specified in `rosetta`'s `go.mod` file) and `make geth`
* Checkout `rosetta` tag `v0.8.0` (`git fetch --all && git checkout v0.8.0`) (or latest released tag) and `make all`
* Run `make alfajores-env` to create an empty datadir with the genesis block (only needs to be run the first time, upon initializing the service). The output should look something like this:
- Checkout `celo-blockchain` tag `v1.3.0` (`git fetch --all && git checkout v1.3.0`) (NOTE: check that this matches the version specified in `rosetta`'s `go.mod` file) and `make geth`
- Checkout `rosetta` tag `v0.8.2` (`git fetch --all && git checkout v0.8.2`) (or latest released tag) and `make all`
- Run `make alfajores-env` to create an empty datadir with the genesis block (only needs to be run the first time, upon initializing the service). The output should look something like this:

```sh
mkdir -p ./envs/alfajores
Expand Down Expand Up @@ -123,10 +123,10 @@ This is the same as above with a few differences (generally: specifying `rc1` vs

Prerequisites:

* `celo-blockchain`: same as above
* Export paths: same as above
* Checkout `rosetta`: same as above
* Run `make rc1-env` to create an empty datadir with the genesis block. The output should look something like this:
- `celo-blockchain`: same as above
- Export paths: same as above
- Checkout `rosetta`: same as above
- Run `make rc1-env` to create an empty datadir with the genesis block. The output should look something like this:

```sh
mkdir -p ./envs/rc1
Expand Down Expand Up @@ -169,7 +169,7 @@ INFO [01-28|14:09:25.731] Stored 1000 blocks srv=celo-moni

Prerequisites:

* [Install](https://docs.docker.com/engine/install/) and run `docker` (tested with version `19.03.12`)
- [Install](https://docs.docker.com/engine/install/) and run `docker` (tested with version `19.03.12`)

Rosetta is released as a docker image: `us.gcr.io/celo-testnet/rosetta`. All versions can be found on the [registry page](https://us.gcr.io/celo-testnet/rosetta). Within the docker image, we pack the `rosetta` binary and also the `geth` binary from `celo-blockchain`. Rosetta will run both.

Expand All @@ -195,18 +195,18 @@ docker run --name rosetta --rm \

To run this for a different network, replace the genesis block generation and staticnode lines with values specific to the network, as detailed directly below:

* `genesis.json` for the target network (can be found by running the following, selecting one of `alfajores`, `baklava`, `rc1` as `<NETWORK>` in `curl 'https://storage.googleapis.com/genesis_blocks/<NETWORK>' > genesis.json`).
* `staticNodes` or `bootnodes`.
* With `staticNodes` Rosetta will directly peer to the list of staticNode provided. This node can be any you have access to. For a public list check `https://storage.cloud.google.com/static_nodes/<NETWORK>`
- `genesis.json` for the target network (can be found by running the following, selecting one of `alfajores`, `baklava`, `rc1` as `<NETWORK>` in `curl 'https://storage.googleapis.com/genesis_blocks/<NETWORK>' > genesis.json`).
- `staticNodes` or `bootnodes`.
- With `staticNodes` Rosetta will directly peer to the list of staticNode provided. This node can be any you have access to. For a public list check `https://storage.cloud.google.com/static_nodes/<NETWORK>`

## Airgap Client Guide

The Celo Rosetta Airgap module is designed to facilitate signing transactions, parameterized by contemporaenous network metadata, in an offline context.

Examples of this metadata include:

* network wide state like "gas price minimum"
* argument specific state like vote amount "effect on validator priority queue"
- network wide state like "gas price minimum"
- argument specific state like vote amount "effect on validator priority queue"

```js
AirGapServer {
Expand All @@ -232,31 +232,31 @@ For a code resource, please see the [examples](./examples/airgap/main.go).

In addition to the dependencies listed above under the instructions for running from `rosetta` source code, you also need:

* `openapi-generator` To re-generate rpc scaffold ([install link](https://openapi-generator.tech))
- `openapi-generator` To re-generate rpc scaffold ([install link](https://openapi-generator.tech))

### Build Commands

Important commands:

* `make all`: Builds project (compiles all modules), same as `go build ./...`
* `make test` or `go test ./...` to run unit tests
- `make all`: Builds project (compiles all modules), same as `go build ./...`
- `make test` or `go test ./...` to run unit tests

### Interaction with Celo Core Contracts

Rosetta uses [kliento](https://github.com/celo-org/kliento) to interact with the necessary Celo Core Contracts.

## How to run rosetta-cli-checks

* Install the [`rosetta-cli`](https://github.com/coinbase/rosetta-cli) according to the instructions. (Note that on Mac, installing the `rosetta-cli` to `/usr/local/bin` or adding its location to you `$PATH` will allow you to call `rosetta-cli` directly on the command line rather than needing to provide the path to the executable). Current testing has been done with `v0.5.16` of the `rosetta-cli`.
* Run the Rosetta service in the background for the respective network (currently only alfajores for both Data and Construction checks)
* Run the CLI checks for alfajores as follows:
- Install the [`rosetta-cli`](https://github.com/coinbase/rosetta-cli) according to the instructions. (Note that on Mac, installing the `rosetta-cli` to `/usr/local/bin` or adding its location to you `$PATH` will allow you to call `rosetta-cli` directly on the command line rather than needing to provide the path to the executable). Current testing has been done with `v0.5.16` of the `rosetta-cli`.
- Run the Rosetta service in the background for the respective network (currently only alfajores for both Data and Construction checks)
- Run the CLI checks for alfajores as follows:

```sh
# alfajores; specify construction or data
rosetta-cli check:construction --configuration-file PATH/TO/rosetta/rosetta-cli-conf/testnet/cli-config.json
```

*Note that running the checks to completion will take a long time if this is the first time you are running Rosetta locally. Under the hood, the service is syncing a full archive node, which takes time (likely a couple of days on a normal laptop). The construction service needs to reach the tip before submitting transactions. The data checks will take a while to complete as well (likely a couple of days on a normal laptop with the current settings) as they reconcile balances for the entire chain.*
_Note that running the checks to completion will take a long time if this is the first time you are running Rosetta locally. Under the hood, the service is syncing a full archive node, which takes time (likely a couple of days on a normal laptop). The construction service needs to reach the tip before submitting transactions. The data checks will take a while to complete as well (likely a couple of days on a normal laptop with the current settings) as they reconcile balances for the entire chain._

### How to generate `bootstrap_balances.json`

Expand Down
10 changes: 5 additions & 5 deletions airgap/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"errors"
"math/big"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
ethereum "github.com/celo-org/celo-blockchain"
"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/celo-blockchain/core/types"
"github.com/celo-org/celo-blockchain/crypto"
"github.com/celo-org/celo-blockchain/rlp"
)

type Server interface {
Expand Down
6 changes: 3 additions & 3 deletions airgap/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/celo-blockchain/core/types"
"github.com/celo-org/celo-blockchain/crypto"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion airgap/arg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/celo-org/celo-blockchain/common"
)

type airgapArgBuilderImpl struct {
Expand Down
2 changes: 1 addition & 1 deletion airgap/arg_parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/celo-org/celo-blockchain/common"
)

type argParser func(interface{}) (interface{}, error)
Expand Down
2 changes: 1 addition & 1 deletion airgap/arg_parsers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/celo-org/celo-blockchain/common"
. "github.com/onsi/gomega"
)

Expand Down
10 changes: 5 additions & 5 deletions airgap/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (
"crypto/ecdsa"
"fmt"

"github.com/celo-org/celo-blockchain/accounts"
"github.com/celo-org/celo-blockchain/accounts/abi"
"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/celo-blockchain/core/types"
"github.com/celo-org/celo-blockchain/crypto"
"github.com/celo-org/kliento/contracts"
"github.com/celo-org/kliento/registry"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
)

type clientImpl struct {
Expand Down
2 changes: 1 addition & 1 deletion airgap/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package airgap
import (
"fmt"

"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/kliento/registry"
"github.com/ethereum/go-ethereum/common"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion airgap/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"fmt"
"math/big"

"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/kliento/registry"
"github.com/ethereum/go-ethereum/common"
)

var ReleaseGold = "ReleaseGold"
Expand Down
2 changes: 1 addition & 1 deletion airgap/methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/celo-org/celo-blockchain/common"
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 1 addition & 1 deletion airgap/server/arg_preprocessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/celo-org/celo-blockchain/common"
)

func preprocessAuthorizeSigner(ctx context.Context, srvCtx ServerContext, args []interface{}) ([]interface{}, error) {
Expand Down
2 changes: 1 addition & 1 deletion airgap/server/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"math/big"
"testing"

"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/rosetta/airgap"
"github.com/ethereum/go-ethereum/common"
. "github.com/onsi/gomega"
)

Expand Down
6 changes: 3 additions & 3 deletions airgap/server/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"context"
"fmt"

"github.com/celo-org/celo-blockchain/accounts/abi"
"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/rosetta/airgap"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
)

var serverCallEventDefinitions = []*airgap.CeloEvent{
Expand Down Expand Up @@ -56,7 +56,7 @@ func hydrateEvents(srvCtx ServerContext, events []*airgap.CeloEvent) (map[*airga

func airgapEventFactory(srvCtx ServerContext, evt abi.Event, event *airgap.CeloEvent) airGapServerEvent {
return func(ctx context.Context, restTopics [][]common.Hash) [][]common.Hash {
topic0 := evt.ID()
topic0 := evt.ID
var topics [][]common.Hash
topics = append(topics, []common.Hash{topic0})
topics = append(topics, restTopics...)
Expand Down
2 changes: 1 addition & 1 deletion airgap/server/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"context"
"fmt"

"github.com/celo-org/celo-blockchain/accounts/abi"
"github.com/celo-org/kliento/contracts"
"github.com/celo-org/kliento/registry"
"github.com/celo-org/rosetta/airgap"
"github.com/ethereum/go-ethereum/accounts/abi"
)

var abiFactoryMap = map[string]func() (*abi.ABI, error){
Expand Down
2 changes: 1 addition & 1 deletion airgap/server/methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"math/big"
"testing"

"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/rosetta/airgap"
"github.com/ethereum/go-ethereum/common"
. "github.com/onsi/gomega"
"golang.org/x/net/context"
)
Expand Down
6 changes: 3 additions & 3 deletions airgap/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"log"
"math/big"

ethereum "github.com/celo-org/celo-blockchain"
"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/celo-blockchain/core/types"
"github.com/celo-org/kliento/registry"
"github.com/celo-org/rosetta/airgap"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)

// airGapServerMethod is a function that returns the tx.data for that method + parameters
Expand Down
10 changes: 5 additions & 5 deletions airgap/server/server_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import (
"context"
"math/big"

ethereum "github.com/celo-org/celo-blockchain"
"github.com/celo-org/celo-blockchain/accounts/abi/bind"
"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/celo-blockchain/core/types"
"github.com/celo-org/celo-blockchain/ethclient"
"github.com/celo-org/kliento/client"
"github.com/celo-org/kliento/contracts/helpers"
"github.com/celo-org/kliento/registry"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
)

type ServerContext interface {
Expand Down
6 changes: 3 additions & 3 deletions airgap/server/server_context_stub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"context"
"math/big"

ethereum "github.com/celo-org/celo-blockchain"
"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/celo-blockchain/core/types"
"github.com/celo-org/kliento/contracts/helpers"
"github.com/celo-org/kliento/registry"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)

type serverContextStub struct{}
Expand Down
Loading

0 comments on commit 5e63a3c

Please sign in to comment.