Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07df0337d1 | ||
|
|
551efea107 | ||
|
|
ebaacb3733 | ||
|
|
a295e7d4b2 | ||
|
|
4b749e8544 | ||
|
|
5fdd60c804 | ||
|
|
4bd5a774f1 | ||
|
|
d2252193ec |
+9
-9
@@ -1,16 +1,16 @@
|
||||
.git
|
||||
.travis.yml
|
||||
.idea
|
||||
bin
|
||||
.gitignore
|
||||
integration_test
|
||||
LICENSE
|
||||
postgraphile
|
||||
.private_blockchain_password
|
||||
README.md
|
||||
scripts
|
||||
Supfile
|
||||
test_config
|
||||
.travis.yml
|
||||
vulcanizedb.log
|
||||
|
||||
LICENSE
|
||||
README.md
|
||||
|
||||
integration
|
||||
test
|
||||
scripts
|
||||
Dockerfile
|
||||
|
||||
**/node_modules
|
||||
@@ -1,51 +0,0 @@
|
||||
name: Test, Build, and/or Publish
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
pre_job:
|
||||
# continue-on-error: true # Uncomment once integration is finished
|
||||
runs-on: ubuntu-latest
|
||||
# Map a step output to a job output
|
||||
outputs:
|
||||
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
||||
steps:
|
||||
- id: skip_check
|
||||
uses: fkirc/skip-duplicate-actions@v4
|
||||
with:
|
||||
# All of these options are optional, so you can remove them if you are happy with the defaults
|
||||
concurrent_skipping: "never"
|
||||
skip_after_successful_duplicate: "true"
|
||||
do_not_skip: '["workflow_dispatch", "schedule"]'
|
||||
run-tests:
|
||||
uses: ./.github/workflows/tests.yaml
|
||||
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
|
||||
needs: pre_job
|
||||
build:
|
||||
name: Run docker build
|
||||
runs-on: ubuntu-latest
|
||||
needs: run-tests
|
||||
if: |
|
||||
always() &&
|
||||
(needs.run-tests.result == 'success' || needs.run-tests.result == 'skipped') &&
|
||||
github.event_name == 'release'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- id: vars
|
||||
name: Output SHA and version tag
|
||||
run: |
|
||||
echo sha=$(echo ${GITHUB_SHA:0:7}) >> "$GITHUB_OUTPUT"
|
||||
echo tag=$(echo ${GITHUB_REF#refs/tags/}) >> "$GITHUB_OUTPUT"
|
||||
- name: Build and tag Docker image
|
||||
run: |
|
||||
docker build . \
|
||||
-t cerc-io/ipld-eth-server \
|
||||
-t git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}} \
|
||||
-t git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.tag}}
|
||||
- name: Push Docker tags
|
||||
run: |
|
||||
echo ${{ secrets.GITEA_PUBLISH_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin
|
||||
docker push git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}}
|
||||
docker push git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.tag}}
|
||||
@@ -0,0 +1,28 @@
|
||||
name: Publish Docker image
|
||||
on:
|
||||
release:
|
||||
types: [published, edited]
|
||||
jobs:
|
||||
build:
|
||||
name: Build and publish image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- id: vars
|
||||
name: Output SHA and version tag
|
||||
run: |
|
||||
echo "sha=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
- name: Build and tag Docker image
|
||||
env:
|
||||
GIT_VDBTO_TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
||||
run: |
|
||||
docker build . \
|
||||
--build-arg GIT_VDBTO_TOKEN \
|
||||
-t git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}} \
|
||||
-t git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.tag}}
|
||||
- name: Push Docker tags
|
||||
run: |
|
||||
echo ${{ secrets.GITEA_PUBLISH_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin
|
||||
docker push git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}}
|
||||
docker push git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.tag}}
|
||||
@@ -2,9 +2,23 @@ name: Test the stack.
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
# Job headers are hidden when not top-level - run them directly for readability until fixed:
|
||||
# https://github.com/go-gitea/gitea/issues/26736
|
||||
pull_request:
|
||||
branches: '*'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- ci-test
|
||||
|
||||
env:
|
||||
# Needed until we can incorporate docker startup into the executor container
|
||||
DOCKER_HOST: unix:///var/run/dind.sock
|
||||
SO_VERSION: v1.1.0-e0b5318-202309201927 # contains fixes for plugeth stack
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: "Run unit tests"
|
||||
name: Run unit tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -12,15 +26,24 @@ jobs:
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
check-latest: true
|
||||
- name: "Run DB container"
|
||||
- name: Run dockerd
|
||||
run: |
|
||||
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
||||
sleep 5
|
||||
- name: Run DB container
|
||||
run: docker compose -f test/compose-db.yml up --wait --quiet-pull
|
||||
- name: "Build and run tests"
|
||||
- name: Configure Gitea access
|
||||
env:
|
||||
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
||||
run: |
|
||||
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf https://git.vdb.to/
|
||||
- name: Build and run tests
|
||||
run: |
|
||||
go install github.com/onsi/ginkgo/v2/ginkgo
|
||||
ginkgo -v -r --skipPackage=./integration
|
||||
|
||||
integration-test:
|
||||
name: "Run integration tests"
|
||||
name: Run integration tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -28,64 +51,61 @@ jobs:
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
check-latest: true
|
||||
- name: "Install stack-orchestrator"
|
||||
# FIXME: using my dev branch for v5 migration changes until a release has them
|
||||
# run: |
|
||||
# curl -L -O https://github.com/cerc-io/stack-orchestrator/releases/latest/download/laconic-so
|
||||
- name: Run dockerd
|
||||
run: |
|
||||
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
||||
sleep 5
|
||||
|
||||
- name: Build server image
|
||||
env:
|
||||
GIT_VDBTO_TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
||||
run: docker build . -t cerc/ipld-eth-server:local --build-arg GIT_VDBTO_TOKEN
|
||||
- name: Install jq
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
run: apt-get update && apt-get install -y jq
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: Install stack-orchestrator
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: cerc-io/stack-orchestrator
|
||||
ref: roy/ipld-eth-ci
|
||||
ref: ${{ env.SO_VERSION }}
|
||||
path: ./stack-orchestrator
|
||||
- run: pip install ./stack-orchestrator
|
||||
- name: "Run testnet stack"
|
||||
- name: Configure Gitea access
|
||||
env:
|
||||
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
||||
run: |
|
||||
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf https://git.vdb.to/
|
||||
|
||||
- name: Run testnet stack
|
||||
env:
|
||||
CERC_GO_AUTH_TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
||||
run: ./scripts/integration-setup.sh
|
||||
- name: "Build and run server"
|
||||
- name: Run server
|
||||
env:
|
||||
ETH_FORWARD_ETH_CALLS: false
|
||||
ETH_CHAIN_ID: ${{ env.ETH_CHAIN_ID }}
|
||||
ETH_CHAIN_CONFIG: ${{ env.ETH_CHAIN_CONFIG }}
|
||||
DEPLOYER_PRIVATE_KEY: ${{ env.DEPLOYER_PRIVATE_KEY }}
|
||||
run: docker compose -f test/compose-server.yml up --wait --quiet-pull
|
||||
- name: "Run tests"
|
||||
env:
|
||||
ETH_CHAIN_ID: ${{ env.ETH_CHAIN_ID }}
|
||||
ETH_HTTP_PATH: ${{ env.ETH_HTTP_PATH }}
|
||||
- name: Run tests
|
||||
run: |
|
||||
sleep 30
|
||||
go install github.com/onsi/ginkgo/v2/ginkgo
|
||||
ginkgo -v --label-filter '!proxy' -r ./integration
|
||||
|
||||
integration-test-eth-proxy:
|
||||
name: "Run direct-proxy integration tests"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
check-latest: true
|
||||
- name: "Install stack-orchestrator"
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: cerc-io/stack-orchestrator
|
||||
ref: roy/ipld-eth-ci
|
||||
path: ./stack-orchestrator
|
||||
- run: pip install ./stack-orchestrator
|
||||
- name: "Run testnet stack"
|
||||
- name: Run testnet stack without statediff
|
||||
env:
|
||||
CERC_RUN_STATEDIFF: false
|
||||
SKIP_BUILD: 1
|
||||
run: ./scripts/integration-setup.sh
|
||||
- name: "Build and run server"
|
||||
- name: Run server with call forwarding
|
||||
env:
|
||||
ETH_FORWARD_ETH_CALLS: true
|
||||
ETH_CHAIN_ID: ${{ env.ETH_CHAIN_ID }}
|
||||
ETH_CHAIN_CONFIG: ${{ env.ETH_CHAIN_CONFIG }}
|
||||
DEPLOYER_PRIVATE_KEY: ${{ env.DEPLOYER_PRIVATE_KEY }}
|
||||
run: docker compose -f test/compose-server.yml up --wait --quiet-pull
|
||||
- name: "Run tests"
|
||||
env:
|
||||
ETH_CHAIN_ID: ${{ env.ETH_CHAIN_ID }}
|
||||
ETH_HTTP_PATH: ${{ env.ETH_HTTP_PATH }}
|
||||
- name: Run eth_call proxy tests
|
||||
run: |
|
||||
sleep 30
|
||||
go install github.com/onsi/ginkgo/v2/ginkgo
|
||||
ginkgo -v --label-filter 'proxy' -r ./integration
|
||||
|
||||
-17
@@ -1,19 +1,2 @@
|
||||
.idea
|
||||
.vscode
|
||||
test_data_dir/
|
||||
contracts/*
|
||||
environments/*.toml
|
||||
Vagrantfile
|
||||
vagrant*.sh
|
||||
.vagrant
|
||||
test_scripts/
|
||||
ipld-eth-server
|
||||
postgraphile/build/
|
||||
postgraphile/node_modules/
|
||||
postgraphile/package-lock.json
|
||||
vulcanizedb.log
|
||||
db/migrations/20*.sql
|
||||
plugins/*.so
|
||||
postgraphile/*.toml
|
||||
postgraphile/schema.graphql
|
||||
vulcanizedb.pem
|
||||
|
||||
+14
-14
@@ -1,35 +1,35 @@
|
||||
FROM golang:1.19-alpine as builder
|
||||
|
||||
RUN apk --update --no-cache add gcc musl-dev
|
||||
# DEBUG
|
||||
RUN apk add busybox-extras
|
||||
FROM golang:1.21-alpine as debugger
|
||||
|
||||
# Include dlv
|
||||
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|
||||
|
||||
FROM golang:1.21-alpine as builder
|
||||
|
||||
RUN apk --update --no-cache add gcc musl-dev binutils-gold git
|
||||
|
||||
# Build ipld-eth-server
|
||||
WORKDIR /go/src/github.com/cerc-io/ipld-eth-server
|
||||
|
||||
ARG GIT_VDBTO_TOKEN
|
||||
|
||||
# Cache the modules
|
||||
ENV GO111MODULE=on
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
RUN go mod download
|
||||
RUN if [ -n "$GIT_VDBTO_TOKEN" ]; then git config --global url."https://$GIT_VDBTO_TOKEN:@git.vdb.to/".insteadOf "https://git.vdb.to/"; fi && \
|
||||
go mod download && \
|
||||
rm -f ~/.gitconfig
|
||||
|
||||
COPY . .
|
||||
|
||||
# Build the binary
|
||||
RUN GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o ipld-eth-server .
|
||||
|
||||
# Get migration tool
|
||||
WORKDIR /
|
||||
ARG GOOSE_VER="v3.6.1"
|
||||
ADD https://github.com/pressly/goose/releases/download/${GOOSE_VER}/goose_linux_x86_64 ./goose
|
||||
RUN chmod +x ./goose
|
||||
|
||||
# app container
|
||||
FROM alpine
|
||||
|
||||
RUN apk --update --no-cache add bash jq curl
|
||||
|
||||
ARG USER="vdm"
|
||||
ARG CONFIG_FILE="./environments/example.toml"
|
||||
|
||||
@@ -43,13 +43,13 @@ USER $USER
|
||||
COPY --chown=5000:5000 --from=builder /go/src/github.com/cerc-io/ipld-eth-server/$CONFIG_FILE config.toml
|
||||
COPY --chown=5000:5000 --from=builder /go/src/github.com/cerc-io/ipld-eth-server/entrypoint.sh .
|
||||
|
||||
RUN mkdir -p nitro-data && chown -R 5000:5000 nitro-data
|
||||
|
||||
# keep binaries immutable
|
||||
COPY --from=builder /go/src/github.com/cerc-io/ipld-eth-server/ipld-eth-server ipld-eth-server
|
||||
COPY --from=builder /goose goose
|
||||
COPY --from=builder /go/src/github.com/cerc-io/ipld-eth-server/environments environments
|
||||
|
||||
# Allow for debugging
|
||||
COPY --from=builder /go/bin/dlv /usr/local/bin/
|
||||
COPY --from=debugger /go/bin/dlv /usr/local/bin/
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
@@ -60,7 +60,7 @@ The corresponding CLI flags can be found with the `./ipld-eth-server serve --hel
|
||||
password = "" # $DATABASE_PASSWORD
|
||||
|
||||
[log]
|
||||
level = "info" # $LOGRUS_LEVEL
|
||||
level = "info" # $LOG_LEVEL
|
||||
|
||||
[server]
|
||||
ipcPath = "~/.vulcanize/vulcanize.ipc" # $SERVER_IPC_PATH
|
||||
|
||||
@@ -35,3 +35,49 @@ func addDatabaseFlags(command *cobra.Command) {
|
||||
viper.BindPFlag("database.user", command.PersistentFlags().Lookup("database-user"))
|
||||
viper.BindPFlag("database.password", command.PersistentFlags().Lookup("database-password"))
|
||||
}
|
||||
|
||||
func addNitroFlags(command *cobra.Command) {
|
||||
// nitro flags
|
||||
command.PersistentFlags().Bool("nitro-run-node-in-process", false, "nitro run node in process")
|
||||
command.PersistentFlags().String("nitro-rpc-query-rates-file", "", "nitro rpcQueryRatesFile")
|
||||
|
||||
command.PersistentFlags().String("nitro-pk", "", "nitro pk")
|
||||
command.PersistentFlags().String("nitro-chain-pk", "", "nitro chainPk")
|
||||
command.PersistentFlags().String("nitro-chain-url", "ws://127.0.0.1:8545", "nitro chainUrl")
|
||||
command.PersistentFlags().String("nitro-na-address", "", "nitro naAddress")
|
||||
command.PersistentFlags().String("nitro-vpa-address", "", "nitro vpaAddress")
|
||||
command.PersistentFlags().String("nitro-ca-address", "", "nitro caAddress")
|
||||
command.PersistentFlags().Bool("nitro-use-durable-store", false, "nitro useDurableStore")
|
||||
command.PersistentFlags().String("nitro-durable-store-folder", "", "nitro durableStoreFolder")
|
||||
command.PersistentFlags().Int("nitro-msg-port", 3005, "nitro msgPort")
|
||||
command.PersistentFlags().Int("nitro-rpc-port", 4005, "nitro rpcPort")
|
||||
command.PersistentFlags().Int("nitro-ws-msg-port", 5005, "nitro wsMsgPort")
|
||||
command.PersistentFlags().Uint("nitro-chain-start-block", 0, "nitro chainStartBlock")
|
||||
command.PersistentFlags().String("nitro-tls-cert-filepath", "", "nitro tlsCertFilepath")
|
||||
command.PersistentFlags().String("nitro-tls-key-filepath", "", "nitro tlsKeyFilepath")
|
||||
|
||||
command.PersistentFlags().String("nitro-endpoint", "", "nitro endpoint")
|
||||
command.PersistentFlags().Bool("nitro-is-secure", false, "nitro isSecure")
|
||||
|
||||
// nitro flag bindings
|
||||
viper.BindPFlag("nitro.runNodeInProcess", command.PersistentFlags().Lookup("nitro-run-node-in-process"))
|
||||
viper.BindPFlag("nitro.rpcQueryRatesFile", command.PersistentFlags().Lookup("nitro-rpc-query-rates-file"))
|
||||
|
||||
viper.BindPFlag("nitro.inProcesssNode.pk", command.PersistentFlags().Lookup("nitro-pk"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.chainPk", command.PersistentFlags().Lookup("nitro-chain-pk"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.chainUrl", command.PersistentFlags().Lookup("nitro-chain-url"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.naAddress", command.PersistentFlags().Lookup("nitro-na-address"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.vpaAddress", command.PersistentFlags().Lookup("nitro-vpa-address"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.caAddress", command.PersistentFlags().Lookup("nitro-ca-address"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.useDurableStore", command.PersistentFlags().Lookup("nitro-use-durable-store"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.durableStoreFolder", command.PersistentFlags().Lookup("nitro-durable-store"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.msgPort", command.PersistentFlags().Lookup("nitro-msg-port"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.rpcPort", command.PersistentFlags().Lookup("nitro-rpc-port"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.wsMsgPort", command.PersistentFlags().Lookup("nitro-ws-msg-port"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.chainStartBlock", command.PersistentFlags().Lookup("nitro-chain-start-block"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.tlsCertFilepath", command.PersistentFlags().Lookup("nitro-tls-cert-filepath"))
|
||||
viper.BindPFlag("nitro.inProcesssNode.tlsKeyFilepath", command.PersistentFlags().Lookup("nitro-tls-key-filepath"))
|
||||
|
||||
viper.BindPFlag("nitro.remoteNode.nitroEndpoint", command.PersistentFlags().Lookup("nitro-endpoint"))
|
||||
viper.BindPFlag("nitro.remoteNode.isSecure", command.PersistentFlags().Lookup("nitro-is-secure"))
|
||||
}
|
||||
|
||||
+213
-5
@@ -16,7 +16,12 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -26,15 +31,26 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/log"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/mailgun/groupcache/v2"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/statechannels/go-nitro/node/engine"
|
||||
"github.com/statechannels/go-nitro/node/engine/chainservice"
|
||||
nitroStore "github.com/statechannels/go-nitro/node/engine/store"
|
||||
"github.com/statechannels/go-nitro/paymentsmanager"
|
||||
"github.com/statechannels/go-nitro/rpc/transport"
|
||||
"golang.org/x/exp/slog"
|
||||
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/graphql"
|
||||
srpc "github.com/cerc-io/ipld-eth-server/v5/pkg/rpc"
|
||||
s "github.com/cerc-io/ipld-eth-server/v5/pkg/serve"
|
||||
v "github.com/cerc-io/ipld-eth-server/v5/version"
|
||||
nitroNode "github.com/statechannels/go-nitro/node"
|
||||
nitrop2pms "github.com/statechannels/go-nitro/node/engine/messageservice/p2p-message-service"
|
||||
nitroRpc "github.com/statechannels/go-nitro/rpc"
|
||||
nitroHttpTransport "github.com/statechannels/go-nitro/rpc/transport/http"
|
||||
)
|
||||
|
||||
var ErrNoRpcEndpoints = errors.New("no rpc endpoints is available")
|
||||
@@ -55,11 +71,13 @@ func serve() {
|
||||
logWithCommand.Infof("ipld-eth-server version: %s", v.VersionWithMeta)
|
||||
|
||||
wg := new(sync.WaitGroup)
|
||||
defer wg.Wait()
|
||||
|
||||
serverConfig, err := s.NewConfig()
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
logWithCommand.Debug("server config: %+v", serverConfig)
|
||||
logWithCommand.Debugf("server config: %+v", serverConfig)
|
||||
server, err := s.NewServer(serverConfig)
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
@@ -75,7 +93,41 @@ func serve() {
|
||||
}
|
||||
|
||||
server.Serve(wg)
|
||||
if err := startServers(server, serverConfig); err != nil {
|
||||
|
||||
var voucherValidator paymentsmanager.VoucherValidator
|
||||
|
||||
nitroConfig := serverConfig.Nitro
|
||||
if nitroConfig.RunNodeInProcess {
|
||||
log.Info("Running an in-process Nitro node")
|
||||
|
||||
pm, nitroRpcServer := initNitroInProcess(wg, nitroConfig)
|
||||
defer pm.Stop()
|
||||
defer nitroRpcServer.Close()
|
||||
|
||||
voucherValidator = paymentsmanager.InProcessVoucherValidator{PaymentsManager: *pm}
|
||||
} else {
|
||||
log.Info("Connecting to a remote Nitro node")
|
||||
|
||||
isSecure := nitroConfig.RemoteNode.IsSecure
|
||||
nitroRpcClient, err := nitroRpc.NewHttpRpcClient(nitroConfig.RemoteNode.NitroEndpoint, isSecure)
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
defer nitroRpcClient.Close()
|
||||
|
||||
voucherValidator = nitroRpc.RemoteVoucherValidator{Client: nitroRpcClient}
|
||||
}
|
||||
|
||||
queryRates, err := readRpcQueryRates(nitroConfig.RpcQueryRatesFile)
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
|
||||
paymentMiddleware := func(next http.Handler) http.Handler {
|
||||
return paymentsmanager.HTTPMiddleware(next, voucherValidator, queryRates)
|
||||
}
|
||||
|
||||
if err := startServers(server, serverConfig, [](func(next http.Handler) http.Handler){paymentMiddleware}); err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
graphQL, err := startEthGraphQL(server, serverConfig)
|
||||
@@ -102,10 +154,9 @@ func serve() {
|
||||
graphQL.Stop()
|
||||
}
|
||||
server.Stop()
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func startServers(server s.Server, settings *s.Config) error {
|
||||
func startServers(server s.Server, settings *s.Config, httpMiddlewares [](func(next http.Handler) http.Handler)) error {
|
||||
if settings.IPCEnabled {
|
||||
logWithCommand.Debug("starting up IPC server")
|
||||
_, _, err := srpc.StartIPCEndpoint(settings.IPCEndpoint, server.APIs())
|
||||
@@ -128,7 +179,7 @@ func startServers(server s.Server, settings *s.Config) error {
|
||||
|
||||
if settings.HTTPEnabled {
|
||||
logWithCommand.Debug("starting up HTTP server")
|
||||
_, err := srpc.StartHTTPEndpoint(settings.HTTPEndpoint, server.APIs(), []string{"vdb", "eth", "debug", "net"}, nil, []string{"*"}, rpc.HTTPTimeouts{})
|
||||
_, err := srpc.StartHTTPEndpoint(settings.HTTPEndpoint, server.APIs(), []string{"vdb", "eth", "debug", "net"}, nil, []string{"*"}, rpc.HTTPTimeouts{}, httpMiddlewares)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -260,6 +311,8 @@ func init() {
|
||||
|
||||
addDatabaseFlags(serveCmd)
|
||||
|
||||
addNitroFlags(serveCmd)
|
||||
|
||||
// flags for all config variables
|
||||
// eth graphql and json-rpc parameters
|
||||
serveCmd.PersistentFlags().Bool("server-graphql", false, "turn on the eth graphql server")
|
||||
@@ -339,3 +392,158 @@ func init() {
|
||||
viper.BindPFlag("validator.enabled", serveCmd.PersistentFlags().Lookup("validator-enabled"))
|
||||
viper.BindPFlag("validator.everyNthBlock", serveCmd.PersistentFlags().Lookup("validator-every-nth-block"))
|
||||
}
|
||||
|
||||
// Initializes an in-process Nitro node, payments manager and a Nitro RPC server
|
||||
func initNitroInProcess(wg *sync.WaitGroup, nitroConfig *s.NitroConfig) (*paymentsmanager.PaymentsManager, *nitroRpc.RpcServer) {
|
||||
nitroNode, err := initNitroNode(&nitroConfig.InProcessNode)
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
|
||||
pm, err := paymentsmanager.NewPaymentsManager(nitroNode)
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
pm.Start(wg)
|
||||
|
||||
tlsCertFilepath := nitroConfig.InProcessNode.TlsCertFilepath
|
||||
tlsKeyFilepath := nitroConfig.InProcessNode.TlsKeyFilepath
|
||||
|
||||
var cert *tls.Certificate
|
||||
if tlsCertFilepath != "" && tlsKeyFilepath != "" {
|
||||
*cert, err = tls.LoadX509KeyPair(tlsCertFilepath, tlsKeyFilepath)
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
nitroRpcServer, err := initNitroRpcServer(nitroNode, pm, cert, nitroConfig.InProcessNode.RpcPort)
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
|
||||
return &pm, nitroRpcServer
|
||||
}
|
||||
|
||||
// https://github.com/cerc-io/go-nitro/blob/release-v0.1.1-ts-port-0.1.7/internal/node/node.go#L17
|
||||
func initNitroNode(config *s.InProcessNitroNodeConfig) (*nitroNode.Node, error) {
|
||||
pkString := config.Pk
|
||||
useDurableStore := config.UseDurableStore
|
||||
durableStoreFolder := config.DurableStoreFolder
|
||||
msgPort := config.MsgPort
|
||||
wsMsgPort := config.WsMsgPort
|
||||
chainUrl := config.ChainUrl
|
||||
chainStartBlock := config.ChainStartBlock
|
||||
chainPk := config.ChainPk
|
||||
naAddress := config.NaAddress
|
||||
vpaAddress := config.VpaAddress
|
||||
caAddress := config.CaAddress
|
||||
|
||||
chainAuthToken := ""
|
||||
publicIp := "0.0.0.0"
|
||||
|
||||
chainOpts := chainservice.ChainOpts{
|
||||
ChainUrl: chainUrl,
|
||||
ChainStartBlock: chainStartBlock,
|
||||
ChainAuthToken: chainAuthToken,
|
||||
ChainPk: chainPk,
|
||||
NaAddress: common.HexToAddress(naAddress),
|
||||
VpaAddress: common.HexToAddress(vpaAddress),
|
||||
CaAddress: common.HexToAddress(caAddress),
|
||||
}
|
||||
|
||||
storeOpts := nitroStore.StoreOpts{
|
||||
PkBytes: common.Hex2Bytes(pkString),
|
||||
UseDurableStore: useDurableStore,
|
||||
DurableStoreFolder: durableStoreFolder,
|
||||
}
|
||||
|
||||
bootPeers := []string{}
|
||||
messageOpts := nitrop2pms.MessageOpts{
|
||||
PkBytes: common.Hex2Bytes(pkString),
|
||||
TcpPort: msgPort,
|
||||
WsMsgPort: wsMsgPort,
|
||||
BootPeers: bootPeers,
|
||||
PublicIp: publicIp,
|
||||
}
|
||||
|
||||
ourStore, err := nitroStore.NewStore(storeOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Info("Initializing message service...", " tcp port=", msgPort, " web socket port=", wsMsgPort)
|
||||
messageService := nitrop2pms.NewMessageService(messageOpts)
|
||||
|
||||
// Compare chainOpts.ChainStartBlock to lastBlockNum seen in store. The larger of the two
|
||||
// gets passed as an argument when creating NewEthChainService
|
||||
storeBlockNum, err := ourStore.GetLastBlockNumSeen()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if storeBlockNum > chainOpts.ChainStartBlock {
|
||||
chainOpts.ChainStartBlock = storeBlockNum
|
||||
}
|
||||
|
||||
log.Info("Initializing chain service...")
|
||||
ourChain, err := chainservice.NewEthChainService(chainOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
node := nitroNode.New(
|
||||
messageService,
|
||||
ourChain,
|
||||
ourStore,
|
||||
&engine.PermissivePolicy{},
|
||||
)
|
||||
|
||||
return &node, nil
|
||||
}
|
||||
|
||||
func initNitroRpcServer(node *nitroNode.Node, pm paymentsmanager.PaymentsManager, cert *tls.Certificate, rpcPort int) (*nitroRpc.RpcServer, error) {
|
||||
var transport transport.Responder
|
||||
var err error
|
||||
|
||||
slog.Info("Initializing Nitro HTTP RPC transport...")
|
||||
transport, err = nitroHttpTransport.NewHttpTransportAsServer(fmt.Sprint(rpcPort), cert)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rpcServer, err := nitroRpc.NewRpcServer(node, pm, transport)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
slog.Info("Completed Nitro RPC server initialization")
|
||||
return rpcServer, nil
|
||||
}
|
||||
|
||||
func readRpcQueryRates(filepath string) (map[string]*big.Int, error) {
|
||||
result := make(map[string]*big.Int)
|
||||
|
||||
if filepath == "" {
|
||||
logWithCommand.Warn("RPC query rates file path not provided")
|
||||
return result, nil
|
||||
}
|
||||
|
||||
jsonFile, err := os.Open(filepath)
|
||||
defer jsonFile.Close()
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
logWithCommand.Warn("RPC query rates file does not exist")
|
||||
return result, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
decoder := json.NewDecoder(jsonFile)
|
||||
err = decoder.Decode(&result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
password = "" # $DATABASE_PASSWORD
|
||||
|
||||
[log]
|
||||
level = "info" # $LOGRUS_LEVEL
|
||||
level = "info" # $LOG_LEVEL
|
||||
|
||||
[server]
|
||||
ipc = false
|
||||
@@ -31,3 +31,27 @@
|
||||
clientName = "Geth" # $ETH_CLIENT_NAME
|
||||
genesisBlock = "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" # $ETH_GENESIS_BLOCK
|
||||
networkID = "1" # $ETH_NETWORK_ID
|
||||
|
||||
[nitro]
|
||||
runNodeInProcess = false # NITRO_RUN_NODE_IN_PROCESS
|
||||
rpcQueryRatesFile = "environments/rpcQueryRates.json" # NITRO_RPC_QUERY_RATES_FILE
|
||||
|
||||
[nitro.inProcesssNode]
|
||||
pk = "" # NITRO_PK
|
||||
chainPk = "" # NITRO_CHAIN_PK
|
||||
chainUrl = "ws://127.0.0.1:8545" # NITRO_CHAIN_URL
|
||||
naAddress = "" # NITRO_NA_ADDRESS
|
||||
vpaAddress = "" # NITRO_VPA_ADDRESS
|
||||
caAddress = "" # NITRO_CA_ADDRESS
|
||||
useDurableStore = true # NITRO_USE_DURABLE_STORE
|
||||
durableStoreFolder = "./data/nitronode" # NITRO_DURABLE_STORE_FOLDER
|
||||
msgPort = 3005 # NITRO_MSG_PORT
|
||||
rpcPort = 4005 # NITRO_RPC_PORT
|
||||
wsMsgPort = 5005 # NITRO_WS_MSG_PORT
|
||||
chainStartBlock = 0 # NITRO_CHAIN_START_BLOCK
|
||||
tlsCertFilepath = "" # NITRO_TLS_CERT_FILEPATH
|
||||
tlsKeyFilepath = "" # NITRO_TLS_KEY_FILEPATH
|
||||
|
||||
[nitro.remoteNode]
|
||||
nitroEndpoint = "127.0.0.1:4005/api/v1" # NITRO_ENDPOINT
|
||||
isSecure = false # NITRO_IS_SECURE
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"eth_getBlockByNumber": 50,
|
||||
"eth_getBlockByHash": 50,
|
||||
"eth_getStorageAt": 50,
|
||||
"eth_getLogs": 50
|
||||
}
|
||||
@@ -1,70 +1,76 @@
|
||||
module github.com/cerc-io/ipld-eth-server/v5
|
||||
|
||||
go 1.19
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/cerc-io/eth-ipfs-state-validator/v5 v5.0.0-alpha
|
||||
github.com/cerc-io/eth-iterator-utils v0.1.1
|
||||
github.com/cerc-io/ipfs-ethdb/v5 v5.0.0-alpha
|
||||
github.com/cerc-io/ipld-eth-statedb v0.0.5-alpha
|
||||
github.com/ethereum/go-ethereum v1.11.6
|
||||
github.com/cerc-io/plugeth-statediff v0.1.1
|
||||
github.com/ethereum/go-ethereum v1.12.0 // TODO: Investigate
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/graph-gophers/graphql-go v1.3.0
|
||||
github.com/ipfs/go-cid v0.3.2
|
||||
github.com/ipfs/go-cid v0.4.1
|
||||
github.com/jmoiron/sqlx v1.3.5
|
||||
github.com/joho/godotenv v1.4.0
|
||||
github.com/lib/pq v1.10.7
|
||||
github.com/lib/pq v1.10.9
|
||||
github.com/machinebox/graphql v0.2.2
|
||||
github.com/mailgun/groupcache/v2 v2.3.0
|
||||
github.com/onsi/ginkgo/v2 v2.9.2
|
||||
github.com/onsi/gomega v1.27.4
|
||||
github.com/prometheus/client_golang v1.14.0
|
||||
github.com/onsi/ginkgo/v2 v2.11.0
|
||||
github.com/onsi/gomega v1.27.8
|
||||
github.com/prometheus/client_golang v1.16.0
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/spf13/cobra v1.4.0
|
||||
github.com/spf13/viper v1.11.0
|
||||
github.com/statechannels/go-nitro v0.1.2
|
||||
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
|
||||
gorm.io/driver/postgres v1.3.7
|
||||
gorm.io/gorm v1.23.5
|
||||
)
|
||||
|
||||
require (
|
||||
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc // indirect
|
||||
github.com/DataDog/zstd v1.5.2 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect
|
||||
github.com/benbjohnson/clock v1.3.0 // indirect
|
||||
github.com/DataDog/zstd v1.5.5 // indirect
|
||||
github.com/Jorropo/jsync v1.0.1 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
|
||||
github.com/benbjohnson/clock v1.3.5 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/cockroachdb/errors v1.9.1 // indirect
|
||||
github.com/cockroachdb/errors v1.10.0 // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
||||
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 // indirect
|
||||
github.com/cockroachdb/redact v1.1.3 // indirect
|
||||
github.com/containerd/cgroups v1.0.4 // indirect
|
||||
github.com/cockroachdb/pebble v0.0.0-20230720154706-692f3b61a3c4 // indirect
|
||||
github.com/cockroachdb/redact v1.1.5 // indirect
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6 // indirect
|
||||
github.com/containerd/cgroups v1.1.0 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||
github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect
|
||||
github.com/cskr/pubsub v1.0.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
|
||||
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
|
||||
github.com/deckarep/golang-set/v2 v2.3.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
|
||||
github.com/deepmap/oapi-codegen v1.8.2 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/edsrzf/mmap-go v1.0.0 // indirect
|
||||
github.com/elastic/gosigar v0.14.2 // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
|
||||
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
|
||||
github.com/fjl/memsize v0.0.1 // indirect
|
||||
github.com/flynn/noise v1.0.0 // indirect
|
||||
github.com/francoispqt/gojay v1.2.13 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.1 // indirect
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
|
||||
github.com/georgysavva/scany v0.2.9 // indirect
|
||||
github.com/getsentry/sentry-go v0.18.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/getsentry/sentry-go v0.22.0 // indirect
|
||||
github.com/go-logr/logr v1.2.4 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-stack/stack v1.8.1 // indirect
|
||||
@@ -72,75 +78,57 @@ require (
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/gofrs/flock v0.8.1 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/gopacket v1.1.19 // indirect
|
||||
github.com/google/pprof v0.0.0-20221203041831-ce31453925ec // indirect
|
||||
github.com/gorilla/mux v1.8.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-bexpr v0.1.10 // indirect
|
||||
github.com/hashicorp/go-bexpr v0.1.12 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect
|
||||
github.com/huin/goupnp v1.0.3 // indirect
|
||||
github.com/holiman/uint256 v1.2.3 // indirect
|
||||
github.com/huin/goupnp v1.2.0 // indirect
|
||||
github.com/inconshreveable/log15 v2.16.0+incompatible // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c // indirect
|
||||
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
|
||||
github.com/ipfs/bbloom v0.0.4 // indirect
|
||||
github.com/ipfs/go-bitfield v1.0.0 // indirect
|
||||
github.com/ipfs/go-bitswap v0.11.0 // indirect
|
||||
github.com/ipfs/go-block-format v0.0.3 // indirect
|
||||
github.com/ipfs/go-blockservice v0.5.0 // indirect
|
||||
github.com/ipfs/boxo v0.13.1 // indirect
|
||||
github.com/ipfs/go-bitfield v1.1.0 // indirect
|
||||
github.com/ipfs/go-block-format v0.1.2 // indirect
|
||||
github.com/ipfs/go-cidutil v0.1.0 // indirect
|
||||
github.com/ipfs/go-datastore v0.6.0 // indirect
|
||||
github.com/ipfs/go-delegated-routing v0.7.0 // indirect
|
||||
github.com/ipfs/go-ds-measure v0.2.0 // indirect
|
||||
github.com/ipfs/go-fetcher v1.6.1 // indirect
|
||||
github.com/ipfs/go-filestore v1.2.0 // indirect
|
||||
github.com/ipfs/go-fs-lock v0.0.7 // indirect
|
||||
github.com/ipfs/go-graphsync v0.14.1 // indirect
|
||||
github.com/ipfs/go-ipfs-blockstore v1.2.0 // indirect
|
||||
github.com/ipfs/go-ipfs-chunker v0.0.5 // indirect
|
||||
github.com/ipfs/go-graphsync v0.15.1 // indirect
|
||||
github.com/ipfs/go-ipfs-blockstore v1.3.0 // indirect
|
||||
github.com/ipfs/go-ipfs-delay v0.0.1 // indirect
|
||||
github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect
|
||||
github.com/ipfs/go-ipfs-exchange-interface v0.2.0 // indirect
|
||||
github.com/ipfs/go-ipfs-exchange-offline v0.3.0 // indirect
|
||||
github.com/ipfs/go-ipfs-keystore v0.1.0 // indirect
|
||||
github.com/ipfs/go-ipfs-pinner v0.2.1 // indirect
|
||||
github.com/ipfs/go-ipfs-posinfo v0.0.1 // indirect
|
||||
github.com/ipfs/go-ipfs-pq v0.0.2 // indirect
|
||||
github.com/ipfs/go-ipfs-provider v0.8.1 // indirect
|
||||
github.com/ipfs/go-ipfs-routing v0.3.0 // indirect
|
||||
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
|
||||
github.com/ipfs/go-ipfs-pq v0.0.3 // indirect
|
||||
github.com/ipfs/go-ipfs-redirects-file v0.1.1 // indirect
|
||||
github.com/ipfs/go-ipfs-util v0.0.3 // indirect
|
||||
github.com/ipfs/go-ipld-cbor v0.0.6 // indirect
|
||||
github.com/ipfs/go-ipld-format v0.4.0 // indirect
|
||||
github.com/ipfs/go-ipld-legacy v0.1.1 // indirect
|
||||
github.com/ipfs/go-ipns v0.3.0 // indirect
|
||||
github.com/ipfs/go-libipfs v0.2.0 // indirect
|
||||
github.com/ipfs/go-ipld-format v0.5.0 // indirect
|
||||
github.com/ipfs/go-ipld-legacy v0.2.1 // indirect
|
||||
github.com/ipfs/go-log v1.0.5 // indirect
|
||||
github.com/ipfs/go-log/v2 v2.5.1 // indirect
|
||||
github.com/ipfs/go-merkledag v0.9.0 // indirect
|
||||
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
|
||||
github.com/ipfs/go-mfs v0.2.1 // indirect
|
||||
github.com/ipfs/go-namesys v0.6.0 // indirect
|
||||
github.com/ipfs/go-path v0.3.0 // indirect
|
||||
github.com/ipfs/go-peertaskqueue v0.8.0 // indirect
|
||||
github.com/ipfs/go-unixfs v0.4.2 // indirect
|
||||
github.com/ipfs/go-unixfsnode v1.5.1 // indirect
|
||||
github.com/ipfs/go-verifcid v0.0.2 // indirect
|
||||
github.com/ipfs/interface-go-ipfs-core v0.8.2 // indirect
|
||||
github.com/ipfs/kubo v0.18.1 // indirect
|
||||
github.com/ipld/edelweiss v0.2.0 // indirect
|
||||
github.com/ipld/go-codec-dagpb v1.5.0 // indirect
|
||||
github.com/ipld/go-ipld-prime v0.19.0 // indirect
|
||||
github.com/ipfs/go-peertaskqueue v0.8.1 // indirect
|
||||
github.com/ipfs/go-unixfsnode v1.8.1 // indirect
|
||||
github.com/ipfs/kubo v0.23.0 // indirect
|
||||
github.com/ipld/go-car/v2 v2.10.2-0.20230622090957-499d0c909d33 // indirect
|
||||
github.com/ipld/go-codec-dagpb v1.6.0 // indirect
|
||||
github.com/ipld/go-ipld-prime v0.21.0 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgconn v1.14.0 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
@@ -155,86 +143,85 @@ require (
|
||||
github.com/jbenet/goprocess v0.1.4 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.4 // indirect
|
||||
github.com/klauspost/compress v1.15.15 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.1 // indirect
|
||||
github.com/koron/go-ssdp v0.0.3 // indirect
|
||||
github.com/klauspost/compress v1.16.7 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
||||
github.com/koron/go-ssdp v0.0.4 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
||||
github.com/libp2p/go-cidranger v1.1.0 // indirect
|
||||
github.com/libp2p/go-doh-resolver v0.4.0 // indirect
|
||||
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
|
||||
github.com/libp2p/go-libp2p v0.24.2 // indirect
|
||||
github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect
|
||||
github.com/libp2p/go-libp2p-kad-dht v0.20.0 // indirect
|
||||
github.com/libp2p/go-libp2p-kbucket v0.5.0 // indirect
|
||||
github.com/libp2p/go-libp2p-pubsub v0.8.3 // indirect
|
||||
github.com/libp2p/go-libp2p v0.31.0 // indirect
|
||||
github.com/libp2p/go-libp2p-asn-util v0.3.0 // indirect
|
||||
github.com/libp2p/go-libp2p-kad-dht v0.24.4 // indirect
|
||||
github.com/libp2p/go-libp2p-kbucket v0.6.3 // indirect
|
||||
github.com/libp2p/go-libp2p-pubsub v0.9.3 // indirect
|
||||
github.com/libp2p/go-libp2p-pubsub-router v0.6.0 // indirect
|
||||
github.com/libp2p/go-libp2p-record v0.2.0 // indirect
|
||||
github.com/libp2p/go-libp2p-routing-helpers v0.6.0 // indirect
|
||||
github.com/libp2p/go-libp2p-routing-helpers v0.7.3 // indirect
|
||||
github.com/libp2p/go-libp2p-xor v0.1.0 // indirect
|
||||
github.com/libp2p/go-mplex v0.7.0 // indirect
|
||||
github.com/libp2p/go-msgio v0.2.0 // indirect
|
||||
github.com/libp2p/go-nat v0.1.0 // indirect
|
||||
github.com/libp2p/go-msgio v0.3.0 // indirect
|
||||
github.com/libp2p/go-nat v0.2.0 // indirect
|
||||
github.com/libp2p/go-netroute v0.2.1 // indirect
|
||||
github.com/libp2p/go-openssl v0.1.0 // indirect
|
||||
github.com/libp2p/go-reuseport v0.2.0 // indirect
|
||||
github.com/libp2p/go-yamux/v4 v4.0.0 // indirect
|
||||
github.com/libp2p/go-reuseport v0.4.0 // indirect
|
||||
github.com/libp2p/go-yamux/v4 v4.0.1 // indirect
|
||||
github.com/libp2p/zeroconf/v2 v2.2.0 // indirect
|
||||
github.com/lucas-clemente/quic-go v0.31.1 // indirect
|
||||
github.com/magiconair/properties v1.8.6 // indirect
|
||||
github.com/marten-seemann/qpack v0.3.0 // indirect
|
||||
github.com/marten-seemann/qtls-go1-18 v0.1.3 // indirect
|
||||
github.com/marten-seemann/qtls-go1-19 v0.1.1 // indirect
|
||||
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
|
||||
github.com/marten-seemann/webtransport-go v0.4.3 // indirect
|
||||
github.com/matryer/is v1.4.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/mattn/go-pointer v0.0.1 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/miekg/dns v1.1.50 // indirect
|
||||
github.com/miekg/dns v1.1.55 // indirect
|
||||
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
|
||||
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
|
||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||
github.com/minio/sha256-simd v1.0.1 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
||||
github.com/mitchellh/pointerstructure v1.2.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mitchellh/pointerstructure v1.2.1 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/multiformats/go-base32 v0.1.0 // indirect
|
||||
github.com/multiformats/go-base36 v0.2.0 // indirect
|
||||
github.com/multiformats/go-multiaddr v0.8.0 // indirect
|
||||
github.com/multiformats/go-multiaddr v0.11.0 // indirect
|
||||
github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect
|
||||
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
|
||||
github.com/multiformats/go-multibase v0.1.1 // indirect
|
||||
github.com/multiformats/go-multicodec v0.7.0 // indirect
|
||||
github.com/multiformats/go-multihash v0.2.1 // indirect
|
||||
github.com/multiformats/go-multistream v0.3.3 // indirect
|
||||
github.com/multiformats/go-multibase v0.2.0 // indirect
|
||||
github.com/multiformats/go-multicodec v0.9.0 // indirect
|
||||
github.com/multiformats/go-multihash v0.2.3 // indirect
|
||||
github.com/multiformats/go-multistream v0.4.1 // indirect
|
||||
github.com/multiformats/go-varint v0.0.7 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/opencontainers/runtime-spec v1.0.2 // indirect
|
||||
github.com/opencontainers/runtime-spec v1.1.0 // indirect
|
||||
github.com/openrelayxyz/plugeth-utils v1.2.0 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
|
||||
github.com/pelletier/go-toml v1.9.4 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
||||
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 // indirect
|
||||
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 // indirect
|
||||
github.com/pganalyze/pg_query_go/v2 v2.1.0 // indirect
|
||||
github.com/pganalyze/pg_query_go/v4 v4.2.1 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect
|
||||
github.com/prometheus/client_model v0.3.0 // indirect
|
||||
github.com/prometheus/common v0.39.0 // indirect
|
||||
github.com/prometheus/procfs v0.9.0 // indirect
|
||||
github.com/polydawn/refmt v0.89.0 // indirect
|
||||
github.com/prometheus/client_model v0.4.0 // indirect
|
||||
github.com/prometheus/common v0.44.0 // indirect
|
||||
github.com/prometheus/procfs v0.11.1 // indirect
|
||||
github.com/quic-go/qpack v0.4.0 // indirect
|
||||
github.com/quic-go/qtls-go1-20 v0.3.3 // indirect
|
||||
github.com/quic-go/quic-go v0.38.1 // indirect
|
||||
github.com/quic-go/webtransport-go v0.5.3 // indirect
|
||||
github.com/raulk/go-watchdog v1.3.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
||||
github.com/rs/cors v1.7.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
||||
github.com/rs/cors v1.9.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/samber/lo v1.36.0 // indirect
|
||||
github.com/segmentio/fasthash v1.0.3 // indirect
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
|
||||
github.com/shopspring/decimal v1.2.0 // indirect
|
||||
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/spf13/afero v1.8.2 // indirect
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
@@ -242,47 +229,77 @@ require (
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/status-im/keycard-go v0.2.0 // indirect
|
||||
github.com/stretchr/objx v0.5.0 // indirect
|
||||
github.com/stretchr/testify v1.8.1 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
|
||||
github.com/thoas/go-funk v0.9.2 // indirect
|
||||
github.com/thoas/go-funk v0.9.3 // indirect
|
||||
github.com/tidwall/btree v1.6.0 // indirect
|
||||
github.com/tidwall/buntdb v1.2.10 // indirect
|
||||
github.com/tidwall/gjson v1.14.4 // indirect
|
||||
github.com/tidwall/grect v0.1.4 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/tidwall/rtred v0.1.2 // indirect
|
||||
github.com/tidwall/tinyqueue v0.1.1 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.11 // indirect
|
||||
github.com/tklauser/numcpus v0.6.0 // indirect
|
||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
|
||||
github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa // indirect
|
||||
github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb // indirect
|
||||
github.com/urfave/cli/v2 v2.25.7 // indirect
|
||||
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20221220214510-0333c149dec0 // indirect
|
||||
github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa // indirect
|
||||
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
|
||||
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
|
||||
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/otel v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.7.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/dig v1.15.0 // indirect
|
||||
go.uber.org/fx v1.18.2 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
|
||||
golang.org/x/crypto v0.6.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
|
||||
golang.org/x/mod v0.9.0 // indirect
|
||||
golang.org/x/net v0.8.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.8.0 // indirect
|
||||
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
|
||||
golang.org/x/tools v0.7.0 // indirect
|
||||
go.opentelemetry.io/otel v1.16.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.16.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.16.0 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/dig v1.17.0 // indirect
|
||||
go.uber.org/fx v1.20.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.25.0 // indirect
|
||||
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
|
||||
golang.org/x/crypto v0.12.0 // indirect
|
||||
golang.org/x/mod v0.12.0 // indirect
|
||||
golang.org/x/net v0.14.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.11.0 // indirect
|
||||
golang.org/x/term v0.11.0 // indirect
|
||||
golang.org/x/text v0.12.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gonum.org/v1/gonum v0.13.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
lukechampine.com/blake3 v1.1.7 // indirect
|
||||
lukechampine.com/blake3 v1.2.1 // indirect
|
||||
)
|
||||
|
||||
replace github.com/ethereum/go-ethereum v1.11.6 => github.com/cerc-io/go-ethereum v1.11.6-statediff-5.0.8
|
||||
replace (
|
||||
// github.com/cerc-io/eth-ipfs-state-validator/v5 => git.vdb.to/cerc-io/eth-ipfs-state-validator/v5 v5.1.1-alpha
|
||||
github.com/cerc-io/eth-iterator-utils => git.vdb.to/cerc-io/eth-iterator-utils v0.1.2
|
||||
github.com/cerc-io/eth-testing => git.vdb.to/cerc-io/eth-testing v0.3.1
|
||||
github.com/cerc-io/ipld-eth-statedb => git.vdb.to/cerc-io/ipld-eth-statedb v0.0.6-alpha
|
||||
github.com/cerc-io/plugeth-statediff => git.vdb.to/cerc-io/plugeth-statediff v0.1.4
|
||||
github.com/ethereum/go-ethereum => git.vdb.to/cerc-io/plugeth v0.0.0-20230808125822-691dc334fab1
|
||||
github.com/openrelayxyz/plugeth-utils => git.vdb.to/cerc-io/plugeth-utils v0.0.0-20230706160122-cd41de354c46
|
||||
)
|
||||
|
||||
// TODO: Use releases after these branches get merged
|
||||
replace (
|
||||
// https://git.vdb.to/cerc-io/eth-ipfs-state-validator/src/branch/v5-go-upgrade
|
||||
github.com/cerc-io/eth-ipfs-state-validator/v5 => github.com/cerc-io/eth-ipfs-state-validator/v5 v5.1.1-alpha.0.20231013075659-56aa03028c43
|
||||
// https://git.vdb.to/cerc-io/ipfs-ethdb/src/branch/v5-go-upgrade
|
||||
github.com/cerc-io/ipfs-ethdb/v5 => github.com/cerc-io/ipfs-ethdb/v5 v5.0.1-alpha.0.20231013070931-0b1a36562a28
|
||||
)
|
||||
|
||||
replace github.com/statechannels/go-nitro v0.1.2 => github.com/cerc-io/go-nitro v0.1.2-ts-port-0.1.9
|
||||
|
||||
@@ -7,8 +7,6 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/statediff/types"
|
||||
)
|
||||
|
||||
type ContractDeployed struct {
|
||||
@@ -72,11 +70,3 @@ var (
|
||||
IncrementCount = MakeGetAndDecodeFunc[CountIncremented]("%s/v1/incrementCount%s?addr=%s")
|
||||
Create2Contract = MakeGetAndDecodeFunc[ContractDeployed]("%s/v1/create2Contract?contract=%s&salt=%s")
|
||||
)
|
||||
|
||||
func ClearWatchedAddresses(gethRPCClient *rpc.Client) error {
|
||||
gethMethod := "statediff_watchAddress"
|
||||
args := []types.WatchAddressArg{}
|
||||
|
||||
// Clear watched addresses
|
||||
return gethRPCClient.Call(nil, gethMethod, types.Clear, args)
|
||||
}
|
||||
|
||||
@@ -25,5 +25,4 @@ func waitForBlock(ctx context.Context, client *ethclient.Client, target int64) e
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
sdtypes "github.com/cerc-io/plugeth-statediff/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@@ -18,7 +18,7 @@ var (
|
||||
ipldMethod = "vdb_watchAddress"
|
||||
)
|
||||
|
||||
var _ = Describe("WatchAddress integration test", func() {
|
||||
var _ = Describe("WatchAddress integration test", Ordered, func() {
|
||||
var (
|
||||
ctx = context.Background()
|
||||
|
||||
@@ -52,7 +52,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
actualCountA3 *big.Int
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
BeforeAll(func() {
|
||||
var err error
|
||||
|
||||
gethRPCClient, err = rpc.Dial(gethHttpPath)
|
||||
@@ -60,9 +60,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
|
||||
ipldRPCClient, err = rpc.Dial(ipldEthHttpPath)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
It("test init", func() {
|
||||
// Deploy three contracts
|
||||
contract1, contractErr = integration.DeploySLVContract()
|
||||
Expect(contractErr).ToNot(HaveOccurred())
|
||||
@@ -79,7 +77,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
countAIndex = common.HexToHash(storageSlotAKey.Key)
|
||||
|
||||
// Clear out watched addresses
|
||||
err = integration.ClearWatchedAddresses(gethRPCClient)
|
||||
err = gethRPCClient.Call(nil, gethMethod, sdtypes.Clear, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// Get initial balances for all the contracts
|
||||
@@ -130,9 +128,9 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
prevCountA3 = big.NewInt(0)
|
||||
})
|
||||
|
||||
defer It("test cleanup", func() {
|
||||
AfterAll(func() {
|
||||
// Clear out watched addresses
|
||||
err := integration.ClearWatchedAddresses(gethRPCClient)
|
||||
err := gethRPCClient.Call(nil, gethMethod, sdtypes.Clear, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
@@ -144,6 +142,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, contract1.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -154,6 +153,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, contract2.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -164,6 +164,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, contract3.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -175,6 +176,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract1.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract1.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -186,6 +188,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract2.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract2.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -197,6 +200,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract3.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract3.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -224,6 +228,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, contract1.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -234,6 +239,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, contract2.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -243,6 +249,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, contract3.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -253,6 +260,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract1.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract1.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -264,6 +272,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract2.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract2.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -274,6 +283,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract3.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract3.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -300,6 +310,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, contract1.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -310,6 +321,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, contract2.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -320,6 +332,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, contract3.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -330,6 +343,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract1.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract1.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -341,6 +355,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract2.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract2.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -352,6 +367,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract3.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract3.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -378,6 +394,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, contract1.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -387,6 +404,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, contract2.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -397,6 +415,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, contract3.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -407,6 +426,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract1.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract1.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -417,6 +437,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract2.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract2.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -428,6 +449,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract3.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract3.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -458,6 +480,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, contract1.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -468,6 +491,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, contract2.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -477,6 +501,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, contract3.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -488,6 +513,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract1.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract1.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -499,6 +525,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract2.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract2.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -509,6 +536,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract3.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract3.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -531,6 +559,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, contract1.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -541,6 +570,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, contract2.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -551,6 +581,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
tx, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||
Expect(txErr).ToNot(HaveOccurred())
|
||||
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||
waitForBlock(ctx, ipldClient, tx.BlockNumber)
|
||||
|
||||
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, contract3.Address, big.NewInt(tx.BlockNumber))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -562,6 +593,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract1.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract1.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -573,6 +605,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract2.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract2.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -584,6 +617,7 @@ var _ = Describe("WatchAddress integration test", func() {
|
||||
inc, incErr = integration.IncrementCount("A", contract3.Address)
|
||||
Expect(incErr).ToNot(HaveOccurred())
|
||||
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||
waitForBlock(ctx, ipldClient, inc.BlockNumber.Int64())
|
||||
|
||||
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, contract3.Address, countAIndex, inc.BlockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
+1
-1
@@ -27,6 +27,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
@@ -38,7 +39,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/log"
|
||||
ipld_direct_state "github.com/cerc-io/ipld-eth-statedb/direct_by_leaf"
|
||||
|
||||
@@ -21,6 +21,9 @@ import (
|
||||
"math/big"
|
||||
"strconv"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/interfaces"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
|
||||
sdtypes "github.com/cerc-io/plugeth-statediff/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
@@ -29,9 +32,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/eth/filters"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/interfaces"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
|
||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||
"github.com/jmoiron/sqlx"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
@@ -219,6 +219,7 @@ var _ = BeforeSuite(func() {
|
||||
api, _ = eth.NewPublicEthAPI(backend, nil, eth.APIConfig{StateDiffTimeout: shared.DefaultStateDiffTimeout})
|
||||
tx, err = indexAndPublisher.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
ipld := sdtypes.IPLD{
|
||||
CID: ipld.Keccak256ToCid(ipld.RawBinary, test_helpers.CodeHash.Bytes()).String(),
|
||||
@@ -232,7 +233,7 @@ var _ = BeforeSuite(func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
uncles := test_helpers.MockBlock.Uncles()
|
||||
@@ -248,8 +249,9 @@ var _ = BeforeSuite(func() {
|
||||
|
||||
tx, err = indexAndPublisher.PushBlock(test_helpers.MockLondonBlock, test_helpers.MockLondonReceipts, test_helpers.MockLondonBlock.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
|
||||
+4
-3
@@ -25,6 +25,8 @@ import (
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
|
||||
"github.com/cerc-io/plugeth-statediff/utils"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
@@ -39,7 +41,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/jmoiron/sqlx"
|
||||
|
||||
@@ -962,7 +963,7 @@ func (b *Backend) getSliceStem(headPath []byte, t ipld_trie_state.Trie, response
|
||||
// nodePath := make([]byte, len(headPath[:i]))
|
||||
nodePath := headPath[:i]
|
||||
|
||||
rawNode, _, err := t.TryGetNode(trie.HexToCompact(nodePath))
|
||||
rawNode, _, err := t.TryGetNode(utils.HexToCompact(nodePath))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1004,7 +1005,7 @@ func (b *Backend) getSliceStem(headPath []byte, t ipld_trie_state.Trie, response
|
||||
func (b *Backend) getSliceHead(headPath []byte, t ipld_trie_state.Trie, response *GetSliceResponse, metaData *metaDataFields, storage bool) error {
|
||||
totalHeadStartTime := makeTimestamp()
|
||||
|
||||
rawNode, _, err := t.TryGetNode(trie.HexToCompact(headPath))
|
||||
rawNode, _, err := t.TryGetNode(utils.HexToCompact(headPath))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
nodeiter "github.com/cerc-io/eth-iterator-utils"
|
||||
"github.com/cerc-io/plugeth-statediff/utils"
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
@@ -32,7 +34,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
nodeiter "github.com/ethereum/go-ethereum/trie/concurrent_iterator"
|
||||
|
||||
"github.com/cerc-io/ipld-eth-statedb/trie_by_cid/state"
|
||||
)
|
||||
@@ -376,9 +377,9 @@ func extractContractAccountInfo(sdb state.Database, node StateNode, nodeElements
|
||||
}
|
||||
|
||||
// Extract state leaf key
|
||||
partialPath := trie.CompactToHex(nodeElements[0].([]byte))
|
||||
partialPath := utils.CompactToHex(nodeElements[0].([]byte))
|
||||
valueNodePath := append(node.Path, partialPath...)
|
||||
encodedPath := trie.HexToCompact(valueNodePath)
|
||||
encodedPath := utils.HexToCompact(valueNodePath)
|
||||
leafKey := encodedPath[1:]
|
||||
stateLeafKeyString := common.BytesToHash(leafKey).String()
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ import (
|
||||
"math/big"
|
||||
"strconv"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/models"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/lib/pq"
|
||||
"gorm.io/driver/postgres"
|
||||
|
||||
+19
-10
@@ -19,9 +19,9 @@ package eth_test
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/interfaces"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/interfaces"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/jmoiron/sqlx"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
@@ -53,12 +53,13 @@ var _ = Describe("Retriever", func() {
|
||||
It("Retrieve", func() {
|
||||
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
for _, node := range test_helpers.MockStateNodes {
|
||||
err = diffIndexer.PushStateNode(tx, node, test_helpers.MockBlock.Hash().String())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
@@ -70,8 +71,9 @@ var _ = Describe("Retriever", func() {
|
||||
It("Gets the number of the first block that has data in the database", func() {
|
||||
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
num, err := retriever.RetrieveFirstBlockNumber()
|
||||
@@ -84,8 +86,9 @@ var _ = Describe("Retriever", func() {
|
||||
payload.Block = newMockBlock(1010101)
|
||||
tx, err := diffIndexer.PushBlock(payload.Block, payload.Receipts, payload.Block.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
num, err := retriever.RetrieveFirstBlockNumber()
|
||||
@@ -100,12 +103,14 @@ var _ = Describe("Retriever", func() {
|
||||
payload2.Block = newMockBlock(5)
|
||||
tx, err := diffIndexer.PushBlock(payload1.Block, payload1.Receipts, payload1.Block.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = tx.Submit(err)
|
||||
defer tx.RollbackOnFailure(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
tx, err = diffIndexer.PushBlock(payload2.Block, payload2.Receipts, payload2.Block.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = tx.Submit(err)
|
||||
defer tx.RollbackOnFailure(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
num, err := retriever.RetrieveFirstBlockNumber()
|
||||
@@ -122,7 +127,8 @@ var _ = Describe("Retriever", func() {
|
||||
It("Gets the number of the latest block that has data in the database", func() {
|
||||
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = tx.Submit(err)
|
||||
defer tx.RollbackOnFailure(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
num, err := retriever.RetrieveLastBlockNumber()
|
||||
@@ -135,8 +141,9 @@ var _ = Describe("Retriever", func() {
|
||||
payload.Block = newMockBlock(1010101)
|
||||
tx, err := diffIndexer.PushBlock(payload.Block, payload.Receipts, payload.Block.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
num, err := retriever.RetrieveLastBlockNumber()
|
||||
@@ -151,12 +158,14 @@ var _ = Describe("Retriever", func() {
|
||||
payload2.Block = newMockBlock(5)
|
||||
tx, err := diffIndexer.PushBlock(payload1.Block, payload1.Receipts, payload1.Block.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = tx.Submit(err)
|
||||
defer tx.RollbackOnFailure(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
tx, err = diffIndexer.PushBlock(payload2.Block, payload2.Receipts, payload2.Block.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = tx.Submit(err)
|
||||
defer tx.RollbackOnFailure(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
num, err := retriever.RetrieveLastBlockNumber()
|
||||
|
||||
@@ -20,6 +20,11 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff"
|
||||
"github.com/cerc-io/plugeth-statediff/adapt"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
@@ -29,13 +34,9 @@ import (
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
"github.com/jmoiron/sqlx"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
// "github.com/ethereum/go-ethereum/statediff/test_helpers"
|
||||
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/eth"
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/eth/test_helpers"
|
||||
@@ -85,7 +86,7 @@ var (
|
||||
|
||||
func init() {
|
||||
// load abi
|
||||
abiBytes, err := ioutil.ReadFile("../test_helpers/abi.json")
|
||||
abiBytes, err := os.ReadFile("../test_helpers/abi.json")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -167,19 +168,21 @@ var _ = BeforeSuite(func() {
|
||||
|
||||
tx, err := indexAndPublisher.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// The non-canonical header has a child
|
||||
tx, err = indexAndPublisher.PushBlock(test_helpers.MockChild, test_helpers.MockReceipts, test_helpers.MockChild.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// iterate over the blocks, generating statediff payloads, and transforming the data into Postgres
|
||||
builder := statediff.NewBuilder(chain.StateCache())
|
||||
builder := statediff.NewBuilder(adapt.GethStateView(chain.StateCache()))
|
||||
for i, block := range blocks {
|
||||
var args statediff.Args
|
||||
var rcts types.Receipts
|
||||
@@ -203,6 +206,7 @@ var _ = BeforeSuite(func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
tx, err := transformer.PushBlock(block, rcts, mockTD)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
for _, node := range diff.Nodes {
|
||||
err = transformer.PushStateNode(tx, node, block.Hash().String())
|
||||
@@ -214,7 +218,7 @@ var _ = BeforeSuite(func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@ import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff"
|
||||
"github.com/cerc-io/plugeth-statediff/adapt"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/shared"
|
||||
)
|
||||
@@ -29,7 +30,7 @@ type IndexChainParams struct {
|
||||
|
||||
func IndexChain(params IndexChainParams) error {
|
||||
indexer := shared.SetupTestStateDiffIndexer(context.Background(), params.ChainConfig, Genesis.Hash())
|
||||
builder := statediff.NewBuilder(params.StateCache)
|
||||
builder := statediff.NewBuilder(adapt.GethStateView(params.StateCache))
|
||||
// iterate over the blocks, generating statediff payloads, and transforming the data into Postgres
|
||||
for i, block := range params.Blocks {
|
||||
var args statediff.Args
|
||||
@@ -59,6 +60,7 @@ func IndexChain(params IndexChainParams) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
if !params.SkipStateNodes {
|
||||
for _, node := range diff.Nodes {
|
||||
@@ -74,7 +76,7 @@ func IndexChain(params IndexChainParams) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
if err = tx.Submit(err); err != nil {
|
||||
if err = tx.Submit(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package test_helpers
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff/test_helpers"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
@@ -27,7 +28,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/statediff/test_helpers"
|
||||
)
|
||||
|
||||
// Test variables
|
||||
|
||||
@@ -22,14 +22,14 @@ import (
|
||||
"crypto/rand"
|
||||
"math/big"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/models"
|
||||
sdtypes "github.com/cerc-io/plugeth-statediff/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
|
||||
+2
-2
@@ -23,13 +23,13 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/log"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/models"
|
||||
sdtypes "github.com/cerc-io/plugeth-statediff/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/common/math"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||
)
|
||||
|
||||
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
|
||||
|
||||
+15
-10
@@ -19,6 +19,13 @@ package graphql_test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strconv"
|
||||
|
||||
statediff "github.com/cerc-io/plugeth-statediff"
|
||||
"github.com/cerc-io/plugeth-statediff/adapt"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/ipld"
|
||||
sdtypes "github.com/cerc-io/plugeth-statediff/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
@@ -27,14 +34,9 @@ import (
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
|
||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||
"github.com/jmoiron/sqlx"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"math/big"
|
||||
"strconv"
|
||||
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/eth"
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/eth/test_helpers"
|
||||
@@ -86,7 +88,7 @@ var _ = BeforeSuite(func() {
|
||||
chainConfig.LondonBlock = big.NewInt(100)
|
||||
blocks, receipts, chain = test_helpers.MakeChain(5, test_helpers.Genesis, test_helpers.TestChainGen, chainConfig)
|
||||
indexer := shared.SetupTestStateDiffIndexer(context.Background(), chainConfig, test_helpers.Genesis.Hash())
|
||||
builder := statediff.NewBuilder(chain.StateCache())
|
||||
builder := statediff.NewBuilder(adapt.GethStateView(chain.StateCache()))
|
||||
|
||||
// Insert some non-canonical data into the database so that we test our ability to discern canonicity
|
||||
nonCanonBlockHash = test_helpers.MockBlock.Hash()
|
||||
@@ -94,13 +96,15 @@ var _ = BeforeSuite(func() {
|
||||
|
||||
tx, err := indexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// The non-canonical header has a child
|
||||
tx, err = indexer.PushBlock(test_helpers.MockChild, test_helpers.MockReceipts, test_helpers.MockChild.Difficulty())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
ipld := sdtypes.IPLD{
|
||||
CID: ipld.Keccak256ToCid(ipld.RawBinary, test_helpers.CodeHash.Bytes()).String(),
|
||||
@@ -109,7 +113,7 @@ var _ = BeforeSuite(func() {
|
||||
err = indexer.PushIPLD(tx, ipld)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// iterate over the blocks, generating statediff payloads, and transforming the data into Postgres
|
||||
@@ -133,8 +137,9 @@ var _ = BeforeSuite(func() {
|
||||
rcts = receipts[i-1]
|
||||
}
|
||||
|
||||
tx, err := indexer.PushBlock(block, rcts, mockTD)
|
||||
tx, err = indexer.PushBlock(block, rcts, mockTD)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer tx.RollbackOnFailure(err)
|
||||
|
||||
diff, err := builder.BuildStateDiffObject(args, statediff.Params{})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -149,7 +154,7 @@ var _ = BeforeSuite(func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
|
||||
err = tx.Submit(err)
|
||||
err = tx.Submit()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -18,6 +18,7 @@ package rpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/log"
|
||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||
@@ -28,16 +29,23 @@ import (
|
||||
)
|
||||
|
||||
// StartHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules.
|
||||
func StartHTTPEndpoint(endpoint string, apis []rpc.API, modules []string, cors []string, vhosts []string, timeouts rpc.HTTPTimeouts) (*rpc.Server, error) {
|
||||
|
||||
func StartHTTPEndpoint(endpoint string, apis []rpc.API, modules []string, cors []string, vhosts []string, timeouts rpc.HTTPTimeouts, httpMiddlewares [](func(next http.Handler) http.Handler)) (*rpc.Server, error) {
|
||||
srv := rpc.NewServer()
|
||||
err := node.RegisterApis(apis, modules, srv)
|
||||
if err != nil {
|
||||
utils.Fatalf("Could not register HTTP API: %w", err)
|
||||
}
|
||||
handler := prom.HTTPMiddleware(node.NewHTTPHandlerStack(srv, cors, vhosts, nil))
|
||||
|
||||
promHandler := prom.HTTPMiddleware(node.NewHTTPHandlerStack(srv, cors, vhosts, nil))
|
||||
|
||||
// Chain the HTTP middlewares
|
||||
handler := promHandler
|
||||
for _, middleware := range httpMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
// start http server
|
||||
// request -> payments -> metrics -> server
|
||||
_, addr, err := node.StartHTTPEndpoint(endpoint, rpc.DefaultHTTPTimeouts, handler)
|
||||
if err != nil {
|
||||
utils.Fatalf("Could not start RPC api: %v", err)
|
||||
|
||||
+2
-1
@@ -17,8 +17,8 @@
|
||||
package serve
|
||||
|
||||
import (
|
||||
"github.com/cerc-io/plugeth-statediff/types"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/statediff/types"
|
||||
)
|
||||
|
||||
// APIName is the namespace used for the state diffing service API
|
||||
@@ -45,6 +45,7 @@ func NewPublicServerAPI(w Server, client *rpc.Client) *PublicServerAPI {
|
||||
func (api *PublicServerAPI) WatchAddress(operation types.OperationType, args []types.WatchAddressArg) error {
|
||||
err := api.rpc.Call(nil, "statediff_watchAddress", operation, args)
|
||||
if err != nil {
|
||||
// Return the error directly to match the native Geth API
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
+103
-5
@@ -24,12 +24,12 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/database/sql/postgres"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/node"
|
||||
"github.com/cerc-io/plugeth-statediff/utils"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/node"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
@@ -79,8 +79,56 @@ const (
|
||||
DATABASE_MAX_IDLE_CONNECTIONS = "DATABASE_MAX_IDLE_CONNECTIONS"
|
||||
DATABASE_MAX_OPEN_CONNECTIONS = "DATABASE_MAX_OPEN_CONNECTIONS"
|
||||
DATABASE_MAX_CONN_LIFETIME = "DATABASE_MAX_CONN_LIFETIME"
|
||||
|
||||
NITRO_RUN_NODE_IN_PROCESS = "NITRO_RUN_NODE_IN_PROCESS"
|
||||
NITRO_RPC_QUERY_RATES_FILE = "NITRO_RPC_QUERY_RATES_FILE"
|
||||
NITRO_PK = "NITRO_PK"
|
||||
NITRO_CHAIN_PK = "NITRO_CHAIN_PK"
|
||||
NITRO_CHAIN_URL = "NITRO_CHAIN_URL"
|
||||
NITRO_NA_ADDRESS = "NITRO_NA_ADDRESS"
|
||||
NITRO_VPA_ADDRESS = "NITRO_VPA_ADDRESS"
|
||||
NITRO_CA_ADDRESS = "NITRO_CA_ADDRESS"
|
||||
NITRO_USE_DURABLE_STORE = "NITRO_USE_DURABLE_STORE"
|
||||
NITRO_DURABLE_STORE_FOLDER = "NITRO_DURABLE_STORE_FOLDER"
|
||||
NITRO_ENDPOINT = "NITRO_ENDPOINT"
|
||||
NITRO_IS_SECURE = "NITRO_IS_SECURE"
|
||||
NITRO_MSG_PORT = "NITRO_MSG_PORT"
|
||||
NITRO_WS_MSG_PORT = "NITRO_WS_MSG_PORT"
|
||||
NITRO_RPC_PORT = "NITRO_RPC_PORT"
|
||||
NITRO_CHAIN_START_BLOCK = "NITRO_CHAIN_START_BLOCK"
|
||||
NITRO_TLS_CERT_FILEPATH = "NITRO_TLS_CERT_FILEPATH"
|
||||
NITRO_TLS_KEY_FILEPATH = "NITRO_TLS_KEY_FILEPATH"
|
||||
)
|
||||
|
||||
type InProcessNitroNodeConfig struct {
|
||||
Pk string
|
||||
ChainPk string
|
||||
ChainUrl string
|
||||
NaAddress string
|
||||
VpaAddress string
|
||||
CaAddress string
|
||||
UseDurableStore bool
|
||||
DurableStoreFolder string
|
||||
RpcPort int
|
||||
MsgPort int
|
||||
WsMsgPort int
|
||||
ChainStartBlock uint64
|
||||
TlsCertFilepath string
|
||||
TlsKeyFilepath string
|
||||
}
|
||||
|
||||
type RemoteNitroNodeConfig struct {
|
||||
NitroEndpoint string
|
||||
IsSecure bool
|
||||
}
|
||||
|
||||
type NitroConfig struct {
|
||||
RunNodeInProcess bool
|
||||
RpcQueryRatesFile string
|
||||
InProcessNode InProcessNitroNodeConfig
|
||||
RemoteNode RemoteNitroNodeConfig
|
||||
}
|
||||
|
||||
// Config struct
|
||||
type Config struct {
|
||||
DB *sqlx.DB
|
||||
@@ -116,6 +164,8 @@ type Config struct {
|
||||
|
||||
StateValidationEnabled bool
|
||||
StateValidationEveryNthBlock uint64
|
||||
|
||||
Nitro *NitroConfig
|
||||
}
|
||||
|
||||
// NewConfig is used to initialize a watcher config from a .toml file
|
||||
@@ -239,15 +289,17 @@ func NewConfig() (*Config, error) {
|
||||
}
|
||||
chainConfigPath := viper.GetString("ethereum.chainConfig")
|
||||
if chainConfigPath != "" {
|
||||
c.ChainConfig, err = statediff.LoadConfig(chainConfigPath)
|
||||
c.ChainConfig, err = utils.LoadConfig(chainConfigPath)
|
||||
} else {
|
||||
c.ChainConfig, err = statediff.ChainConfig(nodeInfo.ChainID)
|
||||
c.ChainConfig, err = utils.ChainConfig(nodeInfo.ChainID)
|
||||
}
|
||||
|
||||
c.loadGroupCacheConfig()
|
||||
|
||||
c.loadValidatorConfig()
|
||||
|
||||
c.loadNitroConfig()
|
||||
|
||||
return c, err
|
||||
}
|
||||
|
||||
@@ -280,6 +332,52 @@ func (c *Config) dbInit() {
|
||||
c.DBConfig.MaxConnLifetime = time.Duration(viper.GetInt("database.maxLifetime"))
|
||||
}
|
||||
|
||||
func (c *Config) loadNitroConfig() {
|
||||
c.Nitro = &NitroConfig{InProcessNode: InProcessNitroNodeConfig{}, RemoteNode: RemoteNitroNodeConfig{}}
|
||||
|
||||
viper.BindEnv("nitro.runNodeInProcess", NITRO_RUN_NODE_IN_PROCESS)
|
||||
viper.BindEnv("nitro.rpcQueryRatesFile", NITRO_RPC_QUERY_RATES_FILE)
|
||||
|
||||
viper.BindEnv("nitro.inProcesssNode.pk", NITRO_PK)
|
||||
viper.BindEnv("nitro.inProcesssNode.chainPk", NITRO_CHAIN_PK)
|
||||
viper.BindEnv("nitro.inProcesssNode.chainUrl", NITRO_CHAIN_URL)
|
||||
viper.BindEnv("nitro.inProcesssNode.naAddress", NITRO_NA_ADDRESS)
|
||||
viper.BindEnv("nitro.inProcesssNode.vpaAddress", NITRO_VPA_ADDRESS)
|
||||
viper.BindEnv("nitro.inProcesssNode.caAddress", NITRO_CA_ADDRESS)
|
||||
viper.BindEnv("nitro.inProcesssNode.useDurableStore", NITRO_USE_DURABLE_STORE)
|
||||
viper.BindEnv("nitro.inProcesssNode.durableStoreFolder", NITRO_DURABLE_STORE_FOLDER)
|
||||
viper.BindEnv("nitro.inProcesssNode.msgPort", NITRO_MSG_PORT)
|
||||
viper.BindEnv("nitro.inProcesssNode.rpcPort", NITRO_RPC_PORT)
|
||||
viper.BindEnv("nitro.inProcesssNode.wsMsgPort", NITRO_WS_MSG_PORT)
|
||||
viper.BindEnv("nitro.inProcesssNode.chainStartBlock", NITRO_CHAIN_START_BLOCK)
|
||||
viper.BindEnv("nitro.inProcesssNode.tlsCertFilepath", NITRO_TLS_CERT_FILEPATH)
|
||||
viper.BindEnv("nitro.inProcesssNode.tlsKeyFilepath", NITRO_TLS_KEY_FILEPATH)
|
||||
|
||||
viper.BindEnv("nitro.remoteNode.nitroEndpoint", NITRO_ENDPOINT)
|
||||
viper.BindEnv("nitro.remoteNode.isSecure", NITRO_IS_SECURE)
|
||||
|
||||
c.Nitro.RunNodeInProcess = viper.GetBool("nitro.runNodeInProcess")
|
||||
c.Nitro.RpcQueryRatesFile = viper.GetString("nitro.rpcQueryRatesFile")
|
||||
|
||||
c.Nitro.InProcessNode.Pk = viper.GetString("nitro.inProcesssNode.pk")
|
||||
c.Nitro.InProcessNode.ChainPk = viper.GetString("nitro.inProcesssNode.chainPk")
|
||||
c.Nitro.InProcessNode.ChainUrl = viper.GetString("nitro.inProcesssNode.chainUrl")
|
||||
c.Nitro.InProcessNode.NaAddress = viper.GetString("nitro.inProcesssNode.naAddress")
|
||||
c.Nitro.InProcessNode.VpaAddress = viper.GetString("nitro.inProcesssNode.vpaAddress")
|
||||
c.Nitro.InProcessNode.CaAddress = viper.GetString("nitro.inProcesssNode.caAddress")
|
||||
c.Nitro.InProcessNode.UseDurableStore = viper.GetBool("nitro.inProcesssNode.useDurableStore")
|
||||
c.Nitro.InProcessNode.DurableStoreFolder = viper.GetString("nitro.inProcesssNode.durableStoreFolder")
|
||||
c.Nitro.InProcessNode.MsgPort = viper.GetInt("nitro.inProcesssNode.msgPort")
|
||||
c.Nitro.InProcessNode.RpcPort = viper.GetInt("nitro.inProcesssNode.rpcPort")
|
||||
c.Nitro.InProcessNode.WsMsgPort = viper.GetInt("nitro.inProcesssNode.wsMsgPort")
|
||||
c.Nitro.InProcessNode.ChainStartBlock = viper.GetUint64("nitro.inProcesssNode.chainStartBlock")
|
||||
c.Nitro.InProcessNode.TlsCertFilepath = viper.GetString("nitro.inProcesssNode.tlsCertFilepath")
|
||||
c.Nitro.InProcessNode.TlsKeyFilepath = viper.GetString("nitro.inProcesssNode.tlsKeyFilepath")
|
||||
|
||||
c.Nitro.RemoteNode.NitroEndpoint = viper.GetString("nitro.remoteNode.nitroEndpoint")
|
||||
c.Nitro.RemoteNode.IsSecure = viper.GetBool("nitro.remoteNode.isSecure")
|
||||
}
|
||||
|
||||
func (c *Config) loadGroupCacheConfig() {
|
||||
viper.BindEnv("groupcache.pool.enabled", ethServerShared.GcachePoolEnabled)
|
||||
viper.BindEnv("groupcache.pool.httpEndpoint", ethServerShared.GcachePoolHttpPath)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/database/sql/postgres"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ import (
|
||||
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/cerc-io/plugeth-statediff/indexer"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/database/sql/postgres"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/interfaces"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/models"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/node"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/interfaces"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||
"github.com/ethereum/go-ethereum/statediff/indexer/node"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
@@ -93,7 +93,7 @@ func SetupTestStateDiffIndexer(ctx context.Context, chainConfig *params.ChainCon
|
||||
|
||||
dbconfig, err := postgres.TestConfig.WithEnv()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, stateDiffIndexer, err := indexer.NewStateDiffIndexer(ctx, chainConfig, testInfo, dbconfig)
|
||||
_, stateDiffIndexer, err := indexer.NewStateDiffIndexer(ctx, chainConfig, testInfo, dbconfig, true)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
return stateDiffIndexer
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#!/bin/bash
|
||||
# Builds and deploys a stack with only what we need.
|
||||
# This script assumes we are running in the project root.
|
||||
|
||||
set -e
|
||||
|
||||
@@ -15,20 +17,21 @@ echo CERC_STATEDIFF_DB_GOOSE_MIN_VER=18 >> $CONFIG_DIR/stack.env
|
||||
# Pass this in so we can run eth_call forwarding tests, which expect no IPLD DB
|
||||
echo CERC_RUN_STATEDIFF=${CERC_RUN_STATEDIFF:-true} >> $CONFIG_DIR/stack.env
|
||||
|
||||
laconic_so="${LACONIC_SO:-laconic-so} --stack fixturenet-eth-loaded --quiet"
|
||||
laconic_so="${LACONIC_SO:-laconic-so} --stack fixturenet-plugeth-tx --verbose"
|
||||
|
||||
set -x
|
||||
|
||||
# Build and deploy a cluster with only what we need from the stack
|
||||
$laconic_so setup-repositories \
|
||||
--exclude github.com/cerc-io/ipld-eth-server,github.com/cerc-io/tx-spammer \
|
||||
--branches-file ./test/stack-refs.txt
|
||||
if [[ -z $SKIP_BUILD ]]; then
|
||||
$laconic_so setup-repositories \
|
||||
--exclude github.com/cerc-io/ipld-eth-server,github.com/cerc-io/tx-spammer,github.com/dboreham/foundry \
|
||||
--branches-file ./test/stack-refs.txt
|
||||
|
||||
$laconic_so build-containers \
|
||||
--exclude cerc/ipld-eth-server,cerc/keycloak,cerc/tx-spammer
|
||||
$laconic_so build-containers \
|
||||
--exclude cerc/ipld-eth-server,cerc/keycloak,cerc/tx-spammer,cerc/foundry
|
||||
fi
|
||||
|
||||
$laconic_so deploy \
|
||||
--include fixturenet-eth,ipld-eth-db \
|
||||
--include fixturenet-plugeth,ipld-eth-db \
|
||||
--env-file $CONFIG_DIR/stack.env \
|
||||
--cluster test up
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
services:
|
||||
ipld-eth-server:
|
||||
restart: unless-stopped
|
||||
image: cerc/ipld-eth-server
|
||||
build: ..
|
||||
image: cerc/ipld-eth-server:local
|
||||
networks:
|
||||
- test_default
|
||||
environment:
|
||||
@@ -14,21 +13,22 @@ services:
|
||||
DATABASE_USER: "vdbm"
|
||||
DATABASE_PASSWORD: "password"
|
||||
ETH_HTTP_PATH: fixturenet-eth-geth-1:8545
|
||||
ETH_CHAIN_CONFIG: "/tmp/chain.json"
|
||||
ETH_CHAIN_CONFIG: /tmp/chain.json
|
||||
ETH_PROXY_ON_ERROR: false
|
||||
ETH_FORWARD_ETH_CALLS: $ETH_FORWARD_ETH_CALLS
|
||||
SERVER_HTTP_PATH: 0.0.0.0:8081
|
||||
VDB_COMMAND: serve
|
||||
LOG_LEVEL: debug
|
||||
volumes:
|
||||
- type: bind
|
||||
source: "${ETH_CHAIN_CONFIG:-./test/chain.json}"
|
||||
target: /tmp/chain.json
|
||||
- type: bind
|
||||
source: $ETH_CHAIN_CONFIG
|
||||
target: /tmp/chain.json
|
||||
ports:
|
||||
- 127.0.0.1:8081:8081
|
||||
- 127.0.0.1:8081:8081
|
||||
|
||||
contract-deployer:
|
||||
restart: on-failure
|
||||
image: cerc/contract-deployer
|
||||
image: cerc/ipld-eth-server/contract-deployer:local
|
||||
build: ./contract
|
||||
networks:
|
||||
- test_default
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
# Downgrade from 18.16, see https://github.com/NomicFoundation/hardhat/issues/3877
|
||||
FROM node:18.15-slim
|
||||
|
||||
ARG ETH_ADDR
|
||||
ENV ETH_ADDR $ETH_ADDR
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
github.com/cerc-io/go-ethereum v1.11.6-statediff-5.0.8
|
||||
github.com/cerc-io/ipld-eth-db v5.0.5-alpha
|
||||
git.vdb.to/cerc-io/plugeth-statediff v0.1.1
|
||||
|
||||
Reference in New Issue
Block a user