forked from cerc-io/ipld-eth-server
Compare commits
161
Commits
v0.3.9
...
cerc_refactor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70b6f62548 | ||
|
|
e7fb82475b | ||
|
|
d2be539fd1 | ||
|
|
7c77b491ed | ||
|
|
31407b5e79 | ||
|
|
9cc02cae23 | ||
|
|
7b1dab40d5 | ||
|
|
89c321d8cf | ||
|
|
1dd5b9ab5c | ||
|
|
44ccf2bd0b | ||
|
|
3201ed60f0 | ||
|
|
d24be29ef0 | ||
|
|
0e91e42128 | ||
|
|
4e9f4bbad6 | ||
|
|
e40e8a7335 | ||
|
|
ddc7485c08 | ||
|
|
cc35b06ddf | ||
|
|
1a24075da7 | ||
|
|
c9e6055cfd | ||
|
|
9eb7b22f47 | ||
|
|
4cf523b626 | ||
|
|
451d71a528 | ||
|
|
ec21e95182 | ||
|
|
0d1da46d6d | ||
|
|
45502e7117 | ||
|
|
74a7748483 | ||
|
|
415e426946 | ||
|
|
ba01123f54 | ||
|
|
b90c28906a | ||
|
|
6cb54ca790 | ||
|
|
bcd00c6e2b | ||
|
|
923a8c3241 | ||
|
|
07a991d3e4 | ||
|
|
a63640933e | ||
|
|
a5ac6c19cf | ||
|
|
45c5a25d54 | ||
|
|
72e903cf68 | ||
|
|
b7b4631231 | ||
|
|
f8de0defad | ||
|
|
aaf571b04c | ||
|
|
4121863a4c | ||
|
|
fa4428b167 | ||
|
|
221114cf56 | ||
|
|
8e652a634f | ||
|
|
1fc53ccab1 | ||
|
|
31e9a7dc5e | ||
|
|
c19cc5c44d | ||
|
|
6bd563e3d5 | ||
|
|
b3d9e01d67 | ||
|
|
0c44882cb2 | ||
|
|
80413211c2 | ||
|
|
7f15befdee | ||
|
|
217cfc63ec | ||
|
|
9550d60467 | ||
|
|
da1c8b2332 | ||
|
|
fe7329c284 | ||
|
|
f144d932cd | ||
|
|
491939b35f | ||
|
|
248d9eb7a2 | ||
|
|
a3d2e71ca6 | ||
|
|
be1d4281e8 | ||
|
|
e2b83a5737 | ||
|
|
613dd6acf4 | ||
|
|
8966d1b6c2 | ||
|
|
c556845d1a | ||
|
|
cf8c08f01e | ||
|
|
5c6fb45d36 | ||
|
|
222fa6d6ed | ||
|
|
6c82eafef1 | ||
|
|
89b9a05234 | ||
|
|
27d9413544 | ||
|
|
4817674c5c | ||
|
|
8556332ff8 | ||
|
|
81884d4826 | ||
|
|
389ba2e360 | ||
|
|
c25d220f71 | ||
|
|
8ea4d1e40d | ||
|
|
ace12fbc35 | ||
|
|
8b8f644b2a | ||
|
|
8bfcce95ca | ||
|
|
0b12c3c329 | ||
|
|
037131528c | ||
|
|
be34f0e8fd | ||
|
|
04096fab0c | ||
|
|
dc14656bbc | ||
|
|
9676690a2d | ||
|
|
025b1c7c9e | ||
|
|
36e590c092 | ||
|
|
384d939dc2 | ||
|
|
24a45a3f00 | ||
|
|
867323a1ab | ||
|
|
da30a957a7 | ||
|
|
705835512e | ||
|
|
2a0e9f8dfd | ||
|
|
c8bdaefe97 | ||
|
|
a141d154b7 | ||
|
|
76986d9497 | ||
|
|
233fa29740 | ||
|
|
4883590d85 | ||
|
|
181e3745f1 | ||
|
|
4b697b2a98 | ||
|
|
77812f2673 | ||
|
|
849b17f4bd | ||
|
|
56c85709c1 | ||
|
|
2be2a06575 | ||
|
|
39fb9207b2 | ||
|
|
3914889d53 | ||
|
|
1a6ff273ba | ||
|
|
f57b816530 | ||
|
|
76aaa93c50 | ||
|
|
778bf82dfd | ||
|
|
e8c1db69b4 | ||
|
|
86eee94f9b | ||
|
|
d785fda414 | ||
|
|
41e04a1c30 | ||
|
|
3aa5cb36ef | ||
|
|
43ddbc7eea | ||
|
|
8df8b50cb1 | ||
|
|
072ba1edcc | ||
|
|
f61691a26e | ||
|
|
6ab34eb878 | ||
|
|
3e211d5978 | ||
|
|
f600ea46bc | ||
|
|
6fa38fd198 | ||
|
|
2fa941f084 | ||
|
|
14332c2cd9 | ||
|
|
a780782bb6 | ||
|
|
627f2c7f81 | ||
|
|
925b22869a | ||
|
|
e6fb859967 | ||
|
|
850b305bf6 | ||
|
|
2f6f939982 | ||
|
|
409521416b | ||
|
|
72d3174f63 | ||
|
|
e288a2933d | ||
|
|
1020ec18a4 | ||
|
|
3118bf4964 | ||
|
|
61e6585f1c | ||
|
|
e924974ece | ||
|
|
20b75ff18f | ||
|
|
ef65993412 | ||
|
|
520be6bc86 | ||
|
|
01074ab55c | ||
|
|
88e20dfc6e | ||
|
|
4446219c36 | ||
|
|
88a89c0cc2 | ||
|
|
63e77c9bc0 | ||
|
|
19570f733f | ||
|
|
3058dc48a8 | ||
|
|
5d86b6e029 | ||
|
|
3b863dc76b | ||
|
|
e92b66638e | ||
|
|
cb39a94792 | ||
|
|
ef4d1f958d | ||
|
|
de12fab935 | ||
|
|
34a6d3af4b | ||
|
|
c28ebcc4f2 | ||
|
|
93a995627c | ||
|
|
316bf0990a | ||
|
|
143d79fdfc | ||
|
|
c07ee1d78a |
@@ -1,25 +0,0 @@
|
|||||||
name: Docker Compose Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Run docker build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Get the version
|
|
||||||
id: vars
|
|
||||||
run: echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7})
|
|
||||||
- name: Run docker build
|
|
||||||
run: make docker-build
|
|
||||||
- name: Tag docker image
|
|
||||||
run: docker tag vulcanize/ipld-eth-server docker.pkg.github.com/vulcanize/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}}
|
|
||||||
- name: Docker Login
|
|
||||||
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin
|
|
||||||
- name: Docker Push
|
|
||||||
run: docker push docker.pkg.github.com/vulcanize/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}}
|
|
||||||
|
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
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
|
||||||
|
secrets:
|
||||||
|
BUILD_HOSTNAME: ${{ secrets.BUILD_HOSTNAME }}
|
||||||
|
BUILD_USERNAME: ${{ secrets.BUILD_USERNAME }}
|
||||||
|
BUILD_KEY: ${{ secrets.BUILD_KEY }}
|
||||||
|
with:
|
||||||
|
STACK_ORCHESTRATOR_REF: "f2fd766f5400fcb9eb47b50675d2e3b1f2753702"
|
||||||
|
GO_ETHEREUM_REF: "be1757b9fd884cb20c8d7faac8fa81fc49bb7216"
|
||||||
|
IPLD_ETH_DB_REF: "be345e0733d2c025e4082c5154e441317ae94cf7"
|
||||||
|
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@v2
|
||||||
|
- name: Get the version
|
||||||
|
id: vars
|
||||||
|
run: echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7})
|
||||||
|
- name: Run docker build
|
||||||
|
run: make docker-build
|
||||||
|
- name: Tag docker image
|
||||||
|
run: docker tag cerc-io/ipld-eth-server git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}}
|
||||||
|
- name: Docker Login
|
||||||
|
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin
|
||||||
|
- name: Docker Push
|
||||||
|
run: docker push git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}}
|
||||||
|
|
||||||
|
push_to_registries:
|
||||||
|
name: Push Docker image to Docker Hub
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: |
|
||||||
|
always() &&
|
||||||
|
(needs.build.result == 'success') &&
|
||||||
|
github.event_name == 'release'
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- name: Get the version
|
||||||
|
id: vars
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7})
|
||||||
|
echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/})
|
||||||
|
- name: Docker Login to Github Registry
|
||||||
|
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin
|
||||||
|
- name: Docker Pull
|
||||||
|
run: docker pull git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}}
|
||||||
|
- name: Docker Login to Docker Registry
|
||||||
|
run: echo ${{ secrets.VULCANIZEJENKINS_PAT }} | docker login -u vulcanizejenkins --password-stdin
|
||||||
|
- name: Tag docker image
|
||||||
|
run: docker tag git.vdb.to/cerc-io/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}} cerc-io/ipld-eth-server:${{steps.vars.outputs.tag}}
|
||||||
|
- name: Docker Push to Docker Hub
|
||||||
|
run: docker push cerc-io/ipld-eth-server:${{steps.vars.outputs.tag}}
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
name: Docker Build
|
|
||||||
|
|
||||||
on: [pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Run docker build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Run docker build
|
|
||||||
run: make docker-build
|
|
||||||
test:
|
|
||||||
name: Run unit tests
|
|
||||||
env:
|
|
||||||
GOPATH: /tmp/go
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
go-version: [1.16.x, 1.17.x]
|
|
||||||
os: [ubuntu-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Create GOPATH
|
|
||||||
run: mkdir -p /tmp/go
|
|
||||||
- name: Install Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go-version }}
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Run database
|
|
||||||
run: docker-compose up -d ipld-eth-db
|
|
||||||
- name: Test
|
|
||||||
run: |
|
|
||||||
sleep 10
|
|
||||||
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing make test
|
|
||||||
|
|
||||||
integrationtest:
|
|
||||||
name: Run integration tests
|
|
||||||
env:
|
|
||||||
GOPATH: /tmp/go
|
|
||||||
DB_WRITE: true
|
|
||||||
ETH_FORWARD_ETH_CALLS: false
|
|
||||||
ETH_PROXY_ON_ERROR: false
|
|
||||||
ETH_HTTP_PATH: ""
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
go-version: [1.16.x]
|
|
||||||
os: [ubuntu-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Create GOPATH
|
|
||||||
run: mkdir -p /tmp/go
|
|
||||||
- name: Install Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go-version }}
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Run database
|
|
||||||
run: docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d ipld-eth-db dapptools contract eth-server
|
|
||||||
- name: Test
|
|
||||||
run: |
|
|
||||||
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \
|
|
||||||
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \
|
|
||||||
make integrationtest
|
|
||||||
|
|
||||||
integrationtest_forwardethcalls:
|
|
||||||
name: Run integration tests for direct proxy fall-through of eth_calls
|
|
||||||
env:
|
|
||||||
GOPATH: /tmp/go
|
|
||||||
DB_WRITE: false
|
|
||||||
ETH_FORWARD_ETH_CALLS: true
|
|
||||||
ETH_PROXY_ON_ERROR: false
|
|
||||||
ETH_HTTP_PATH: "dapptools:8545"
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
go-version: [ 1.16.x ]
|
|
||||||
os: [ ubuntu-latest ]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Create GOPATH
|
|
||||||
run: mkdir -p /tmp/go
|
|
||||||
- name: Install Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go-version }}
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Run database
|
|
||||||
run: docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d ipld-eth-db dapptools contract eth-server
|
|
||||||
- name: Test
|
|
||||||
run: |
|
|
||||||
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \
|
|
||||||
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \
|
|
||||||
make integrationtest
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
name: Publish Docker image
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
jobs:
|
|
||||||
push_to_registries:
|
|
||||||
name: Push Docker image to Docker Hub
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Get the version
|
|
||||||
id: vars
|
|
||||||
run: |
|
|
||||||
echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7})
|
|
||||||
echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/})
|
|
||||||
- name: Docker Login to Github Registry
|
|
||||||
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin
|
|
||||||
- name: Docker Pull
|
|
||||||
run: docker pull docker.pkg.github.com/vulcanize/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}}
|
|
||||||
- name: Docker Login to Docker Registry
|
|
||||||
run: echo ${{ secrets.VULCANIZEJENKINS_PAT }} | docker login -u vulcanizejenkins --password-stdin
|
|
||||||
- name: Tag docker image
|
|
||||||
run: docker tag docker.pkg.github.com/vulcanize/ipld-eth-server/ipld-eth-server:${{steps.vars.outputs.sha}} vulcanize/ipld-eth-server:${{steps.vars.outputs.tag}}
|
|
||||||
- name: Docker Push to Docker Hub
|
|
||||||
run: docker push vulcanize/ipld-eth-server:${{steps.vars.outputs.tag}}
|
|
||||||
|
|
||||||
Executable
+29
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Set up repo
|
||||||
|
start_dir=$(pwd)
|
||||||
|
temp_dir=$(mktemp -d)
|
||||||
|
cd $temp_dir
|
||||||
|
git clone -b $(cat /tmp/git_head_ref) "https://github.com/$(cat /tmp/git_repository).git"
|
||||||
|
cd ipld-eth-server
|
||||||
|
|
||||||
|
## Remove the branch and github related info. This way future runs wont be confused.
|
||||||
|
rm -f /tmp/git_head_ref /tmp/git_repository
|
||||||
|
|
||||||
|
# Spin up DB and run migrations
|
||||||
|
echo 'docker-compose up -d migrations ipld-eth-db'
|
||||||
|
docker-compose up -d migrations ipld-eth-db
|
||||||
|
trap "docker-compose down -v --remove-orphans; cd $start_dir ; rm -r $temp_dir" SIGINT SIGTERM ERR
|
||||||
|
sleep 30
|
||||||
|
|
||||||
|
# Remove old logs so there's no confusion, then run test
|
||||||
|
rm -f /tmp/test.log /tmp/return_test.txt
|
||||||
|
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=localhost DATABASE_NAME=vulcanize_testing make test > /tmp/test.log
|
||||||
|
echo $? > /tmp/return_test.txt
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
docker-compose down -v --remove-orphans
|
||||||
|
cd $start_dir
|
||||||
|
rm -fr $temp_dir
|
||||||
@@ -0,0 +1,212 @@
|
|||||||
|
name: Test the stack.
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
secrets:
|
||||||
|
BUILD_HOSTNAME:
|
||||||
|
required: true
|
||||||
|
BUILD_USERNAME:
|
||||||
|
required: true
|
||||||
|
BUILD_KEY:
|
||||||
|
required: true
|
||||||
|
inputs:
|
||||||
|
STACK_ORCHESTRATOR_REF:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
GO_ETHEREUM_REF:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
IPLD_ETH_DB_REF:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Run docker build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Run docker build
|
||||||
|
run: make docker-build
|
||||||
|
test:
|
||||||
|
name: Run unit tests
|
||||||
|
env:
|
||||||
|
GOPATH: /tmp/go
|
||||||
|
# To run the unit tests you need to add secrets to your repository.
|
||||||
|
BUILD_HOSTNAME: ${{ secrets.BUILD_HOSTNAME }}
|
||||||
|
BUILD_USERNAME: ${{ secrets.BUILD_USERNAME }}
|
||||||
|
BUILD_KEY: ${{ secrets.BUILD_KEY }}
|
||||||
|
#strategy:
|
||||||
|
# matrix:
|
||||||
|
# go-version: [1.16.x, 1.17.x, 1.18.x]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Passed experience with GHA has taught me to store variables in files instead of passing them as variables.
|
||||||
|
- name: Output variables to files
|
||||||
|
run: |
|
||||||
|
echo $GITHUB_REPOSITORY > /tmp/git_repository
|
||||||
|
[ -z "$GITHUB_HEAD_REF" ] && echo $GITHUB_REF_NAME > /tmp/git_head_ref || echo $GITHUB_HEAD_REF > /tmp/git_head_ref
|
||||||
|
echo "-----BEGIN OPENSSH PRIVATE KEY-----" >> /tmp/key
|
||||||
|
echo ${{ env.BUILD_KEY }} >> /tmp/key
|
||||||
|
echo "-----END OPENSSH PRIVATE KEY-----" >> /tmp/key
|
||||||
|
chmod 400 /tmp/key
|
||||||
|
cat /tmp/git_repository
|
||||||
|
cat /tmp/git_head_ref
|
||||||
|
|
||||||
|
- name: Raw SCP
|
||||||
|
run: |
|
||||||
|
scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key /tmp/git_repository ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/git_repository
|
||||||
|
scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key /tmp/git_head_ref ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/git_head_ref
|
||||||
|
scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key .github/workflows/run_unit_test.sh ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/run_unit_test.sh
|
||||||
|
|
||||||
|
- name: Trigger Unit Test
|
||||||
|
run: |
|
||||||
|
ssh -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }} go install github.com/onsi/ginkgo/ginkgo@latest
|
||||||
|
ssh -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }} /tmp/run_unit_test.sh
|
||||||
|
|
||||||
|
- name: Get the logs and cat them
|
||||||
|
run: |
|
||||||
|
scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/test.log .
|
||||||
|
cat ./test.log
|
||||||
|
|
||||||
|
- name: Check Error Code
|
||||||
|
run: |
|
||||||
|
scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/return_test.txt .
|
||||||
|
[ $(cat ./return_test.txt) -eq 0 ]
|
||||||
|
|
||||||
|
integrationtest:
|
||||||
|
name: Run integration tests
|
||||||
|
env:
|
||||||
|
GOPATH: /tmp/go
|
||||||
|
DB_WRITE: true
|
||||||
|
ETH_FORWARD_ETH_CALLS: false
|
||||||
|
ETH_PROXY_ON_ERROR: false
|
||||||
|
ETH_HTTP_PATH: "go-ethereum:8545"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Create GOPATH
|
||||||
|
run: mkdir -p /tmp/go
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: "1.18.x"
|
||||||
|
check-latest: true
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: "./ipld-eth-server"
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.STACK_ORCHESTRATOR_REF }}
|
||||||
|
path: "./stack-orchestrator/"
|
||||||
|
repository: vulcanize/stack-orchestrator
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.GO_ETHEREUM_REF }}
|
||||||
|
repository: cerc-io/go-ethereum
|
||||||
|
path: "./go-ethereum/"
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.IPLD_ETH_DB_REF }}
|
||||||
|
repository: cerc-io/ipld-eth-db
|
||||||
|
path: "./ipld-eth-db/"
|
||||||
|
- name: Create config file
|
||||||
|
run: |
|
||||||
|
echo vulcanize_go_ethereum=$GITHUB_WORKSPACE/go-ethereum/ > ./config.sh
|
||||||
|
echo vulcanize_ipld_eth_db=$GITHUB_WORKSPACE/ipld-eth-db/ >> ./config.sh
|
||||||
|
echo vulcanize_ipld_eth_server=$GITHUB_WORKSPACE/ipld-eth-server/ >> ./config.sh
|
||||||
|
echo vulcanize_test_contract=$GITHUB_WORKSPACE/ipld-eth-server/test/contract >> ./config.sh
|
||||||
|
echo genesis_file_path=start-up-files/go-ethereum/genesis.json >> ./config.sh
|
||||||
|
echo db_write=$DB_WRITE >> ./config.sh
|
||||||
|
echo eth_forward_eth_calls=$ETH_FORWARD_ETH_CALLS >> ./config.sh
|
||||||
|
echo eth_proxy_on_error=$ETH_PROXY_ON_ERROR >> ./config.sh
|
||||||
|
echo eth_http_path=$ETH_HTTP_PATH >> ./config.sh
|
||||||
|
cat ./config.sh
|
||||||
|
- name: Build geth
|
||||||
|
run: |
|
||||||
|
cd $GITHUB_WORKSPACE/stack-orchestrator/helper-scripts
|
||||||
|
./compile-geth.sh \
|
||||||
|
-p "$GITHUB_WORKSPACE/config.sh" \
|
||||||
|
-e docker
|
||||||
|
- name: Run docker compose
|
||||||
|
run: |
|
||||||
|
docker-compose \
|
||||||
|
-f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-db-sharding.yml" \
|
||||||
|
-f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" \
|
||||||
|
-f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-ipld-eth-server.yml" \
|
||||||
|
-f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-contract.yml" \
|
||||||
|
--env-file "$GITHUB_WORKSPACE/config.sh" \
|
||||||
|
up -d --build
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
cd $GITHUB_WORKSPACE/ipld-eth-server
|
||||||
|
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \
|
||||||
|
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \
|
||||||
|
make integrationtest
|
||||||
|
|
||||||
|
integrationtest_forwardethcalls:
|
||||||
|
name: Run integration tests for direct proxy fall-through of eth_calls
|
||||||
|
env:
|
||||||
|
GOPATH: /tmp/go
|
||||||
|
DB_WRITE: false
|
||||||
|
ETH_FORWARD_ETH_CALLS: true
|
||||||
|
ETH_PROXY_ON_ERROR: false
|
||||||
|
ETH_HTTP_PATH: "go-ethereum:8545"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Create GOPATH
|
||||||
|
run: mkdir -p /tmp/go
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: "1.18.x"
|
||||||
|
check-latest: true
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: "./ipld-eth-server"
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.STACK_ORCHESTRATOR_REF }}
|
||||||
|
path: "./stack-orchestrator/"
|
||||||
|
repository: vulcanize/stack-orchestrator
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.GO_ETHEREUM_REF }}
|
||||||
|
repository: cerc-io/go-ethereum
|
||||||
|
path: "./go-ethereum/"
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.IPLD_ETH_DB_REF }}
|
||||||
|
repository: cerc-io/ipld-eth-db
|
||||||
|
path: "./ipld-eth-db/"
|
||||||
|
- name: Create config file
|
||||||
|
run: |
|
||||||
|
echo vulcanize_go_ethereum=$GITHUB_WORKSPACE/go-ethereum/ > ./config.sh
|
||||||
|
echo vulcanize_ipld_eth_db=$GITHUB_WORKSPACE/ipld-eth-db/ >> ./config.sh
|
||||||
|
echo vulcanize_ipld_eth_server=$GITHUB_WORKSPACE/ipld-eth-server/ >> ./config.sh
|
||||||
|
echo vulcanize_test_contract=$GITHUB_WORKSPACE/ipld-eth-server/test/contract >>./config.sh
|
||||||
|
echo genesis_file_path=start-up-files/go-ethereum/genesis.json >> ./config.sh
|
||||||
|
echo db_write=$DB_WRITE >> ./config.sh
|
||||||
|
echo eth_forward_eth_calls=$ETH_FORWARD_ETH_CALLS >> ./config.sh
|
||||||
|
echo eth_proxy_on_error=$ETH_PROXY_ON_ERROR >> ./config.sh
|
||||||
|
echo eth_http_path=$ETH_HTTP_PATH >> ./config.sh
|
||||||
|
cat ./config.sh
|
||||||
|
- name: Build geth
|
||||||
|
run: |
|
||||||
|
cd $GITHUB_WORKSPACE/stack-orchestrator/helper-scripts
|
||||||
|
./compile-geth.sh \
|
||||||
|
-p "$GITHUB_WORKSPACE/config.sh" \
|
||||||
|
-e docker
|
||||||
|
- name: Run docker compose
|
||||||
|
run: |
|
||||||
|
docker-compose \
|
||||||
|
-f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-db-sharding.yml" \
|
||||||
|
-f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" \
|
||||||
|
-f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-ipld-eth-server.yml" \
|
||||||
|
-f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-contract.yml" \
|
||||||
|
--env-file "$GITHUB_WORKSPACE/config.sh" \
|
||||||
|
up -d --build
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
cd $GITHUB_WORKSPACE/ipld-eth-server
|
||||||
|
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \
|
||||||
|
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \
|
||||||
|
make integrationtest
|
||||||
+6
-6
@@ -1,11 +1,11 @@
|
|||||||
FROM golang:1.16-alpine as builder
|
FROM golang:1.18-alpine as builder
|
||||||
|
|
||||||
RUN apk --update --no-cache add make git g++ linux-headers
|
RUN apk --update --no-cache add make git g++ linux-headers
|
||||||
# DEBUG
|
# DEBUG
|
||||||
RUN apk add busybox-extras
|
RUN apk add busybox-extras
|
||||||
|
|
||||||
# Build ipld-eth-server
|
# Build ipld-eth-server
|
||||||
WORKDIR /go/src/github.com/vulcanize/ipld-eth-server
|
WORKDIR /go/src/github.com/cerc-io/ipld-eth-server
|
||||||
|
|
||||||
# Cache the modules
|
# Cache the modules
|
||||||
ENV GO111MODULE=on
|
ENV GO111MODULE=on
|
||||||
@@ -37,13 +37,13 @@ USER $USER
|
|||||||
|
|
||||||
# chown first so dir is writable
|
# chown first so dir is writable
|
||||||
# note: using $USER is merged, but not in the stable release yet
|
# note: using $USER is merged, but not in the stable release yet
|
||||||
COPY --chown=5000:5000 --from=builder /go/src/github.com/vulcanize/ipld-eth-server/$CONFIG_FILE config.toml
|
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/vulcanize/ipld-eth-server/entrypoint.sh .
|
COPY --chown=5000:5000 --from=builder /go/src/github.com/cerc-io/ipld-eth-server/entrypoint.sh .
|
||||||
|
|
||||||
|
|
||||||
# keep binaries immutable
|
# keep binaries immutable
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-server/ipld-eth-server ipld-eth-server
|
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 /goose goose
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-server/environments environments
|
COPY --from=builder /go/src/github.com/cerc-io/ipld-eth-server/environments environments
|
||||||
|
|
||||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ BASE = $(GOPATH)/src/$(PACKAGE)
|
|||||||
PKGS = go list ./... | grep -v "^vendor/"
|
PKGS = go list ./... | grep -v "^vendor/"
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
## Testing library
|
|
||||||
GINKGO = $(BIN)/ginkgo
|
|
||||||
$(BIN)/ginkgo:
|
|
||||||
go get -u github.com/onsi/ginkgo/ginkgo
|
|
||||||
|
|
||||||
## Migration tool
|
## Migration tool
|
||||||
GOOSE = $(BIN)/goose
|
GOOSE = $(BIN)/goose
|
||||||
@@ -26,8 +22,9 @@ $(BIN)/gometalinter.v2:
|
|||||||
|
|
||||||
|
|
||||||
.PHONY: installtools
|
.PHONY: installtools
|
||||||
installtools: | $(LINT) $(GOOSE) $(GINKGO)
|
installtools: | $(LINT) $(GOOSE)
|
||||||
echo "Installing tools"
|
echo "Installing tools"
|
||||||
|
go mod download
|
||||||
|
|
||||||
.PHONY: metalint
|
.PHONY: metalint
|
||||||
metalint: | $(METALINT)
|
metalint: | $(METALINT)
|
||||||
@@ -54,30 +51,23 @@ TEST_CONNECT_STRING = postgresql://$(DATABASE_USER):$(DATABASE_PASSWORD)@$(DATAB
|
|||||||
TEST_CONNECT_STRING_LOCAL = postgresql://$(USER)@$(HOST_NAME):$(PORT)/$(TEST_DB)?sslmode=disable
|
TEST_CONNECT_STRING_LOCAL = postgresql://$(USER)@$(HOST_NAME):$(PORT)/$(TEST_DB)?sslmode=disable
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: | $(GINKGO) $(GOOSE)
|
test: | $(GOOSE)
|
||||||
go vet ./...
|
go vet ./...
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
$(GINKGO) -r --skipPackage=test
|
go run github.com/onsi/ginkgo/ginkgo -r --skipPackage=test
|
||||||
|
|
||||||
.PHONY: integrationtest
|
.PHONY: integrationtest
|
||||||
integrationtest: | $(GINKGO) $(GOOSE)
|
integrationtest: | $(GOOSE)
|
||||||
go vet ./...
|
go vet ./...
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
$(GINKGO) -r test/ -v
|
go run github.com/onsi/ginkgo/ginkgo -r test/ -v
|
||||||
|
|
||||||
.PHONY: test_local
|
.PHONY: test_local
|
||||||
test_local: | $(GINKGO) $(GOOSE)
|
test_local: | $(GOOSE)
|
||||||
go vet ./...
|
go vet ./...
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
./scripts/run_unit_test.sh
|
./scripts/run_unit_test.sh
|
||||||
|
|
||||||
.PHONY: integrationtest_local
|
|
||||||
integrationtest_local: | $(GINKGO) $(GOOSE)
|
|
||||||
go vet ./...
|
|
||||||
go fmt ./...
|
|
||||||
./scripts/run_integration_test.sh
|
|
||||||
./scripts/run_integration_test_forward_eth_calls.sh
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
GO111MODULE=on go build
|
GO111MODULE=on go build
|
||||||
@@ -145,4 +135,4 @@ import:
|
|||||||
## Build docker image
|
## Build docker image
|
||||||
.PHONY: docker-build
|
.PHONY: docker-build
|
||||||
docker-build:
|
docker-build:
|
||||||
docker build -t vulcanize/ipld-eth-server .
|
docker build -t cerc-io/ipld-eth-server .
|
||||||
|
|||||||
@@ -22,20 +22,20 @@ Additional, unique endpoints are exposed which utilize the new indexes and state
|
|||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
Minimal build dependencies
|
Minimal build dependencies
|
||||||
* Go (1.13)
|
* Go (1.18)
|
||||||
* Git
|
* Git
|
||||||
* GCC compiler
|
* GCC compiler
|
||||||
* This repository
|
* This repository
|
||||||
|
|
||||||
External dependency
|
External dependency
|
||||||
* Postgres database populated by [ipld-eth-indexer](https://github.com/vulcanize/ipld-eth-indexer)
|
* Postgres database populated by [ipld-eth-db](https://github.com/cerc-io/ipld-eth-db)
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
Start by downloading ipld-eth-server and moving into the repo:
|
Start by downloading ipld-eth-server and moving into the repo:
|
||||||
|
|
||||||
`GO111MODULE=off go get -d github.com/vulcanize/ipld-eth-server`
|
`GO111MODULE=off go get -d github.com/cerc-io/ipld-eth-server/v4`
|
||||||
|
|
||||||
`cd $GOPATH/src/github.com/vulcanize/ipld-eth-server`
|
`cd $GOPATH/src/github.com/cerc-io/ipld-eth-server/v4@v4.x.x`
|
||||||
|
|
||||||
Then, build the binary:
|
Then, build the binary:
|
||||||
|
|
||||||
@@ -148,8 +148,8 @@ TODO: Add the rest of the standard endpoints and unique endpoints (e.g. getSlice
|
|||||||
|
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
`make test` will run the unit tests
|
|
||||||
`make test` setups a clean `vulcanize_testing` db
|
Follow steps in [test/README.md](./test/README.md)
|
||||||
|
|
||||||
## Monitoring
|
## Monitoring
|
||||||
|
|
||||||
|
|||||||
+30
-7
@@ -19,16 +19,20 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/prom"
|
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/prom"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cfgFile string
|
cfgFile string
|
||||||
|
envFile string
|
||||||
subCommand string
|
subCommand string
|
||||||
logWithCommand log.Entry
|
logWithCommand log.Entry
|
||||||
)
|
)
|
||||||
@@ -99,6 +103,7 @@ func init() {
|
|||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file location")
|
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file location")
|
||||||
|
rootCmd.PersistentFlags().StringVar(&envFile, "env", "", "environment file location")
|
||||||
|
|
||||||
rootCmd.PersistentFlags().String("client-ipcPath", "", "location of geth.ipc file")
|
rootCmd.PersistentFlags().String("client-ipcPath", "", "location of geth.ipc file")
|
||||||
rootCmd.PersistentFlags().String("log-level", log.InfoLevel.String(), "log level (trace, debug, info, warn, error, fatal, panic)")
|
rootCmd.PersistentFlags().String("log-level", log.InfoLevel.String(), "log level (trace, debug, info, warn, error, fatal, panic)")
|
||||||
@@ -121,14 +126,32 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initConfig() {
|
func initConfig() {
|
||||||
|
if cfgFile == "" && envFile == "" {
|
||||||
|
log.Fatal("No configuration file specified, use --config , --env flag to provide configuration")
|
||||||
|
}
|
||||||
|
|
||||||
if cfgFile != "" {
|
if cfgFile != "" {
|
||||||
|
if filepath.Ext(cfgFile) != ".toml" {
|
||||||
|
log.Fatal("Provide .toml file for --config flag")
|
||||||
|
}
|
||||||
|
|
||||||
viper.SetConfigFile(cfgFile)
|
viper.SetConfigFile(cfgFile)
|
||||||
if err := viper.ReadInConfig(); err == nil {
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
log.Printf("Using config file: %s", viper.ConfigFileUsed())
|
log.Fatalf("Couldn't read config file: %s", err.Error())
|
||||||
} else {
|
|
||||||
log.Fatal(fmt.Sprintf("Couldn't read config file: %s", err.Error()))
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.Warn("No config file passed with --config flag")
|
log.Infof("Using config file: %s", viper.ConfigFileUsed())
|
||||||
|
}
|
||||||
|
|
||||||
|
if envFile != "" {
|
||||||
|
if filepath.Ext(envFile) != ".env" {
|
||||||
|
log.Fatal("Provide .env file for --env flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := godotenv.Load(envFile); err != nil {
|
||||||
|
log.Fatalf("Failed to set environment variable from env file: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("Using env file: %s", envFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -17,6 +17,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/mailgun/groupcache/v2"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@@ -26,17 +27,16 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/mailgun/groupcache/v2"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/vulcanize/gap-filler/pkg/mux"
|
"github.com/vulcanize/gap-filler/pkg/mux"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/graphql"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/graphql"
|
||||||
srpc "github.com/vulcanize/ipld-eth-server/pkg/rpc"
|
srpc "github.com/cerc-io/ipld-eth-server/v4/pkg/rpc"
|
||||||
s "github.com/vulcanize/ipld-eth-server/pkg/serve"
|
s "github.com/cerc-io/ipld-eth-server/v4/pkg/serve"
|
||||||
v "github.com/vulcanize/ipld-eth-server/version"
|
v "github.com/cerc-io/ipld-eth-server/v4/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrNoRpcEndpoints = errors.New("no rpc endpoints is available")
|
var ErrNoRpcEndpoints = errors.New("no rpc endpoints is available")
|
||||||
@@ -123,7 +123,7 @@ func startServers(server s.Server, settings *s.Config) error {
|
|||||||
|
|
||||||
if settings.WSEnabled {
|
if settings.WSEnabled {
|
||||||
logWithCommand.Info("starting up WS server")
|
logWithCommand.Info("starting up WS server")
|
||||||
_, _, err := srpc.StartWSEndpoint(settings.WSEndpoint, server.APIs(), []string{"vdb", "net"}, nil, true)
|
_, _, err := srpc.StartWSEndpoint(settings.WSEndpoint, server.APIs(), []string{"vdb", "net"}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ func startServers(server s.Server, settings *s.Config) error {
|
|||||||
|
|
||||||
if settings.HTTPEnabled {
|
if settings.HTTPEnabled {
|
||||||
logWithCommand.Info("starting up HTTP server")
|
logWithCommand.Info("starting up HTTP server")
|
||||||
_, err := srpc.StartHTTPEndpoint(settings.HTTPEndpoint, server.APIs(), []string{"eth", "net"}, nil, []string{"*"}, rpc.HTTPTimeouts{})
|
_, err := srpc.StartHTTPEndpoint(settings.HTTPEndpoint, server.APIs(), []string{"vdb", "eth", "net"}, nil, []string{"*"}, rpc.HTTPTimeouts{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -27,9 +27,9 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/client"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/client"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
w "github.com/vulcanize/ipld-eth-server/pkg/serve"
|
w "github.com/cerc-io/ipld-eth-server/v4/pkg/serve"
|
||||||
)
|
)
|
||||||
|
|
||||||
// subscribeCmd represents the subscribe command
|
// subscribeCmd represents the subscribe command
|
||||||
|
|||||||
+4
-4
@@ -18,14 +18,14 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
validator "github.com/cerc-io/eth-ipfs-state-validator/v4/pkg"
|
||||||
|
ipfsethdb "github.com/cerc-io/ipfs-ethdb/v4/postgres"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
validator "github.com/vulcanize/eth-ipfs-state-validator/pkg"
|
|
||||||
ipfsethdb "github.com/vulcanize/ipfs-ethdb/postgres"
|
|
||||||
|
|
||||||
s "github.com/vulcanize/ipld-eth-server/pkg/serve"
|
s "github.com/cerc-io/ipld-eth-server/v4/pkg/serve"
|
||||||
)
|
)
|
||||||
|
|
||||||
const GroupName = "statedb-validate"
|
const GroupName = "statedb-validate"
|
||||||
@@ -57,7 +57,7 @@ func validate() {
|
|||||||
stateRoot := common.HexToHash(stateRootStr)
|
stateRoot := common.HexToHash(stateRootStr)
|
||||||
cacheSize := viper.GetInt("cacheSize")
|
cacheSize := viper.GetInt("cacheSize")
|
||||||
|
|
||||||
ethDB := ipfsethdb.NewDatabase(config.DB.DB, ipfsethdb.CacheConfig{
|
ethDB := ipfsethdb.NewDatabase(config.DB, ipfsethdb.CacheConfig{
|
||||||
Name: GroupName,
|
Name: GroupName,
|
||||||
Size: cacheSize * 1024 * 1024,
|
Size: cacheSize * 1024 * 1024,
|
||||||
ExpiryDuration: time.Minute * time.Duration(CacheExpiryInMins),
|
ExpiryDuration: time.Minute * time.Duration(CacheExpiryInMins),
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
v "github.com/vulcanize/ipld-eth-server/version"
|
v "github.com/cerc-io/ipld-eth-server/v4/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
// versionCmd represents the version command
|
// versionCmd represents the version command
|
||||||
|
|||||||
@@ -2,13 +2,11 @@ version: '3.2'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
contract:
|
contract:
|
||||||
depends_on:
|
|
||||||
- dapptools
|
|
||||||
build:
|
build:
|
||||||
context: ./test/contract
|
context: ./test/contract
|
||||||
args:
|
args:
|
||||||
ETH_ADDR: "http://dapptools:8545"
|
ETH_ADDR: "http://go-ethereum:8545"
|
||||||
environment:
|
environment:
|
||||||
ETH_ADDR: "http://dapptools:8545"
|
ETH_ADDR: "http://go-ethereum:8545"
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:3000:3000"
|
- "127.0.0.1:3000:3000"
|
||||||
|
|||||||
+10
-31
@@ -1,34 +1,28 @@
|
|||||||
version: '3.2'
|
version: '3.2'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
dapptools:
|
migrations:
|
||||||
restart: unless-stopped
|
restart: on-failure
|
||||||
depends_on:
|
depends_on:
|
||||||
- ipld-eth-db
|
- ipld-eth-db
|
||||||
image: vulcanize/dapptools:v0.30.0-v1.10.14-statediff-0.0.29
|
image: git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:v4.2.1-alpha-unstable
|
||||||
environment:
|
environment:
|
||||||
DB_USER: vdbm
|
DATABASE_USER: "vdbm"
|
||||||
DB_NAME: vulcanize_testing
|
DATABASE_NAME: "vulcanize_testing"
|
||||||
DB_HOST: ipld-eth-db
|
DATABASE_PASSWORD: "password"
|
||||||
DB_PORT: 5432
|
DATABASE_HOSTNAME: "ipld-eth-db"
|
||||||
DB_PASSWORD: password
|
DATABASE_PORT: 5432
|
||||||
DB_WRITE: $DB_WRITE
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:8545:8545"
|
|
||||||
- "127.0.0.1:8546:8546"
|
|
||||||
|
|
||||||
ipld-eth-db:
|
ipld-eth-db:
|
||||||
|
image: timescale/timescaledb:latest-pg14
|
||||||
restart: always
|
restart: always
|
||||||
image: vulcanize/ipld-eth-db:v0.2.0
|
command: ["postgres", "-c", "log_statement=all"]
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: "vdbm"
|
POSTGRES_USER: "vdbm"
|
||||||
POSTGRES_DB: "vulcanize_testing"
|
POSTGRES_DB: "vulcanize_testing"
|
||||||
POSTGRES_PASSWORD: "password"
|
POSTGRES_PASSWORD: "password"
|
||||||
volumes:
|
|
||||||
- vdb_db_eth_server:/var/lib/postgresql/data
|
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:8077:5432"
|
- "127.0.0.1:8077:5432"
|
||||||
command: ["postgres", "-c", "log_statement=all"]
|
|
||||||
|
|
||||||
eth-server:
|
eth-server:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -61,20 +55,5 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:8081:8081"
|
- "127.0.0.1:8081:8081"
|
||||||
|
|
||||||
graphql:
|
|
||||||
restart: unless-stopped
|
|
||||||
depends_on:
|
|
||||||
- ipld-eth-db
|
|
||||||
image: vulcanize/postgraphile:v1.0.1
|
|
||||||
environment:
|
|
||||||
- PG_HOST=db
|
|
||||||
- PG_PORT=5432
|
|
||||||
- PG_DATABASE=vulcanize_public
|
|
||||||
- PG_USER=vdbm
|
|
||||||
- PG_PASSWORD=password
|
|
||||||
- SCHEMA=public,eth
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:5000:5000"
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
vdb_db_eth_server:
|
vdb_db_eth_server:
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ An example of how to subscribe to a real-time Ethereum data feed from ipld-eth-s
|
|||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/client"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/client"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/watch"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/watch"
|
||||||
)
|
)
|
||||||
|
|
||||||
config, _ := eth.NewEthSubscriptionConfig()
|
config, _ := eth.NewEthSubscriptionConfig()
|
||||||
@@ -160,9 +160,9 @@ An example of how to subscribe to a real-time Bitcoin data feed from ipld-eth-se
|
|||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/btc"
|
"github.com/vulcanize/ipld-eth-server/v4/pkg/btc"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/client"
|
"github.com/vulcanize/ipld-eth-server/v4/pkg/client"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/watch"
|
"github.com/vulcanize/ipld-eth-server/v4/pkg/watch"
|
||||||
)
|
)
|
||||||
|
|
||||||
config, _ := btc.NewBtcSubscriptionConfig()
|
config, _ := btc.NewBtcSubscriptionConfig()
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
graphqlEndpoint = "127.0.0.1:8083" # $SERVER_GRAPHQL_ENDPOINT
|
graphqlEndpoint = "127.0.0.1:8083" # $SERVER_GRAPHQL_ENDPOINT
|
||||||
|
|
||||||
[ethereum]
|
[ethereum]
|
||||||
|
chainConfig = "./chain.json" # ETH_CHAIN_CONFIG
|
||||||
chainID = "1" # $ETH_CHAIN_ID
|
chainID = "1" # $ETH_CHAIN_ID
|
||||||
defaultSender = "" # $ETH_DEFAULT_SENDER_ADDR
|
defaultSender = "" # $ETH_DEFAULT_SENDER_ADDR
|
||||||
rpcGasCap = "1000000000000" # $ETH_RPC_GAS_CAP
|
rpcGasCap = "1000000000000" # $ETH_RPC_GAS_CAP
|
||||||
|
|||||||
@@ -1,38 +1,296 @@
|
|||||||
module github.com/vulcanize/ipld-eth-server
|
module github.com/cerc-io/ipld-eth-server/v4
|
||||||
|
|
||||||
go 1.15
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ethereum/go-ethereum v1.10.14
|
github.com/cerc-io/eth-ipfs-state-validator/v4 v4.0.8-alpha
|
||||||
github.com/fsnotify/fsnotify v1.5.1 // indirect
|
github.com/cerc-io/ipfs-ethdb/v4 v4.0.8-alpha
|
||||||
github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29
|
github.com/ethereum/go-ethereum v1.10.23
|
||||||
|
github.com/graph-gophers/graphql-go v1.3.0
|
||||||
github.com/ipfs/go-block-format v0.0.3
|
github.com/ipfs/go-block-format v0.0.3
|
||||||
github.com/ipfs/go-blockservice v0.1.7
|
github.com/ipfs/go-cid v0.2.0
|
||||||
github.com/ipfs/go-cid v0.0.7
|
github.com/ipfs/go-ipfs-blockstore v1.2.0
|
||||||
github.com/ipfs/go-ipfs v0.10.0
|
github.com/ipfs/go-ipfs-ds-help v1.1.0
|
||||||
github.com/ipfs/go-ipfs-blockstore v1.0.1
|
github.com/jmoiron/sqlx v1.3.5
|
||||||
github.com/ipfs/go-ipfs-ds-help v1.0.0
|
github.com/joho/godotenv v1.4.0
|
||||||
github.com/ipfs/go-ipld-format v0.2.0
|
github.com/lib/pq v1.10.6
|
||||||
github.com/jmoiron/sqlx v1.2.0
|
|
||||||
github.com/lib/pq v1.10.4
|
|
||||||
github.com/machinebox/graphql v0.2.2
|
github.com/machinebox/graphql v0.2.2
|
||||||
github.com/mailgun/groupcache/v2 v2.2.1
|
github.com/mailgun/groupcache/v2 v2.3.0
|
||||||
github.com/matryer/is v1.4.0 // indirect
|
github.com/multiformats/go-multihash v0.2.0
|
||||||
github.com/multiformats/go-multihash v0.0.15
|
|
||||||
github.com/onsi/ginkgo v1.16.5
|
github.com/onsi/ginkgo v1.16.5
|
||||||
github.com/onsi/gomega v1.13.0
|
github.com/onsi/gomega v1.19.0
|
||||||
github.com/prometheus/client_golang v1.11.0
|
github.com/prometheus/client_golang v1.12.1
|
||||||
github.com/shirou/gopsutil v3.21.5+incompatible // indirect
|
github.com/sirupsen/logrus v1.9.0
|
||||||
github.com/sirupsen/logrus v1.7.0
|
github.com/spf13/cobra v1.4.0
|
||||||
github.com/spf13/cobra v1.1.1
|
github.com/spf13/viper v1.11.0
|
||||||
github.com/spf13/viper v1.7.0
|
github.com/vulcanize/gap-filler v0.4.0
|
||||||
github.com/tklauser/go-sysconf v0.3.6 // indirect
|
gorm.io/driver/postgres v1.3.7
|
||||||
github.com/vulcanize/eth-ipfs-state-validator v0.1.0
|
gorm.io/gorm v1.23.5
|
||||||
github.com/vulcanize/gap-filler v0.3.1
|
|
||||||
github.com/vulcanize/ipfs-ethdb v0.0.6
|
|
||||||
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e // indirect
|
|
||||||
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
|
|
||||||
golang.org/x/tools v0.1.8 // indirect
|
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/ethereum/go-ethereum v1.10.14 => github.com/vulcanize/go-ethereum v1.10.14-statediff-0.0.29
|
require (
|
||||||
|
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc // indirect
|
||||||
|
github.com/Stebalien/go-bitfield v0.0.1 // 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/beorn7/perks v1.0.1 // indirect
|
||||||
|
github.com/blang/semver/v4 v4.0.0 // indirect
|
||||||
|
github.com/btcsuite/btcd v0.22.1 // indirect
|
||||||
|
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
|
||||||
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
||||||
|
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
||||||
|
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||||
|
github.com/cerc-io/go-eth-state-node-iterator v1.1.7 // indirect
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||||
|
github.com/cheekybits/genny v1.0.0 // indirect
|
||||||
|
github.com/containerd/cgroups v1.0.3 // indirect
|
||||||
|
github.com/coreos/go-systemd/v22 v22.3.2 // 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 v1.8.0 // indirect
|
||||||
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||||
|
github.com/deepmap/oapi-codegen v1.8.2 // indirect
|
||||||
|
github.com/docker/go-units v0.4.0 // indirect
|
||||||
|
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||||
|
github.com/edsrzf/mmap-go v1.0.0 // indirect
|
||||||
|
github.com/elastic/gosigar v0.14.2 // indirect
|
||||||
|
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
|
||||||
|
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
|
||||||
|
github.com/flynn/noise v1.0.0 // indirect
|
||||||
|
github.com/francoispqt/gojay v1.2.13 // indirect
|
||||||
|
github.com/friendsofgo/graphiql v0.2.2 // indirect
|
||||||
|
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||||
|
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
|
||||||
|
github.com/georgysavva/scany v0.2.9 // indirect
|
||||||
|
github.com/go-logr/logr v1.2.3 // 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.0 // indirect
|
||||||
|
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
|
||||||
|
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||||
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
|
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
|
||||||
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
|
github.com/google/gopacket v1.1.19 // indirect
|
||||||
|
github.com/google/uuid v1.3.0 // indirect
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f // indirect
|
||||||
|
github.com/gorilla/websocket v1.5.0 // indirect
|
||||||
|
github.com/graphql-go/graphql v0.7.9 // 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-multierror v1.1.1 // indirect
|
||||||
|
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
|
||||||
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
|
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||||
|
github.com/holiman/uint256 v1.2.0 // indirect
|
||||||
|
github.com/huin/goupnp v1.0.3 // indirect
|
||||||
|
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||||
|
github.com/influxdata/influxdb v1.8.3 // indirect
|
||||||
|
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // 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.8.0 // indirect
|
||||||
|
github.com/ipfs/go-blockservice v0.4.0 // indirect
|
||||||
|
github.com/ipfs/go-cidutil v0.1.0 // indirect
|
||||||
|
github.com/ipfs/go-datastore v0.5.1 // indirect
|
||||||
|
github.com/ipfs/go-delegated-routing v0.3.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.13.1 // indirect
|
||||||
|
github.com/ipfs/go-ipfs-chunker v0.0.5 // indirect
|
||||||
|
github.com/ipfs/go-ipfs-delay v0.0.1 // 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-files v0.1.1 // indirect
|
||||||
|
github.com/ipfs/go-ipfs-keystore v0.0.2 // 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.7.1 // indirect
|
||||||
|
github.com/ipfs/go-ipfs-routing v0.2.1 // indirect
|
||||||
|
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
|
||||||
|
github.com/ipfs/go-ipld-cbor v0.0.5 // 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.1.2 // 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.6.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.5.0 // indirect
|
||||||
|
github.com/ipfs/go-path v0.3.0 // indirect
|
||||||
|
github.com/ipfs/go-peertaskqueue v0.7.1 // indirect
|
||||||
|
github.com/ipfs/go-unixfs v0.4.0 // indirect
|
||||||
|
github.com/ipfs/go-unixfsnode v1.4.0 // indirect
|
||||||
|
github.com/ipfs/go-verifcid v0.0.1 // indirect
|
||||||
|
github.com/ipfs/interface-go-ipfs-core v0.7.0 // indirect
|
||||||
|
github.com/ipfs/kubo v0.14.0 // indirect
|
||||||
|
github.com/ipld/edelweiss v0.1.4 // indirect
|
||||||
|
github.com/ipld/go-codec-dagpb v1.4.0 // indirect
|
||||||
|
github.com/ipld/go-ipld-prime v0.17.0 // indirect
|
||||||
|
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||||
|
github.com/jackc/pgconn v1.12.1 // indirect
|
||||||
|
github.com/jackc/pgio v1.0.0 // indirect
|
||||||
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
|
github.com/jackc/pgproto3/v2 v2.3.0 // indirect
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
|
||||||
|
github.com/jackc/pgtype v1.11.0 // indirect
|
||||||
|
github.com/jackc/pgx/v4 v4.16.1 // indirect
|
||||||
|
github.com/jackc/puddle v1.2.1 // indirect
|
||||||
|
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
|
||||||
|
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
|
||||||
|
github.com/jbenet/goprocess v0.1.4 // indirect
|
||||||
|
github.com/jinzhu/copier v0.2.4 // indirect
|
||||||
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
|
github.com/jinzhu/now v1.1.4 // indirect
|
||||||
|
github.com/klauspost/compress v1.15.1 // indirect
|
||||||
|
github.com/klauspost/cpuid/v2 v2.0.12 // indirect
|
||||||
|
github.com/koron/go-ssdp v0.0.2 // indirect
|
||||||
|
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
|
||||||
|
github.com/libp2p/go-cidranger v1.1.0 // indirect
|
||||||
|
github.com/libp2p/go-doh-resolver v0.4.0 // indirect
|
||||||
|
github.com/libp2p/go-eventbus v0.2.1 // indirect
|
||||||
|
github.com/libp2p/go-flow-metrics v0.0.3 // indirect
|
||||||
|
github.com/libp2p/go-libp2p v0.20.3 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-core v0.16.1 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-discovery v0.7.0 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-kad-dht v0.16.0 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-kbucket v0.4.7 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-loggables v0.1.0 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-peerstore v0.6.0 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-pubsub v0.6.1 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-pubsub-router v0.5.0 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-record v0.1.3 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-resource-manager v0.3.0 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-routing-helpers v0.2.3 // indirect
|
||||||
|
github.com/libp2p/go-libp2p-swarm v0.11.0 // 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-netroute v0.2.0 // indirect
|
||||||
|
github.com/libp2p/go-openssl v0.0.7 // indirect
|
||||||
|
github.com/libp2p/go-reuseport v0.2.0 // indirect
|
||||||
|
github.com/libp2p/go-yamux/v3 v3.1.2 // indirect
|
||||||
|
github.com/libp2p/zeroconf/v2 v2.1.1 // indirect
|
||||||
|
github.com/lucas-clemente/quic-go v0.27.1 // indirect
|
||||||
|
github.com/magiconair/properties v1.8.6 // indirect
|
||||||
|
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
|
||||||
|
github.com/marten-seemann/qtls-go1-17 v0.1.1 // indirect
|
||||||
|
github.com/marten-seemann/qtls-go1-18 v0.1.1 // indirect
|
||||||
|
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
|
||||||
|
github.com/matryer/is v1.4.0 // indirect
|
||||||
|
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||||
|
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||||
|
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||||
|
github.com/miekg/dns v1.1.48 // 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/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/mr-tron/base58 v1.2.0 // indirect
|
||||||
|
github.com/multiformats/go-base32 v0.0.4 // indirect
|
||||||
|
github.com/multiformats/go-base36 v0.1.0 // indirect
|
||||||
|
github.com/multiformats/go-multiaddr v0.5.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.0 // indirect
|
||||||
|
github.com/multiformats/go-multicodec v0.5.0 // indirect
|
||||||
|
github.com/multiformats/go-multistream v0.3.3 // indirect
|
||||||
|
github.com/multiformats/go-varint v0.0.6 // indirect
|
||||||
|
github.com/nxadm/tail v1.4.8 // indirect
|
||||||
|
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||||
|
github.com/opencontainers/runtime-spec v1.0.2 // 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.0-beta.8 // 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/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.2.0 // indirect
|
||||||
|
github.com/prometheus/common v0.33.0 // indirect
|
||||||
|
github.com/prometheus/procfs v0.7.3 // indirect
|
||||||
|
github.com/prometheus/tsdb v0.10.0 // indirect
|
||||||
|
github.com/raulk/clock v1.1.0 // indirect
|
||||||
|
github.com/raulk/go-watchdog v1.2.0 // indirect
|
||||||
|
github.com/rjeczalik/notify v0.9.1 // indirect
|
||||||
|
github.com/rs/cors v1.7.0 // indirect
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
|
github.com/segmentio/fasthash v1.0.3 // indirect
|
||||||
|
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
|
||||||
|
github.com/smartystreets/assertions v1.0.1 // 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
|
||||||
|
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||||
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
|
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 // indirect
|
||||||
|
github.com/stretchr/objx v0.2.0 // indirect
|
||||||
|
github.com/stretchr/testify v1.7.2 // 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/tidwall/gjson v1.14.0 // indirect
|
||||||
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
|
github.com/tidwall/pretty v1.2.0 // indirect
|
||||||
|
github.com/tklauser/go-sysconf v0.3.5 // indirect
|
||||||
|
github.com/tklauser/numcpus v0.2.2 // indirect
|
||||||
|
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef // indirect
|
||||||
|
github.com/urfave/cli/v2 v2.10.2 // indirect
|
||||||
|
github.com/valyala/fastjson v1.6.3 // indirect
|
||||||
|
github.com/wI2L/jsondiff v0.2.0 // indirect
|
||||||
|
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect
|
||||||
|
github.com/whyrusleeping/cbor-gen v0.0.0-20210219115102-f37d292932f2 // 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/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
|
||||||
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||||
|
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||||
|
go.opencensus.io v0.23.0 // indirect
|
||||||
|
go.opentelemetry.io/otel v1.7.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/trace v1.7.0 // indirect
|
||||||
|
go.uber.org/atomic v1.9.0 // indirect
|
||||||
|
go.uber.org/dig v1.14.0 // indirect
|
||||||
|
go.uber.org/fx v1.16.0 // indirect
|
||||||
|
go.uber.org/multierr v1.8.0 // indirect
|
||||||
|
go.uber.org/zap v1.21.0 // indirect
|
||||||
|
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
|
||||||
|
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
|
||||||
|
golang.org/x/net v0.0.0-20220607020251-c690dde0001d // indirect
|
||||||
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||||
|
golang.org/x/text v0.3.7 // indirect
|
||||||
|
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
|
||||||
|
golang.org/x/tools v0.1.10 // indirect
|
||||||
|
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
|
||||||
|
google.golang.org/protobuf v1.28.0 // indirect
|
||||||
|
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||||
|
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
lukechampine.com/blake3 v1.1.7 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
|
replace github.com/ethereum/go-ethereum v1.10.23 => github.com/cerc-io/go-ethereum v1.10.23-statediff-4.2.0-alpha
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/cmd"
|
"github.com/cerc-io/ipld-eth-server/v4/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -20,11 +20,10 @@ package client
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/serve"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/serve"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client is used to subscribe to the ipld-eth-server ipld data stream
|
// Client is used to subscribe to the ipld-eth-server ipld data stream
|
||||||
|
|||||||
+16
-14
@@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/statediff"
|
"github.com/ethereum/go-ethereum/statediff"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/shared"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
// APIName is the namespace for the watcher's eth api
|
// APIName is the namespace for the watcher's eth api
|
||||||
@@ -66,6 +66,9 @@ type PublicEthAPI struct {
|
|||||||
|
|
||||||
// NewPublicEthAPI creates a new PublicEthAPI with the provided underlying Backend
|
// NewPublicEthAPI creates a new PublicEthAPI with the provided underlying Backend
|
||||||
func NewPublicEthAPI(b *Backend, client *rpc.Client, supportsStateDiff, forwardEthCalls, proxyOnError bool) (*PublicEthAPI, error) {
|
func NewPublicEthAPI(b *Backend, client *rpc.Client, supportsStateDiff, forwardEthCalls, proxyOnError bool) (*PublicEthAPI, error) {
|
||||||
|
if b == nil {
|
||||||
|
return nil, errors.New("ipld-eth-server must be configured with an ethereum backend")
|
||||||
|
}
|
||||||
if forwardEthCalls && client == nil {
|
if forwardEthCalls && client == nil {
|
||||||
return nil, errors.New("ipld-eth-server is configured to forward eth_calls to proxy node but no proxy node is configured")
|
return nil, errors.New("ipld-eth-server is configured to forward eth_calls to proxy node but no proxy node is configured")
|
||||||
}
|
}
|
||||||
@@ -120,11 +123,10 @@ func (pea *PublicEthAPI) GetHeaderByHash(ctx context.Context, hash common.Hash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if pea.proxyOnError {
|
if pea.proxyOnError {
|
||||||
if header, err := pea.ethClient.HeaderByHash(ctx, hash); header != nil && err == nil {
|
var result map[string]interface{}
|
||||||
|
if err := pea.rpc.CallContext(ctx, &result, "eth_getHeaderByHash", hash); result != nil && err == nil {
|
||||||
go pea.writeStateDiffFor(hash)
|
go pea.writeStateDiffFor(hash)
|
||||||
if res, err := pea.rpcMarshalHeader(header); err != nil {
|
return result
|
||||||
return res
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +158,7 @@ func (pea *PublicEthAPI) BlockNumber() hexutil.Uint64 {
|
|||||||
// * When fullTx is true all transactions in the block are returned, otherwise
|
// * When fullTx is true all transactions in the block are returned, otherwise
|
||||||
// only the transaction hash is returned.
|
// only the transaction hash is returned.
|
||||||
func (pea *PublicEthAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) {
|
func (pea *PublicEthAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) {
|
||||||
|
logrus.Debug("Received getBlockByNumber request for number ", number.Int64())
|
||||||
block, err := pea.B.BlockByNumber(ctx, number)
|
block, err := pea.B.BlockByNumber(ctx, number)
|
||||||
if block != nil && err == nil {
|
if block != nil && err == nil {
|
||||||
return pea.rpcMarshalBlock(block, true, fullTx)
|
return pea.rpcMarshalBlock(block, true, fullTx)
|
||||||
@@ -174,6 +177,7 @@ func (pea *PublicEthAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockN
|
|||||||
// GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full
|
// GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full
|
||||||
// detail, otherwise only the transaction hash is returned.
|
// detail, otherwise only the transaction hash is returned.
|
||||||
func (pea *PublicEthAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error) {
|
func (pea *PublicEthAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error) {
|
||||||
|
logrus.Debug("Received getBlockByHash request for hash ", hash.Hex())
|
||||||
block, err := pea.B.BlockByHash(ctx, hash)
|
block, err := pea.B.BlockByHash(ctx, hash)
|
||||||
if block != nil && err == nil {
|
if block != nil && err == nil {
|
||||||
return pea.rpcMarshalBlock(block, true, fullTx)
|
return pea.rpcMarshalBlock(block, true, fullTx)
|
||||||
@@ -190,21 +194,17 @@ func (pea *PublicEthAPI) GetBlockByHash(ctx context.Context, hash common.Hash, f
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
|
// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
|
||||||
func (pea *PublicEthAPI) ChainId() (*hexutil.Big, error) {
|
func (pea *PublicEthAPI) ChainId() *hexutil.Big {
|
||||||
block, err := pea.B.CurrentBlock()
|
if pea.B.Config.ChainConfig.ChainID == nil || pea.B.Config.ChainConfig.ChainID.Cmp(big.NewInt(0)) <= 0 {
|
||||||
if err != nil {
|
|
||||||
if pea.proxyOnError {
|
if pea.proxyOnError {
|
||||||
if id, err := pea.ethClient.ChainID(context.Background()); err == nil {
|
if id, err := pea.ethClient.ChainID(context.Background()); err == nil {
|
||||||
return (*hexutil.Big)(id), nil
|
return (*hexutil.Big)(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if config := pea.B.Config.ChainConfig; config.IsEIP155(block.Number()) {
|
return (*hexutil.Big)(pea.B.Config.ChainConfig.ChainID)
|
||||||
return (*hexutil.Big)(config.ChainID), nil
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("chain not synced beyond EIP-155 replay-protection fork block")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1096,11 +1096,13 @@ func (pea *PublicEthAPI) writeStateDiffFor(blockHash common.Hash) {
|
|||||||
func (pea *PublicEthAPI) rpcMarshalBlock(b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) {
|
func (pea *PublicEthAPI) rpcMarshalBlock(b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) {
|
||||||
fields, err := RPCMarshalBlock(b, inclTx, fullTx)
|
fields, err := RPCMarshalBlock(b, inclTx, fullTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logrus.Errorf("error RPC marshalling block with hash %s: %s", b.Hash().String(), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if inclTx {
|
if inclTx {
|
||||||
td, err := pea.B.GetTd(b.Hash())
|
td, err := pea.B.GetTd(b.Hash())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logrus.Errorf("error getting td for block with hash and number %s, %s: %s", b.Hash().String(), b.Number().String(), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
fields["totalDifficulty"] = (*hexutil.Big)(td)
|
fields["totalDifficulty"] = (*hexutil.Big)(td)
|
||||||
|
|||||||
+43
-39
@@ -19,9 +19,12 @@ package eth_test
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth/test_helpers"
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
|
ethServerShared "github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
@@ -31,16 +34,11 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer"
|
"github.com/ethereum/go-ethereum/statediff/indexer/interfaces"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/node"
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
|
||||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth/test_helpers"
|
|
||||||
ethServerShared "github.com/vulcanize/ipld-eth-server/pkg/shared"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -183,22 +181,9 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetupDB is use to setup a db for watcher tests
|
|
||||||
func SetupDB() (*postgres.DB, error) {
|
|
||||||
port, _ := strconv.Atoi(os.Getenv("DATABASE_PORT"))
|
|
||||||
uri := postgres.DbConnectionString(postgres.ConnectionParams{
|
|
||||||
User: os.Getenv("DATABASE_USER"),
|
|
||||||
Password: os.Getenv("DATABASE_PASSWORD"),
|
|
||||||
Hostname: os.Getenv("DATABASE_HOSTNAME"),
|
|
||||||
Name: os.Getenv("DATABASE_NAME"),
|
|
||||||
Port: port,
|
|
||||||
})
|
|
||||||
return postgres.NewDB(uri, postgres.ConnectionConfig{}, node.Info{})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = Describe("API", func() {
|
var _ = Describe("API", func() {
|
||||||
var (
|
var (
|
||||||
db *postgres.DB
|
db *sqlx.DB
|
||||||
api *eth.PublicEthAPI
|
api *eth.PublicEthAPI
|
||||||
chainConfig = params.TestChainConfig
|
chainConfig = params.TestChainConfig
|
||||||
)
|
)
|
||||||
@@ -207,14 +192,12 @@ var _ = Describe("API", func() {
|
|||||||
It("test init", func() {
|
It("test init", func() {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
tx *indexer.BlockTx
|
tx interfaces.Batch
|
||||||
)
|
)
|
||||||
|
|
||||||
db, err = SetupDB()
|
db = shared.SetupDB()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
indexAndPublisher := shared.SetupTestStateDiffIndexer(ctx, chainConfig, test_helpers.Genesis.Hash())
|
||||||
|
|
||||||
indexAndPublisher, err := indexer.NewStateDiffIndexer(chainConfig, db)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
backend, err := eth.NewEthBackend(db, ð.Config{
|
backend, err := eth.NewEthBackend(db, ð.Config{
|
||||||
ChainConfig: chainConfig,
|
ChainConfig: chainConfig,
|
||||||
VMConfig: vm.Config{},
|
VMConfig: vm.Config{},
|
||||||
@@ -233,11 +216,6 @@ var _ = Describe("API", func() {
|
|||||||
tx, err = indexAndPublisher.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
tx, err = indexAndPublisher.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
for _, node := range test_helpers.MockStateNodes {
|
|
||||||
err = indexAndPublisher.PushStateNode(tx, node)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
}
|
|
||||||
|
|
||||||
ccHash := sdtypes.CodeAndCodeHash{
|
ccHash := sdtypes.CodeAndCodeHash{
|
||||||
Hash: test_helpers.ContractCodeHash,
|
Hash: test_helpers.ContractCodeHash,
|
||||||
Code: test_helpers.ContractCode,
|
Code: test_helpers.ContractCode,
|
||||||
@@ -246,7 +224,12 @@ var _ = Describe("API", func() {
|
|||||||
err = indexAndPublisher.PushCodeAndCodeHash(tx, ccHash)
|
err = indexAndPublisher.PushCodeAndCodeHash(tx, ccHash)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = tx.Close(err)
|
for _, node := range test_helpers.MockStateNodes {
|
||||||
|
err = indexAndPublisher.PushStateNode(tx, node, test_helpers.MockBlock.Hash().String())
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
}
|
||||||
|
|
||||||
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
uncles := test_helpers.MockBlock.Uncles()
|
uncles := test_helpers.MockBlock.Uncles()
|
||||||
@@ -258,18 +241,17 @@ var _ = Describe("API", func() {
|
|||||||
|
|
||||||
// setting chain config to for london block
|
// setting chain config to for london block
|
||||||
chainConfig.LondonBlock = big.NewInt(2)
|
chainConfig.LondonBlock = big.NewInt(2)
|
||||||
indexAndPublisher, err = indexer.NewStateDiffIndexer(chainConfig, db)
|
indexAndPublisher = shared.SetupTestStateDiffIndexer(ctx, chainConfig, test_helpers.Genesis.Hash())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
tx, err = indexAndPublisher.PushBlock(test_helpers.MockLondonBlock, test_helpers.MockLondonReceipts, test_helpers.MockLondonBlock.Difficulty())
|
tx, err = indexAndPublisher.PushBlock(test_helpers.MockLondonBlock, test_helpers.MockLondonReceipts, test_helpers.MockLondonBlock.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
// Single test db tear down at end of all tests
|
// Single test db tear down at end of all tests
|
||||||
defer It("test teardown", func() { eth.TearDownDB(db) })
|
defer It("test teardown", func() { shared.TearDownDB(db) })
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Headers and blocks
|
Headers and blocks
|
||||||
@@ -287,8 +269,6 @@ var _ = Describe("API", func() {
|
|||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
Expect(err.Error()).To(ContainSubstring("sql: no rows in result set"))
|
Expect(err.Error()).To(ContainSubstring("sql: no rows in result set"))
|
||||||
Expect(header).To(BeNil())
|
Expect(header).To(BeNil())
|
||||||
_, err = api.B.DB.Beginx()
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -353,6 +333,18 @@ var _ = Describe("API", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(block["baseFee"].(*big.Int)).To(Equal(baseFee))
|
Expect(block["baseFee"].(*big.Int)).To(Equal(baseFee))
|
||||||
})
|
})
|
||||||
|
It("Retrieves a block by number with uncles in correct order", func() {
|
||||||
|
block, err := api.GetBlockByNumber(ctx, londonBlockNum, false)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
expectedUncles := []common.Hash{
|
||||||
|
test_helpers.MockLondonUncles[0].Hash(),
|
||||||
|
test_helpers.MockLondonUncles[1].Hash(),
|
||||||
|
}
|
||||||
|
Expect(block["uncles"]).To(Equal(expectedUncles))
|
||||||
|
Expect(block["sha3Uncles"]).To(Equal(test_helpers.MockLondonBlock.UncleHash()))
|
||||||
|
Expect(block["hash"]).To(Equal(test_helpers.MockLondonBlock.Hash()))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("eth_getBlockByHash", func() {
|
Describe("eth_getBlockByHash", func() {
|
||||||
@@ -394,6 +386,18 @@ var _ = Describe("API", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(block["baseFee"].(*big.Int)).To(Equal(baseFee))
|
Expect(block["baseFee"].(*big.Int)).To(Equal(baseFee))
|
||||||
})
|
})
|
||||||
|
It("Retrieves a block by hash with uncles in correct order", func() {
|
||||||
|
block, err := api.GetBlockByHash(ctx, test_helpers.MockLondonBlock.Hash(), false)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
expectedUncles := []common.Hash{
|
||||||
|
test_helpers.MockLondonUncles[0].Hash(),
|
||||||
|
test_helpers.MockLondonUncles[1].Hash(),
|
||||||
|
}
|
||||||
|
Expect(block["uncles"]).To(Equal(expectedUncles))
|
||||||
|
Expect(block["sha3Uncles"]).To(Equal(test_helpers.MockLondonBlock.UncleHash()))
|
||||||
|
Expect(block["hash"]).To(Equal(test_helpers.MockLondonBlock.Hash()))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+212
-194
@@ -24,6 +24,8 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
validator "github.com/cerc-io/eth-ipfs-state-validator/v4/pkg"
|
||||||
|
ipfsethdb "github.com/cerc-io/ipfs-ethdb/v4/postgres"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/consensus"
|
"github.com/ethereum/go-ethereum/consensus"
|
||||||
@@ -39,15 +41,13 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs"
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
|
||||||
ethServerShared "github.com/ethereum/go-ethereum/statediff/indexer/shared"
|
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
validator "github.com/vulcanize/eth-ipfs-state-validator/pkg"
|
|
||||||
ipfsethdb "github.com/vulcanize/ipfs-ethdb/postgres"
|
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/shared"
|
ethServerShared "github.com/ethereum/go-ethereum/statediff/indexer/shared"
|
||||||
|
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -55,34 +55,44 @@ var (
|
|||||||
errNegativeBlockNumber = errors.New("negative block number not supported")
|
errNegativeBlockNumber = errors.New("negative block number not supported")
|
||||||
errHeaderHashNotFound = errors.New("header for hash not found")
|
errHeaderHashNotFound = errors.New("header for hash not found")
|
||||||
errHeaderNotFound = errors.New("header not found")
|
errHeaderNotFound = errors.New("header not found")
|
||||||
|
errMultipleHeadersForHash = errors.New("more than one headers for the given hash")
|
||||||
|
errTxHashNotFound = errors.New("transaction for hash not found")
|
||||||
|
errTxHashInMultipleBlocks = errors.New("transaction for hash found in more than one canonical block")
|
||||||
|
|
||||||
// errMissingSignature is returned if a block's extra-data section doesn't seem
|
// errMissingSignature is returned if a block's extra-data section doesn't seem
|
||||||
// to contain a 65 byte secp256k1 signature.
|
// to contain a 65 byte secp256k1 signature.
|
||||||
errMissingSignature = errors.New("extra-data 65 byte signature suffix missing")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RetrieveCanonicalBlockHashByNumber = `SELECT block_hash FROM eth.header_cids
|
RetrieveCanonicalBlockHashByNumber = `SELECT block_hash
|
||||||
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
|
FROM canonical_header_hash($1) AS block_hash
|
||||||
WHERE id = (SELECT canonical_header_id($1))`
|
WHERE block_hash IS NOT NULL`
|
||||||
RetrieveCanonicalHeaderByNumber = `SELECT cid, data FROM eth.header_cids
|
RetrieveCanonicalHeaderByNumber = `SELECT cid, data FROM eth.header_cids
|
||||||
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
|
INNER JOIN public.blocks ON (
|
||||||
WHERE id = (SELECT canonical_header_id($1))`
|
header_cids.mh_key = blocks.key
|
||||||
RetrieveTD = `SELECT td FROM eth.header_cids
|
AND header_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
|
WHERE block_hash = (SELECT canonical_header_hash($1))`
|
||||||
|
RetrieveTD = `SELECT CAST(td as Text) FROM eth.header_cids
|
||||||
WHERE header_cids.block_hash = $1`
|
WHERE header_cids.block_hash = $1`
|
||||||
RetrieveRPCTransaction = `SELECT blocks.data, block_hash, block_number, index FROM public.blocks, eth.transaction_cids, eth.header_cids
|
RetrieveRPCTransaction = `SELECT blocks.data, header_id, transaction_cids.block_number, index
|
||||||
|
FROM public.blocks, eth.transaction_cids
|
||||||
WHERE blocks.key = transaction_cids.mh_key
|
WHERE blocks.key = transaction_cids.mh_key
|
||||||
AND transaction_cids.header_id = header_cids.id
|
AND blocks.block_number = transaction_cids.block_number
|
||||||
AND transaction_cids.tx_hash = $1`
|
AND transaction_cids.tx_hash = $1
|
||||||
|
AND transaction_cids.header_id = (SELECT canonical_header_hash(transaction_cids.block_number))`
|
||||||
RetrieveCodeHashByLeafKeyAndBlockHash = `SELECT code_hash FROM eth.state_accounts, eth.state_cids, eth.header_cids
|
RetrieveCodeHashByLeafKeyAndBlockHash = `SELECT code_hash FROM eth.state_accounts, eth.state_cids, eth.header_cids
|
||||||
WHERE state_accounts.state_id = state_cids.id
|
WHERE state_accounts.header_id = state_cids.header_id
|
||||||
AND state_cids.header_id = header_cids.id
|
AND state_accounts.state_path = state_cids.state_path
|
||||||
|
AND state_accounts.block_number = state_cids.block_number
|
||||||
|
AND state_cids.header_id = header_cids.block_hash
|
||||||
|
AND state_cids.block_number = header_cids.block_number
|
||||||
AND state_leaf_key = $1
|
AND state_leaf_key = $1
|
||||||
AND block_number <= (SELECT block_number
|
AND header_cids.block_number <= (SELECT block_number
|
||||||
FROM eth.header_cids
|
FROM eth.header_cids
|
||||||
WHERE block_hash = $2)
|
WHERE block_hash = $2)
|
||||||
AND header_cids.id = (SELECT canonical_header_id(block_number))
|
AND header_cids.block_hash = (SELECT canonical_header_hash(header_cids.block_number))
|
||||||
ORDER BY block_number DESC
|
ORDER BY header_cids.block_number DESC
|
||||||
LIMIT 1`
|
LIMIT 1`
|
||||||
RetrieveCodeByMhKey = `SELECT data FROM public.blocks WHERE key = $1`
|
RetrieveCodeByMhKey = `SELECT data FROM public.blocks WHERE key = $1`
|
||||||
)
|
)
|
||||||
@@ -93,7 +103,7 @@ const (
|
|||||||
|
|
||||||
type Backend struct {
|
type Backend struct {
|
||||||
// underlying postgres db
|
// underlying postgres db
|
||||||
DB *postgres.DB
|
DB *sqlx.DB
|
||||||
|
|
||||||
// postgres db interfaces
|
// postgres db interfaces
|
||||||
Retriever *CIDRetriever
|
Retriever *CIDRetriever
|
||||||
@@ -115,7 +125,7 @@ type Config struct {
|
|||||||
GroupCacheConfig *shared.GroupCacheConfig
|
GroupCacheConfig *shared.GroupCacheConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEthBackend(db *postgres.DB, c *Config) (*Backend, error) {
|
func NewEthBackend(db *sqlx.DB, c *Config) (*Backend, error) {
|
||||||
gcc := c.GroupCacheConfig
|
gcc := c.GroupCacheConfig
|
||||||
|
|
||||||
groupName := gcc.StateDB.Name
|
groupName := gcc.StateDB.Name
|
||||||
@@ -124,7 +134,7 @@ func NewEthBackend(db *postgres.DB, c *Config) (*Backend, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := NewCIDRetriever(db)
|
r := NewCIDRetriever(db)
|
||||||
ethDB := ipfsethdb.NewDatabase(db.DB, ipfsethdb.CacheConfig{
|
ethDB := ipfsethdb.NewDatabase(db, ipfsethdb.CacheConfig{
|
||||||
Name: groupName,
|
Name: groupName,
|
||||||
Size: gcc.StateDB.CacheSizeInMB * 1024 * 1024,
|
Size: gcc.StateDB.CacheSizeInMB * 1024 * 1024,
|
||||||
ExpiryDuration: time.Minute * time.Duration(gcc.StateDB.CacheExpiryInMins),
|
ExpiryDuration: time.Minute * time.Duration(gcc.StateDB.CacheExpiryInMins),
|
||||||
@@ -181,7 +191,23 @@ func (b *Backend) HeaderByNumber(ctx context.Context, blockNumber rpc.BlockNumbe
|
|||||||
|
|
||||||
// HeaderByHash gets the header for the provided block hash
|
// HeaderByHash gets the header for the provided block hash
|
||||||
func (b *Backend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
func (b *Backend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
||||||
_, headerRLP, err := b.IPLDRetriever.RetrieveHeaderByHash(hash)
|
// Begin tx
|
||||||
|
tx, err := b.DB.Beginx()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if p := recover(); p != nil {
|
||||||
|
shared.Rollback(tx)
|
||||||
|
panic(p)
|
||||||
|
} else if err != nil {
|
||||||
|
shared.Rollback(tx)
|
||||||
|
} else {
|
||||||
|
err = tx.Commit()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
_, headerRLP, err := b.IPLDRetriever.RetrieveHeaderByHash(tx, hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -214,6 +240,10 @@ func (b *Backend) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.Bl
|
|||||||
return nil, errors.New("invalid arguments; neither block nor hash specified")
|
return nil, errors.New("invalid arguments; neither block nor hash specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Backend) PendingBlockAndReceipts() (*types.Block, types.Receipts) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetTd gets the total difficulty at the given block hash
|
// GetTd gets the total difficulty at the given block hash
|
||||||
func (b *Backend) GetTd(blockHash common.Hash) (*big.Int, error) {
|
func (b *Backend) GetTd(blockHash common.Hash) (*big.Int, error) {
|
||||||
var tdStr string
|
var tdStr string
|
||||||
@@ -266,7 +296,7 @@ func (b *Backend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.Blo
|
|||||||
return nil, errors.New("invalid arguments; neither block nor hash specified")
|
return nil, errors.New("invalid arguments; neither block nor hash specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockByNumber returns the requested canonical block.
|
// BlockByNumber returns the requested canonical block
|
||||||
func (b *Backend) BlockByNumber(ctx context.Context, blockNumber rpc.BlockNumber) (*types.Block, error) {
|
func (b *Backend) BlockByNumber(ctx context.Context, blockNumber rpc.BlockNumber) (*types.Block, error) {
|
||||||
var err error
|
var err error
|
||||||
number := blockNumber.Int64()
|
number := blockNumber.Int64()
|
||||||
@@ -288,6 +318,7 @@ func (b *Backend) BlockByNumber(ctx context.Context, blockNumber rpc.BlockNumber
|
|||||||
if number < 0 {
|
if number < 0 {
|
||||||
return nil, errNegativeBlockNumber
|
return nil, errNegativeBlockNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the canonical hash
|
// Get the canonical hash
|
||||||
canonicalHash, err := b.GetCanonicalHash(uint64(number))
|
canonicalHash, err := b.GetCanonicalHash(uint64(number))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -296,112 +327,12 @@ func (b *Backend) BlockByNumber(ctx context.Context, blockNumber rpc.BlockNumber
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Retrieve all the CIDs for the block
|
|
||||||
// TODO: optimize this by retrieving iplds directly rather than the cids first (this is remanent from when we fetched iplds through ipfs blockservice interface)
|
return b.BlockByHash(ctx, canonicalHash)
|
||||||
headerCID, uncleCIDs, txCIDs, rctCIDs, err := b.Retriever.RetrieveBlockByHash(canonicalHash)
|
|
||||||
if err != nil {
|
|
||||||
if err == sql.ErrNoRows {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin tx
|
// BlockByHash returns the requested block
|
||||||
tx, err := b.DB.Beginx()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if p := recover(); p != nil {
|
|
||||||
ethServerShared.Rollback(tx)
|
|
||||||
panic(p)
|
|
||||||
} else if err != nil {
|
|
||||||
ethServerShared.Rollback(tx)
|
|
||||||
} else {
|
|
||||||
err = tx.Commit()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Fetch and decode the header IPLD
|
|
||||||
var headerIPLD ipfs.BlockModel
|
|
||||||
headerIPLD, err = b.Fetcher.FetchHeader(tx, headerCID)
|
|
||||||
if err != nil {
|
|
||||||
if err == sql.ErrNoRows {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var header types.Header
|
|
||||||
err = rlp.DecodeBytes(headerIPLD.Data, &header)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
// Fetch and decode the uncle IPLDs
|
|
||||||
var uncleIPLDs []ipfs.BlockModel
|
|
||||||
uncleIPLDs, err = b.Fetcher.FetchUncles(tx, uncleCIDs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var uncles []*types.Header
|
|
||||||
for _, uncleIPLD := range uncleIPLDs {
|
|
||||||
var uncle types.Header
|
|
||||||
err = rlp.DecodeBytes(uncleIPLD.Data, &uncle)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
uncles = append(uncles, &uncle)
|
|
||||||
}
|
|
||||||
// Fetch and decode the transaction IPLDs
|
|
||||||
var txIPLDs []ipfs.BlockModel
|
|
||||||
txIPLDs, err = b.Fetcher.FetchTrxs(tx, txCIDs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var transactions []*types.Transaction
|
|
||||||
for _, txIPLD := range txIPLDs {
|
|
||||||
var transaction types.Transaction
|
|
||||||
err = transaction.UnmarshalBinary(txIPLD.Data)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
transactions = append(transactions, &transaction)
|
|
||||||
}
|
|
||||||
// Fetch and decode the receipt IPLDs
|
|
||||||
var rctIPLDs []ipfs.BlockModel
|
|
||||||
rctIPLDs, err = b.Fetcher.FetchRcts(tx, rctCIDs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var receipts []*types.Receipt
|
|
||||||
for _, rctIPLD := range rctIPLDs {
|
|
||||||
var receipt types.Receipt
|
|
||||||
nodeVal, err := DecodeLeafNode(rctIPLD.Data)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = receipt.UnmarshalBinary(nodeVal)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
receipts = append(receipts, &receipt)
|
|
||||||
}
|
|
||||||
// Compose everything together into a complete block
|
|
||||||
return types.NewBlock(&header, transactions, uncles, receipts, new(trie.Trie)), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// BlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full
|
|
||||||
// detail, otherwise only the transaction hash is returned.
|
|
||||||
func (b *Backend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
|
func (b *Backend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
|
||||||
// Retrieve all the CIDs for the block
|
|
||||||
headerCID, uncleCIDs, txCIDs, rctCIDs, err := b.Retriever.RetrieveBlockByHash(hash)
|
|
||||||
if err != nil {
|
|
||||||
if err == sql.ErrNoRows {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Begin tx
|
// Begin tx
|
||||||
tx, err := b.DB.Beginx()
|
tx, err := b.DB.Beginx()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -409,114 +340,185 @@ func (b *Backend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Blo
|
|||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if p := recover(); p != nil {
|
if p := recover(); p != nil {
|
||||||
ethServerShared.Rollback(tx)
|
shared.Rollback(tx)
|
||||||
panic(p)
|
panic(p)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
ethServerShared.Rollback(tx)
|
shared.Rollback(tx)
|
||||||
} else {
|
} else {
|
||||||
err = tx.Commit()
|
err = tx.Commit()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Fetch and decode the header IPLD
|
// Fetch header
|
||||||
var headerIPLD ipfs.BlockModel
|
header, err := b.GetHeaderByBlockHash(tx, hash)
|
||||||
headerIPLD, err = b.Fetcher.FetchHeader(tx, headerCID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error("error fetching header: ", err)
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var header types.Header
|
|
||||||
err = rlp.DecodeBytes(headerIPLD.Data, &header)
|
// Fetch uncles
|
||||||
if err != nil {
|
uncles, err := b.GetUnclesByBlockHash(tx, hash)
|
||||||
|
if err != nil && err != sql.ErrNoRows {
|
||||||
|
log.Error("error fetching uncles: ", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Fetch and decode the uncle IPLDs
|
|
||||||
var uncleIPLDs []ipfs.BlockModel
|
// When num. of uncles = 2,
|
||||||
uncleIPLDs, err = b.Fetcher.FetchUncles(tx, uncleCIDs)
|
// Check if calculated uncle hash matches the one in header
|
||||||
if err != nil {
|
// If not, re-order the two uncles
|
||||||
if err == sql.ErrNoRows {
|
// Assumption: Max num. of uncles in mainnet = 2
|
||||||
return nil, nil
|
if len(uncles) == 2 {
|
||||||
|
uncleHash := types.CalcUncleHash(uncles)
|
||||||
|
if uncleHash != header.UncleHash {
|
||||||
|
uncles[0], uncles[1] = uncles[1], uncles[0]
|
||||||
|
|
||||||
|
uncleHash = types.CalcUncleHash(uncles)
|
||||||
|
// Check if uncle hash matches after re-ordering
|
||||||
|
if uncleHash != header.UncleHash {
|
||||||
|
log.Error("uncle hash mismatch for block hash: ", hash.Hex())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch transactions
|
||||||
|
transactions, err := b.GetTransactionsByBlockHash(tx, hash)
|
||||||
|
if err != nil && err != sql.ErrNoRows {
|
||||||
|
log.Error("error fetching transactions: ", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var uncles []*types.Header
|
|
||||||
for _, uncleIPLD := range uncleIPLDs {
|
// Fetch receipts
|
||||||
var uncle types.Header
|
receipts, err := b.GetReceiptsByBlockHash(tx, hash)
|
||||||
err = rlp.DecodeBytes(uncleIPLD.Data, &uncle)
|
if err != nil && err != sql.ErrNoRows {
|
||||||
if err != nil {
|
log.Error("error fetching receipts: ", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uncles = append(uncles, &uncle)
|
|
||||||
|
// Compose everything together into a complete block
|
||||||
|
return types.NewBlock(header, transactions, uncles, receipts, new(trie.Trie)), err
|
||||||
}
|
}
|
||||||
// Fetch and decode the transaction IPLDs
|
|
||||||
var txIPLDs []ipfs.BlockModel
|
// GetHeaderByBlockHash retrieves header for a provided block hash
|
||||||
txIPLDs, err = b.Fetcher.FetchTrxs(tx, txCIDs)
|
func (b *Backend) GetHeaderByBlockHash(tx *sqlx.Tx, hash common.Hash) (*types.Header, error) {
|
||||||
if err != nil {
|
_, headerRLP, err := b.IPLDRetriever.RetrieveHeaderByHash(tx, hash)
|
||||||
if err == sql.ErrNoRows {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var transactions []*types.Transaction
|
|
||||||
for _, txIPLD := range txIPLDs {
|
|
||||||
var transaction types.Transaction
|
|
||||||
err = transaction.UnmarshalBinary(txIPLD.Data)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
transactions = append(transactions, &transaction)
|
|
||||||
}
|
|
||||||
// Fetch and decode the receipt IPLDs
|
|
||||||
var rctIPLDs []ipfs.BlockModel
|
|
||||||
rctIPLDs, err = b.Fetcher.FetchRcts(tx, rctCIDs)
|
|
||||||
if err != nil {
|
|
||||||
if err == sql.ErrNoRows {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var receipts []*types.Receipt
|
|
||||||
for _, rctIPLD := range rctIPLDs {
|
|
||||||
var receipt types.Receipt
|
|
||||||
nodeVal, err := DecodeLeafNode(rctIPLD.Data)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = receipt.UnmarshalBinary(nodeVal)
|
header := new(types.Header)
|
||||||
|
return header, rlp.DecodeBytes(headerRLP, header)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUnclesByBlockHash retrieves uncles for a provided block hash
|
||||||
|
func (b *Backend) GetUnclesByBlockHash(tx *sqlx.Tx, hash common.Hash) ([]*types.Header, error) {
|
||||||
|
_, uncleBytes, err := b.IPLDRetriever.RetrieveUnclesByBlockHash(tx, hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
receipts = append(receipts, &receipt)
|
|
||||||
|
uncles := make([]*types.Header, len(uncleBytes))
|
||||||
|
for i, bytes := range uncleBytes {
|
||||||
|
var uncle types.Header
|
||||||
|
err = rlp.DecodeBytes(bytes, &uncle)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
// Compose everything together into a complete block
|
|
||||||
return types.NewBlock(&header, transactions, uncles, receipts, new(trie.Trie)), err
|
uncles[i] = &uncle
|
||||||
|
}
|
||||||
|
|
||||||
|
return uncles, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTransactionsByBlockHash retrieves transactions for a provided block hash
|
||||||
|
func (b *Backend) GetTransactionsByBlockHash(tx *sqlx.Tx, hash common.Hash) (types.Transactions, error) {
|
||||||
|
_, transactionBytes, err := b.IPLDRetriever.RetrieveTransactionsByBlockHash(tx, hash)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
txs := make(types.Transactions, len(transactionBytes))
|
||||||
|
for i, txBytes := range transactionBytes {
|
||||||
|
var tx types.Transaction
|
||||||
|
if err := tx.UnmarshalBinary(txBytes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
txs[i] = &tx
|
||||||
|
}
|
||||||
|
|
||||||
|
return txs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetReceiptsByBlockHash retrieves receipts for a provided block hash
|
||||||
|
func (b *Backend) GetReceiptsByBlockHash(tx *sqlx.Tx, hash common.Hash) (types.Receipts, error) {
|
||||||
|
_, receiptBytes, txs, err := b.IPLDRetriever.RetrieveReceiptsByBlockHash(tx, hash)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
rcts := make(types.Receipts, len(receiptBytes))
|
||||||
|
for i, rctBytes := range receiptBytes {
|
||||||
|
rct := new(types.Receipt)
|
||||||
|
if err := rct.UnmarshalBinary(rctBytes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
rct.TxHash = txs[i]
|
||||||
|
rcts[i] = rct
|
||||||
|
}
|
||||||
|
return rcts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTransaction retrieves a tx by hash
|
// GetTransaction retrieves a tx by hash
|
||||||
// It also returns the blockhash, blocknumber, and tx index associated with the transaction
|
// It also returns the blockhash, blocknumber, and tx index associated with the transaction
|
||||||
func (b *Backend) GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) {
|
func (b *Backend) GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) {
|
||||||
var tempTxStruct struct {
|
type txRes struct {
|
||||||
Data []byte `db:"data"`
|
Data []byte `db:"data"`
|
||||||
BlockHash string `db:"block_hash"`
|
HeaderID string `db:"header_id"`
|
||||||
BlockNumber uint64 `db:"block_number"`
|
BlockNumber uint64 `db:"block_number"`
|
||||||
Index uint64 `db:"index"`
|
Index uint64 `db:"index"`
|
||||||
}
|
}
|
||||||
if err := b.DB.Get(&tempTxStruct, RetrieveRPCTransaction, txHash.String()); err != nil {
|
var res = make([]txRes, 0)
|
||||||
|
if err := b.DB.Select(&res, RetrieveRPCTransaction, txHash.String()); err != nil {
|
||||||
return nil, common.Hash{}, 0, 0, err
|
return nil, common.Hash{}, 0, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(res) == 0 {
|
||||||
|
return nil, common.Hash{}, 0, 0, errTxHashNotFound
|
||||||
|
} else if len(res) > 1 {
|
||||||
|
// a transaction can be part of a only one canonical block
|
||||||
|
return nil, common.Hash{}, 0, 0, errTxHashInMultipleBlocks
|
||||||
|
}
|
||||||
|
|
||||||
var transaction types.Transaction
|
var transaction types.Transaction
|
||||||
if err := transaction.UnmarshalBinary(tempTxStruct.Data); err != nil {
|
if err := transaction.UnmarshalBinary(res[0].Data); err != nil {
|
||||||
return nil, common.Hash{}, 0, 0, err
|
return nil, common.Hash{}, 0, 0, err
|
||||||
}
|
}
|
||||||
return &transaction, common.HexToHash(tempTxStruct.BlockHash), tempTxStruct.BlockNumber, tempTxStruct.Index, nil
|
|
||||||
|
return &transaction, common.HexToHash(res[0].HeaderID), res[0].BlockNumber, res[0].Index, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetReceipts retrieves receipts for provided block hash
|
// GetReceipts retrieves receipts for provided block hash
|
||||||
func (b *Backend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
|
func (b *Backend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
|
||||||
_, receiptBytes, txs, err := b.IPLDRetriever.RetrieveReceiptsByBlockHash(hash)
|
// Begin tx
|
||||||
|
tx, err := b.DB.Beginx()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if p := recover(); p != nil {
|
||||||
|
shared.Rollback(tx)
|
||||||
|
panic(p)
|
||||||
|
} else if err != nil {
|
||||||
|
shared.Rollback(tx)
|
||||||
|
} else {
|
||||||
|
err = tx.Commit()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
_, receiptBytes, txs, err := b.IPLDRetriever.RetrieveReceiptsByBlockHash(tx, hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -533,8 +535,24 @@ func (b *Backend) GetReceipts(ctx context.Context, hash common.Hash) (types.Rece
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetLogs returns all the logs for the given block hash
|
// GetLogs returns all the logs for the given block hash
|
||||||
func (b *Backend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) {
|
func (b *Backend) GetLogs(ctx context.Context, hash common.Hash, number uint64) ([][]*types.Log, error) {
|
||||||
_, receiptBytes, txs, err := b.IPLDRetriever.RetrieveReceiptsByBlockHash(hash)
|
// Begin tx
|
||||||
|
tx, err := b.DB.Beginx()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if p := recover(); p != nil {
|
||||||
|
shared.Rollback(tx)
|
||||||
|
panic(p)
|
||||||
|
} else if err != nil {
|
||||||
|
shared.Rollback(tx)
|
||||||
|
} else {
|
||||||
|
err = tx.Commit()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
_, receiptBytes, txs, err := b.IPLDRetriever.RetrieveReceiptsByBlockHash(tx, hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -735,10 +753,10 @@ func (b *Backend) GetCodeByHash(ctx context.Context, address common.Address, has
|
|||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if p := recover(); p != nil {
|
if p := recover(); p != nil {
|
||||||
ethServerShared.Rollback(tx)
|
shared.Rollback(tx)
|
||||||
panic(p)
|
panic(p)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
ethServerShared.Rollback(tx)
|
shared.Rollback(tx)
|
||||||
} else {
|
} else {
|
||||||
err = tx.Commit()
|
err = tx.Commit()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,6 +166,11 @@ func NewRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
|
|||||||
result.TransactionIndex = (*hexutil.Uint64)(&index)
|
result.TransactionIndex = (*hexutil.Uint64)(&index)
|
||||||
}
|
}
|
||||||
switch tx.Type() {
|
switch tx.Type() {
|
||||||
|
case types.LegacyTxType:
|
||||||
|
// if a legacy transaction has an EIP-155 chain id, include it explicitly
|
||||||
|
if id := tx.ChainId(); id.Sign() != 0 {
|
||||||
|
result.ChainID = (*hexutil.Big)(id)
|
||||||
|
}
|
||||||
case types.AccessListTxType:
|
case types.AccessListTxType:
|
||||||
al := tx.AccessList()
|
al := tx.AccessList()
|
||||||
result.Accesses = &al
|
result.Accesses = &al
|
||||||
|
|||||||
+267
-113
@@ -19,16 +19,18 @@ package eth
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"gorm.io/driver/postgres"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/shared"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Retriever interface for substituting mocks in tests
|
// Retriever interface for substituting mocks in tests
|
||||||
@@ -40,13 +42,75 @@ type Retriever interface {
|
|||||||
|
|
||||||
// CIDRetriever satisfies the CIDRetriever interface for ethereum
|
// CIDRetriever satisfies the CIDRetriever interface for ethereum
|
||||||
type CIDRetriever struct {
|
type CIDRetriever struct {
|
||||||
db *postgres.DB
|
db *sqlx.DB
|
||||||
|
gormDB *gorm.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
type IPLDModelRecord struct {
|
||||||
|
models.IPLDModel
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName overrides the table name used by IPLD
|
||||||
|
func (IPLDModelRecord) TableName() string {
|
||||||
|
return "public.blocks"
|
||||||
|
}
|
||||||
|
|
||||||
|
type HeaderCIDRecord struct {
|
||||||
|
CID string `gorm:"column:cid"`
|
||||||
|
BlockHash string `gorm:"primaryKey"`
|
||||||
|
BlockNumber string `gorm:"primaryKey"`
|
||||||
|
ParentHash string
|
||||||
|
Timestamp uint64
|
||||||
|
StateRoot string
|
||||||
|
TotalDifficulty string `gorm:"column:td"`
|
||||||
|
TxRoot string
|
||||||
|
RctRoot string `gorm:"column:receipt_root"`
|
||||||
|
UncleRoot string
|
||||||
|
Bloom []byte
|
||||||
|
MhKey string
|
||||||
|
|
||||||
|
// gorm doesn't check if foreign key exists in database.
|
||||||
|
// It is required to eager load relations using preload.
|
||||||
|
TransactionCIDs []TransactionCIDRecord `gorm:"foreignKey:HeaderID,BlockNumber;references:BlockHash,BlockNumber"`
|
||||||
|
IPLD IPLDModelRecord `gorm:"foreignKey:MhKey,BlockNumber;references:Key,BlockNumber"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName overrides the table name used by HeaderCIDRecord
|
||||||
|
func (HeaderCIDRecord) TableName() string {
|
||||||
|
return "eth.header_cids"
|
||||||
|
}
|
||||||
|
|
||||||
|
type TransactionCIDRecord struct {
|
||||||
|
CID string `gorm:"column:cid"`
|
||||||
|
TxHash string `gorm:"primaryKey"`
|
||||||
|
BlockNumber string `gorm:"primaryKey"`
|
||||||
|
HeaderID string `gorm:"column:header_id"`
|
||||||
|
Index int64
|
||||||
|
Src string
|
||||||
|
Dst string
|
||||||
|
MhKey string
|
||||||
|
IPLD IPLDModelRecord `gorm:"foreignKey:MhKey,BlockNumber;references:Key,BlockNumber"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName overrides the table name used by TransactionCIDRecord
|
||||||
|
func (TransactionCIDRecord) TableName() string {
|
||||||
|
return "eth.transaction_cids"
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCIDRetriever returns a pointer to a new CIDRetriever which supports the CIDRetriever interface
|
// NewCIDRetriever returns a pointer to a new CIDRetriever which supports the CIDRetriever interface
|
||||||
func NewCIDRetriever(db *postgres.DB) *CIDRetriever {
|
func NewCIDRetriever(db *sqlx.DB) *CIDRetriever {
|
||||||
|
gormDB, err := gorm.Open(postgres.New(postgres.Config{
|
||||||
|
Conn: db,
|
||||||
|
}), &gorm.Config{})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return &CIDRetriever{
|
return &CIDRetriever{
|
||||||
db: db,
|
db: db,
|
||||||
|
gormDB: gormDB,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +166,7 @@ func (ecr *CIDRetriever) Retrieve(filter SubscriptionSettings, blockNumber int64
|
|||||||
if filter.HeaderFilter.Uncles {
|
if filter.HeaderFilter.Uncles {
|
||||||
// Retrieve uncle cids for this header id
|
// Retrieve uncle cids for this header id
|
||||||
var uncleCIDs []models.UncleModel
|
var uncleCIDs []models.UncleModel
|
||||||
uncleCIDs, err = ecr.RetrieveUncleCIDsByHeaderID(tx, header.ID)
|
uncleCIDs, err = ecr.RetrieveUncleCIDsByHeaderID(tx, header.BlockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("uncle cid retrieval error")
|
log.Error("uncle cid retrieval error")
|
||||||
return nil, true, err
|
return nil, true, err
|
||||||
@@ -112,7 +176,7 @@ func (ecr *CIDRetriever) Retrieve(filter SubscriptionSettings, blockNumber int64
|
|||||||
}
|
}
|
||||||
// Retrieve cached trx CIDs
|
// Retrieve cached trx CIDs
|
||||||
if !filter.TxFilter.Off {
|
if !filter.TxFilter.Off {
|
||||||
cw.Transactions, err = ecr.RetrieveTxCIDs(tx, filter.TxFilter, header.ID)
|
cw.Transactions, err = ecr.RetrieveTxCIDs(tx, filter.TxFilter, header.BlockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("transaction cid retrieval error")
|
log.Error("transaction cid retrieval error")
|
||||||
return nil, true, err
|
return nil, true, err
|
||||||
@@ -121,13 +185,13 @@ func (ecr *CIDRetriever) Retrieve(filter SubscriptionSettings, blockNumber int64
|
|||||||
empty = false
|
empty = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trxIds := make([]int64, len(cw.Transactions))
|
trxHashes := make([]string, len(cw.Transactions))
|
||||||
for j, tx := range cw.Transactions {
|
for j, t := range cw.Transactions {
|
||||||
trxIds[j] = tx.ID
|
trxHashes[j] = t.TxHash
|
||||||
}
|
}
|
||||||
// Retrieve cached receipt CIDs
|
// Retrieve cached receipt CIDs
|
||||||
if !filter.ReceiptFilter.Off {
|
if !filter.ReceiptFilter.Off {
|
||||||
cw.Receipts, err = ecr.RetrieveRctCIDsByHeaderID(tx, filter.ReceiptFilter, header.ID, trxIds)
|
cw.Receipts, err = ecr.RetrieveRctCIDs(tx, filter.ReceiptFilter, 0, header.BlockHash, trxHashes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("receipt cid retrieval error")
|
log.Error("receipt cid retrieval error")
|
||||||
return nil, true, err
|
return nil, true, err
|
||||||
@@ -138,7 +202,7 @@ func (ecr *CIDRetriever) Retrieve(filter SubscriptionSettings, blockNumber int64
|
|||||||
}
|
}
|
||||||
// Retrieve cached state CIDs
|
// Retrieve cached state CIDs
|
||||||
if !filter.StateFilter.Off {
|
if !filter.StateFilter.Off {
|
||||||
cw.StateNodes, err = ecr.RetrieveStateCIDs(tx, filter.StateFilter, header.ID)
|
cw.StateNodes, err = ecr.RetrieveStateCIDs(tx, filter.StateFilter, header.BlockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("state cid retrieval error")
|
log.Error("state cid retrieval error")
|
||||||
return nil, true, err
|
return nil, true, err
|
||||||
@@ -149,7 +213,7 @@ func (ecr *CIDRetriever) Retrieve(filter SubscriptionSettings, blockNumber int64
|
|||||||
}
|
}
|
||||||
// Retrieve cached storage CIDs
|
// Retrieve cached storage CIDs
|
||||||
if !filter.StorageFilter.Off {
|
if !filter.StorageFilter.Off {
|
||||||
cw.StorageNodes, err = ecr.RetrieveStorageCIDs(tx, filter.StorageFilter, header.ID)
|
cw.StorageNodes, err = ecr.RetrieveStorageCIDs(tx, filter.StorageFilter, header.BlockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("storage cid retrieval error")
|
log.Error("storage cid retrieval error")
|
||||||
return nil, true, err
|
return nil, true, err
|
||||||
@@ -168,32 +232,39 @@ func (ecr *CIDRetriever) Retrieve(filter SubscriptionSettings, blockNumber int64
|
|||||||
func (ecr *CIDRetriever) RetrieveHeaderCIDs(tx *sqlx.Tx, blockNumber int64) ([]models.HeaderModel, error) {
|
func (ecr *CIDRetriever) RetrieveHeaderCIDs(tx *sqlx.Tx, blockNumber int64) ([]models.HeaderModel, error) {
|
||||||
log.Debug("retrieving header cids for block ", blockNumber)
|
log.Debug("retrieving header cids for block ", blockNumber)
|
||||||
headers := make([]models.HeaderModel, 0)
|
headers := make([]models.HeaderModel, 0)
|
||||||
pgStr := `SELECT * FROM eth.header_cids
|
pgStr := `SELECT CAST(block_number as Text), block_hash, parent_hash, cid, mh_key, CAST(td as Text), node_id,
|
||||||
|
CAST(reward as Text), state_root, uncle_root,tx_root, receipt_root, bloom, timestamp, times_validated, coinbase
|
||||||
|
FROM eth.header_cids
|
||||||
WHERE block_number = $1`
|
WHERE block_number = $1`
|
||||||
return headers, tx.Select(&headers, pgStr, blockNumber)
|
return headers, tx.Select(&headers, pgStr, blockNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveUncleCIDsByHeaderID retrieves and returns all of the uncle cids for the provided header
|
// RetrieveUncleCIDsByHeaderID retrieves and returns all of the uncle cids for the provided header
|
||||||
func (ecr *CIDRetriever) RetrieveUncleCIDsByHeaderID(tx *sqlx.Tx, headerID int64) ([]models.UncleModel, error) {
|
func (ecr *CIDRetriever) RetrieveUncleCIDsByHeaderID(tx *sqlx.Tx, headerID string) ([]models.UncleModel, error) {
|
||||||
log.Debug("retrieving uncle cids for block id ", headerID)
|
log.Debug("retrieving uncle cids for block id ", headerID)
|
||||||
headers := make([]models.UncleModel, 0)
|
headers := make([]models.UncleModel, 0)
|
||||||
pgStr := `SELECT * FROM eth.uncle_cids
|
pgStr := `SELECT CAST(block_number as Text), header_id, block_hash, parent_hash, cid, mh_key, CAST(reward as text)
|
||||||
|
FROM eth.uncle_cids
|
||||||
WHERE header_id = $1`
|
WHERE header_id = $1`
|
||||||
return headers, tx.Select(&headers, pgStr, headerID)
|
return headers, tx.Select(&headers, pgStr, headerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveTxCIDs retrieves and returns all of the trx cids at the provided blockheight that conform to the provided filter parameters
|
// RetrieveTxCIDs retrieves and returns all of the trx cids at the provided blockheight that conform to the provided filter parameters
|
||||||
// also returns the ids for the returned transaction cids
|
// also returns the ids for the returned transaction cids
|
||||||
func (ecr *CIDRetriever) RetrieveTxCIDs(tx *sqlx.Tx, txFilter TxFilter, headerID int64) ([]models.TxModel, error) {
|
func (ecr *CIDRetriever) RetrieveTxCIDs(tx *sqlx.Tx, txFilter TxFilter, headerID string) ([]models.TxModel, error) {
|
||||||
log.Debug("retrieving transaction cids for header id ", headerID)
|
log.Debug("retrieving transaction cids for header id ", headerID)
|
||||||
args := make([]interface{}, 0, 3)
|
args := make([]interface{}, 0, 3)
|
||||||
results := make([]models.TxModel, 0)
|
results := make([]models.TxModel, 0)
|
||||||
id := 1
|
id := 1
|
||||||
pgStr := fmt.Sprintf(`SELECT transaction_cids.id, transaction_cids.header_id,
|
pgStr := fmt.Sprintf(`SELECT CAST(transaction_cids.block_number as Text), transaction_cids.tx_hash,
|
||||||
transaction_cids.tx_hash, transaction_cids.cid, transaction_cids.mh_key,
|
transaction_cids.header_id, transaction_cids.cid, transaction_cids.mh_key, transaction_cids.dst,
|
||||||
transaction_cids.dst, transaction_cids.src, transaction_cids.index, transaction_cids.tx_data
|
transaction_cids.src, transaction_cids.index, transaction_cids.tx_data, transaction_cids.tx_type
|
||||||
FROM eth.transaction_cids INNER JOIN eth.header_cids ON (transaction_cids.header_id = header_cids.id)
|
FROM eth.transaction_cids
|
||||||
WHERE header_cids.id = $%d`, id)
|
INNER JOIN eth.header_cids ON (
|
||||||
|
transaction_cids.header_id = header_cids.block_hash
|
||||||
|
AND transaction_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
|
WHERE header_cids.block_hash = $%d`, id)
|
||||||
args = append(args, headerID)
|
args = append(args, headerID)
|
||||||
id++
|
id++
|
||||||
if len(txFilter.Dst) > 0 {
|
if len(txFilter.Dst) > 0 {
|
||||||
@@ -242,9 +313,9 @@ func logFilterCondition(id *int, pgStr string, args []interface{}, rctFilter Rec
|
|||||||
return pgStr, args
|
return pgStr, args
|
||||||
}
|
}
|
||||||
|
|
||||||
func receiptFilterConditions(id *int, pgStr string, args []interface{}, rctFilter ReceiptFilter, trxIds []int64) (string, []interface{}) {
|
func receiptFilterConditions(id *int, pgStr string, args []interface{}, rctFilter ReceiptFilter, txHashes []string) (string, []interface{}) {
|
||||||
rctCond := " AND (receipt_cids.id = ANY ( "
|
rctCond := " AND (receipt_cids.tx_id = ANY ( "
|
||||||
logQuery := "SELECT receipt_id FROM eth.log_cids WHERE"
|
logQuery := "SELECT rct_id FROM eth.log_cids WHERE"
|
||||||
if len(rctFilter.LogAddresses) > 0 {
|
if len(rctFilter.LogAddresses) > 0 {
|
||||||
// Filter on log contract addresses if there are any
|
// Filter on log contract addresses if there are any
|
||||||
pgStr += fmt.Sprintf(`%s %s eth.log_cids.address = ANY ($%d)`, rctCond, logQuery, *id)
|
pgStr += fmt.Sprintf(`%s %s eth.log_cids.address = ANY ($%d)`, rctCond, logQuery, *id)
|
||||||
@@ -258,10 +329,10 @@ func receiptFilterConditions(id *int, pgStr string, args []interface{}, rctFilte
|
|||||||
|
|
||||||
pgStr += ")"
|
pgStr += ")"
|
||||||
|
|
||||||
// Filter on txIDs if there are any and we are matching txs
|
// Filter on txHashes if there are any, and we are matching txs
|
||||||
if rctFilter.MatchTxs && len(trxIds) > 0 {
|
if rctFilter.MatchTxs && len(txHashes) > 0 {
|
||||||
pgStr += fmt.Sprintf(` OR receipt_cids.tx_id = ANY($%d::INTEGER[])`, *id)
|
pgStr += fmt.Sprintf(` OR receipt_cids.tx_id = ANY($%d)`, *id)
|
||||||
args = append(args, pq.Array(trxIds))
|
args = append(args, pq.Array(txHashes))
|
||||||
}
|
}
|
||||||
pgStr += ")"
|
pgStr += ")"
|
||||||
} else { // If there are no contract addresses to filter on
|
} else { // If there are no contract addresses to filter on
|
||||||
@@ -270,58 +341,45 @@ func receiptFilterConditions(id *int, pgStr string, args []interface{}, rctFilte
|
|||||||
pgStr += rctCond + logQuery
|
pgStr += rctCond + logQuery
|
||||||
pgStr, args = topicFilterCondition(id, rctFilter.Topics, args, pgStr, true)
|
pgStr, args = topicFilterCondition(id, rctFilter.Topics, args, pgStr, true)
|
||||||
pgStr += ")"
|
pgStr += ")"
|
||||||
// Filter on txIDs if there are any and we are matching txs
|
// Filter on txHashes if there are any, and we are matching txs
|
||||||
if rctFilter.MatchTxs && len(trxIds) > 0 {
|
if rctFilter.MatchTxs && len(txHashes) > 0 {
|
||||||
pgStr += fmt.Sprintf(` OR receipt_cids.tx_id = ANY($%d::INTEGER[])`, *id)
|
pgStr += fmt.Sprintf(` OR receipt_cids.tx_id = ANY($%d)`, *id)
|
||||||
args = append(args, pq.Array(trxIds))
|
args = append(args, pq.Array(txHashes))
|
||||||
}
|
}
|
||||||
pgStr += ")"
|
pgStr += ")"
|
||||||
} else if rctFilter.MatchTxs && len(trxIds) > 0 {
|
} else if rctFilter.MatchTxs && len(txHashes) > 0 {
|
||||||
// If there are no contract addresses or topics to filter on,
|
// If there are no contract addresses or topics to filter on,
|
||||||
// Filter on txIDs if there are any and we are matching txs
|
// Filter on txHashes if there are any, and we are matching txs
|
||||||
pgStr += fmt.Sprintf(` AND receipt_cids.tx_id = ANY($%d::INTEGER[])`, *id)
|
pgStr += fmt.Sprintf(` AND receipt_cids.tx_id = ANY($%d)`, *id)
|
||||||
args = append(args, pq.Array(trxIds))
|
args = append(args, pq.Array(txHashes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pgStr, args
|
return pgStr, args
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveRctCIDsByHeaderID retrieves and returns all of the rct cids at the provided header ID that conform to the provided
|
// RetrieveFilteredGQLLogs retrieves and returns all the log CIDs provided blockHash that conform to the provided
|
||||||
// filter parameters and correspond to the provided tx ids
|
|
||||||
func (ecr *CIDRetriever) RetrieveRctCIDsByHeaderID(tx *sqlx.Tx, rctFilter ReceiptFilter, headerID int64, trxIds []int64) ([]models.ReceiptModel, error) {
|
|
||||||
log.Debug("retrieving receipt cids for header id ", headerID)
|
|
||||||
args := make([]interface{}, 0, 4)
|
|
||||||
pgStr := `SELECT receipt_cids.id, receipt_cids.tx_id, receipt_cids.leaf_cid, receipt_cids.leaf_mh_key,
|
|
||||||
receipt_cids.contract, receipt_cids.contract_hash
|
|
||||||
FROM eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
|
||||||
WHERE receipt_cids.tx_id = transaction_cids.id
|
|
||||||
AND transaction_cids.header_id = header_cids.id
|
|
||||||
AND header_cids.id = $1`
|
|
||||||
id := 2
|
|
||||||
args = append(args, headerID)
|
|
||||||
|
|
||||||
pgStr, args = receiptFilterConditions(&id, pgStr, args, rctFilter, trxIds)
|
|
||||||
|
|
||||||
pgStr += ` ORDER BY transaction_cids.index`
|
|
||||||
receiptCids := make([]models.ReceiptModel, 0)
|
|
||||||
return receiptCids, tx.Select(&receiptCids, pgStr, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RetrieveFilteredGQLLogs retrieves and returns all the log cIDs provided blockHash that conform to the provided
|
|
||||||
// filter parameters.
|
// filter parameters.
|
||||||
func (ecr *CIDRetriever) RetrieveFilteredGQLLogs(tx *sqlx.Tx, rctFilter ReceiptFilter, blockHash *common.Hash) ([]LogResult, error) {
|
func (ecr *CIDRetriever) RetrieveFilteredGQLLogs(tx *sqlx.Tx, rctFilter ReceiptFilter, blockHash *common.Hash) ([]LogResult, error) {
|
||||||
log.Debug("retrieving log cids for receipt ids")
|
log.Debug("retrieving log cids for receipt ids with block hash", blockHash.String())
|
||||||
args := make([]interface{}, 0, 4)
|
args := make([]interface{}, 0, 4)
|
||||||
id := 1
|
id := 1
|
||||||
pgStr := `SELECT eth.log_cids.leaf_cid, eth.log_cids.index, eth.log_cids.receipt_id,
|
pgStr := `SELECT CAST(eth.log_cids.block_number as Text), eth.log_cids.leaf_cid, eth.log_cids.index, eth.log_cids.rct_id,
|
||||||
eth.log_cids.address, eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3,
|
eth.log_cids.address, eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3,
|
||||||
eth.log_cids.log_data, eth.transaction_cids.tx_hash, data, eth.receipt_cids.leaf_cid as cid, eth.receipt_cids.post_status
|
eth.log_cids.log_data, eth.transaction_cids.tx_hash, eth.transaction_cids.index as txn_index, data,
|
||||||
|
eth.receipt_cids.leaf_cid as cid, eth.receipt_cids.post_status, header_cids.block_hash
|
||||||
FROM eth.log_cids, eth.receipt_cids, eth.transaction_cids, eth.header_cids, public.blocks
|
FROM eth.log_cids, eth.receipt_cids, eth.transaction_cids, eth.header_cids, public.blocks
|
||||||
WHERE eth.log_cids.receipt_id = receipt_cids.id
|
WHERE eth.log_cids.rct_id = receipt_cids.tx_id
|
||||||
AND receipt_cids.tx_id = transaction_cids.id
|
AND eth.log_cids.header_id = eth.receipt_cids.header_id
|
||||||
AND transaction_cids.header_id = header_cids.id
|
AND eth.log_cids.block_number = eth.receipt_cids.block_number
|
||||||
AND log_cids.leaf_mh_key = blocks.key AND header_cids.block_hash = $1`
|
AND receipt_cids.tx_id = transaction_cids.tx_hash
|
||||||
|
AND receipt_cids.header_id = transaction_cids.header_id
|
||||||
|
AND receipt_cids.block_number = transaction_cids.block_number
|
||||||
|
AND transaction_cids.header_id = header_cids.block_hash
|
||||||
|
AND transaction_cids.block_number = header_cids.block_number
|
||||||
|
AND log_cids.leaf_mh_key = blocks.key
|
||||||
|
AND log_cids.block_number = blocks.block_number
|
||||||
|
AND header_cids.block_hash = $1`
|
||||||
|
|
||||||
args = append(args, blockHash.String())
|
args = append(args, blockHash.String())
|
||||||
id++
|
id++
|
||||||
@@ -338,19 +396,24 @@ func (ecr *CIDRetriever) RetrieveFilteredGQLLogs(tx *sqlx.Tx, rctFilter ReceiptF
|
|||||||
return logCIDs, nil
|
return logCIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveFilteredLog retrieves and returns all the log cIDs provided blockHeight or blockHash that conform to the provided
|
// RetrieveFilteredLog retrieves and returns all the log CIDs provided blockHeight or blockHash that conform to the provided
|
||||||
// filter parameters.
|
// filter parameters.
|
||||||
func (ecr *CIDRetriever) RetrieveFilteredLog(tx *sqlx.Tx, rctFilter ReceiptFilter, blockNumber int64, blockHash *common.Hash) ([]LogResult, error) {
|
func (ecr *CIDRetriever) RetrieveFilteredLog(tx *sqlx.Tx, rctFilter ReceiptFilter, blockNumber int64, blockHash *common.Hash) ([]LogResult, error) {
|
||||||
log.Debug("retrieving log cids for receipt ids")
|
log.Debug("retrieving log cids for receipt ids")
|
||||||
args := make([]interface{}, 0, 4)
|
args := make([]interface{}, 0, 4)
|
||||||
pgStr := `SELECT eth.log_cids.leaf_cid, eth.log_cids.index, eth.log_cids.receipt_id,
|
pgStr := `SELECT CAST(eth.log_cids.block_number as Text), eth.log_cids.leaf_cid, eth.log_cids.index, eth.log_cids.rct_id,
|
||||||
eth.log_cids.address, eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3,
|
eth.log_cids.address, eth.log_cids.topic0, eth.log_cids.topic1, eth.log_cids.topic2, eth.log_cids.topic3,
|
||||||
eth.log_cids.log_data, eth.transaction_cids.tx_hash, eth.transaction_cids.index as txn_index,
|
eth.log_cids.log_data, eth.transaction_cids.tx_hash, eth.transaction_cids.index as txn_index,
|
||||||
header_cids.block_hash, header_cids.block_number
|
eth.receipt_cids.leaf_cid as cid, eth.receipt_cids.post_status, header_cids.block_hash
|
||||||
FROM eth.log_cids, eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
FROM eth.log_cids, eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
||||||
WHERE eth.log_cids.receipt_id = receipt_cids.id
|
WHERE eth.log_cids.rct_id = receipt_cids.tx_id
|
||||||
AND receipt_cids.tx_id = transaction_cids.id
|
AND eth.log_cids.header_id = eth.receipt_cids.header_id
|
||||||
AND transaction_cids.header_id = header_cids.id`
|
AND eth.log_cids.block_number = eth.receipt_cids.block_number
|
||||||
|
AND receipt_cids.tx_id = transaction_cids.tx_hash
|
||||||
|
AND receipt_cids.header_id = transaction_cids.header_id
|
||||||
|
AND receipt_cids.block_number = transaction_cids.block_number
|
||||||
|
AND transaction_cids.header_id = header_cids.block_hash
|
||||||
|
AND transaction_cids.block_number = header_cids.block_number`
|
||||||
id := 1
|
id := 1
|
||||||
if blockNumber > 0 {
|
if blockNumber > 0 {
|
||||||
pgStr += fmt.Sprintf(` AND header_cids.block_number = $%d`, id)
|
pgStr += fmt.Sprintf(` AND header_cids.block_number = $%d`, id)
|
||||||
@@ -377,30 +440,34 @@ func (ecr *CIDRetriever) RetrieveFilteredLog(tx *sqlx.Tx, rctFilter ReceiptFilte
|
|||||||
|
|
||||||
// RetrieveRctCIDs retrieves and returns all of the rct cids at the provided blockheight or block hash that conform to the provided
|
// RetrieveRctCIDs retrieves and returns all of the rct cids at the provided blockheight or block hash that conform to the provided
|
||||||
// filter parameters and correspond to the provided tx ids
|
// filter parameters and correspond to the provided tx ids
|
||||||
func (ecr *CIDRetriever) RetrieveRctCIDs(tx *sqlx.Tx, rctFilter ReceiptFilter, blockNumber int64, blockHash *common.Hash, trxIds []int64) ([]models.ReceiptModel, error) {
|
func (ecr *CIDRetriever) RetrieveRctCIDs(tx *sqlx.Tx, rctFilter ReceiptFilter, blockNumber int64, blockHash string, txHashes []string) ([]models.ReceiptModel, error) {
|
||||||
log.Debug("retrieving receipt cids for block ", blockNumber)
|
log.Debug("retrieving receipt cids for block ", blockNumber)
|
||||||
args := make([]interface{}, 0, 5)
|
args := make([]interface{}, 0, 5)
|
||||||
pgStr := `SELECT receipt_cids.id, receipt_cids.leaf_cid, receipt_cids.leaf_mh_key, receipt_cids.tx_id
|
pgStr := `SELECT CAST(receipt_cids.block_number as Text), receipt_cids.header_id, receipt_cids.tx_id,
|
||||||
|
receipt_cids.leaf_cid, receipt_cids.leaf_mh_key, receipt_cids.contract, receipt_cids.contract_hash
|
||||||
FROM eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
FROM eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
||||||
WHERE receipt_cids.tx_id = transaction_cids.id
|
WHERE receipt_cids.tx_id = transaction_cids.tx_hash
|
||||||
AND transaction_cids.header_id = header_cids.id`
|
AND receipt_cids.header_id = transaction_cids.header_id
|
||||||
|
AND receipt_cids.block_number = transaction_cids.block_number
|
||||||
|
AND transaction_cids.header_id = header_cids.block_hash
|
||||||
|
AND transaction_cids.block_number = header_cids.block_number`
|
||||||
id := 1
|
id := 1
|
||||||
if blockNumber > 0 {
|
if blockNumber > 0 {
|
||||||
pgStr += fmt.Sprintf(` AND header_cids.block_number = $%d`, id)
|
pgStr += fmt.Sprintf(` AND header_cids.block_number = $%d`, id)
|
||||||
args = append(args, blockNumber)
|
args = append(args, blockNumber)
|
||||||
id++
|
id++
|
||||||
}
|
}
|
||||||
if blockHash != nil {
|
if blockHash != "" {
|
||||||
pgStr += fmt.Sprintf(` AND header_cids.block_hash = $%d`, id)
|
pgStr += fmt.Sprintf(` AND header_cids.block_hash = $%d`, id)
|
||||||
args = append(args, blockHash.String())
|
args = append(args, blockHash)
|
||||||
id++
|
id++
|
||||||
}
|
}
|
||||||
|
|
||||||
pgStr, args = receiptFilterConditions(&id, pgStr, args, rctFilter, trxIds)
|
pgStr, args = receiptFilterConditions(&id, pgStr, args, rctFilter, txHashes)
|
||||||
|
|
||||||
pgStr += ` ORDER BY transaction_cids.index`
|
pgStr += ` ORDER BY transaction_cids.index`
|
||||||
receiptCids := make([]models.ReceiptModel, 0)
|
receiptCIDs := make([]models.ReceiptModel, 0)
|
||||||
return receiptCids, tx.Select(&receiptCids, pgStr, args...)
|
return receiptCIDs, tx.Select(&receiptCIDs, pgStr, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasTopics(topics [][]string) bool {
|
func hasTopics(topics [][]string) bool {
|
||||||
@@ -413,13 +480,17 @@ func hasTopics(topics [][]string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveStateCIDs retrieves and returns all of the state node cids at the provided header ID that conform to the provided filter parameters
|
// RetrieveStateCIDs retrieves and returns all of the state node cids at the provided header ID that conform to the provided filter parameters
|
||||||
func (ecr *CIDRetriever) RetrieveStateCIDs(tx *sqlx.Tx, stateFilter StateFilter, headerID int64) ([]models.StateNodeModel, error) {
|
func (ecr *CIDRetriever) RetrieveStateCIDs(tx *sqlx.Tx, stateFilter StateFilter, headerID string) ([]models.StateNodeModel, error) {
|
||||||
log.Debug("retrieving state cids for header id ", headerID)
|
log.Debug("retrieving state cids for header id ", headerID)
|
||||||
args := make([]interface{}, 0, 2)
|
args := make([]interface{}, 0, 2)
|
||||||
pgStr := `SELECT state_cids.id, state_cids.header_id,
|
pgStr := `SELECT CAST(state_cids.block_number as Text), state_cids.header_id,
|
||||||
state_cids.state_leaf_key, state_cids.node_type, state_cids.cid, state_cids.mh_key, state_cids.state_path
|
state_cids.state_leaf_key, state_cids.node_type, state_cids.cid, state_cids.mh_key, state_cids.state_path
|
||||||
FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id)
|
FROM eth.state_cids
|
||||||
WHERE header_cids.id = $1`
|
INNER JOIN eth.header_cids ON (
|
||||||
|
state_cids.header_id = header_cids.block_hash
|
||||||
|
AND state_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
|
WHERE header_cids.block_hash = $1`
|
||||||
args = append(args, headerID)
|
args = append(args, headerID)
|
||||||
addrLen := len(stateFilter.Addresses)
|
addrLen := len(stateFilter.Addresses)
|
||||||
if addrLen > 0 {
|
if addrLen > 0 {
|
||||||
@@ -438,15 +509,19 @@ func (ecr *CIDRetriever) RetrieveStateCIDs(tx *sqlx.Tx, stateFilter StateFilter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveStorageCIDs retrieves and returns all of the storage node cids at the provided header id that conform to the provided filter parameters
|
// RetrieveStorageCIDs retrieves and returns all of the storage node cids at the provided header id that conform to the provided filter parameters
|
||||||
func (ecr *CIDRetriever) RetrieveStorageCIDs(tx *sqlx.Tx, storageFilter StorageFilter, headerID int64) ([]models.StorageNodeWithStateKeyModel, error) {
|
func (ecr *CIDRetriever) RetrieveStorageCIDs(tx *sqlx.Tx, storageFilter StorageFilter, headerID string) ([]models.StorageNodeWithStateKeyModel, error) {
|
||||||
log.Debug("retrieving storage cids for header id ", headerID)
|
log.Debug("retrieving storage cids for header id ", headerID)
|
||||||
args := make([]interface{}, 0, 3)
|
args := make([]interface{}, 0, 3)
|
||||||
pgStr := `SELECT storage_cids.id, storage_cids.state_id, storage_cids.storage_leaf_key, storage_cids.node_type,
|
pgStr := `SELECT CAST(storage_cids.block_number as Text), storage_cids.header_id, storage_cids.storage_leaf_key,
|
||||||
storage_cids.cid, storage_cids.mh_key, storage_cids.storage_path, state_cids.state_leaf_key
|
storage_cids.node_type, storage_cids.cid, storage_cids.mh_key, storage_cids.storage_path, storage_cids.state_path,
|
||||||
|
state_cids.state_leaf_key
|
||||||
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
FROM eth.storage_cids, eth.state_cids, eth.header_cids
|
||||||
WHERE storage_cids.state_id = state_cids.id
|
WHERE storage_cids.header_id = state_cids.header_id
|
||||||
AND state_cids.header_id = header_cids.id
|
AND storage_cids.state_path = state_cids.state_path
|
||||||
AND header_cids.id = $1`
|
AND storage_cids.block_number = state_cids.block_number
|
||||||
|
AND state_cids.header_id = header_cids.block_hash
|
||||||
|
AND state_cids.block_number = header_cids.block_number
|
||||||
|
AND header_cids.block_hash = $1`
|
||||||
args = append(args, headerID)
|
args = append(args, headerID)
|
||||||
id := 2
|
id := 2
|
||||||
addrLen := len(storageFilter.Addresses)
|
addrLen := len(storageFilter.Addresses)
|
||||||
@@ -496,24 +571,28 @@ func (ecr *CIDRetriever) RetrieveBlockByHash(blockHash common.Hash) (models.Head
|
|||||||
log.Error("header cid retrieval error")
|
log.Error("header cid retrieval error")
|
||||||
return models.HeaderModel{}, nil, nil, nil, err
|
return models.HeaderModel{}, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
blockNumber, err := strconv.ParseInt(headerCID.BlockNumber, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return models.HeaderModel{}, nil, nil, nil, err
|
||||||
|
}
|
||||||
var uncleCIDs []models.UncleModel
|
var uncleCIDs []models.UncleModel
|
||||||
uncleCIDs, err = ecr.RetrieveUncleCIDsByHeaderID(tx, headerCID.ID)
|
uncleCIDs, err = ecr.RetrieveUncleCIDsByHeaderID(tx, headerCID.BlockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("uncle cid retrieval error")
|
log.Error("uncle cid retrieval error")
|
||||||
return models.HeaderModel{}, nil, nil, nil, err
|
return models.HeaderModel{}, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
var txCIDs []models.TxModel
|
var txCIDs []models.TxModel
|
||||||
txCIDs, err = ecr.RetrieveTxCIDsByHeaderID(tx, headerCID.ID)
|
txCIDs, err = ecr.RetrieveTxCIDsByHeaderID(tx, headerCID.BlockHash, blockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("tx cid retrieval error")
|
log.Error("tx cid retrieval error")
|
||||||
return models.HeaderModel{}, nil, nil, nil, err
|
return models.HeaderModel{}, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
txIDs := make([]int64, len(txCIDs))
|
txHashes := make([]string, len(txCIDs))
|
||||||
for i, txCID := range txCIDs {
|
for i, txCID := range txCIDs {
|
||||||
txIDs[i] = txCID.ID
|
txHashes[i] = txCID.TxHash
|
||||||
}
|
}
|
||||||
var rctCIDs []models.ReceiptModel
|
var rctCIDs []models.ReceiptModel
|
||||||
rctCIDs, err = ecr.RetrieveReceiptCIDsByTxIDs(tx, txIDs)
|
rctCIDs, err = ecr.RetrieveReceiptCIDsByByHeaderIDAndTxIDs(tx, headerCID.BlockHash, txHashes, blockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("rct cid retrieval error")
|
log.Error("rct cid retrieval error")
|
||||||
}
|
}
|
||||||
@@ -550,23 +629,23 @@ func (ecr *CIDRetriever) RetrieveBlockByNumber(blockNumber int64) (models.Header
|
|||||||
return models.HeaderModel{}, nil, nil, nil, fmt.Errorf("header cid retrieval error, no header CIDs found at block %d", blockNumber)
|
return models.HeaderModel{}, nil, nil, nil, fmt.Errorf("header cid retrieval error, no header CIDs found at block %d", blockNumber)
|
||||||
}
|
}
|
||||||
var uncleCIDs []models.UncleModel
|
var uncleCIDs []models.UncleModel
|
||||||
uncleCIDs, err = ecr.RetrieveUncleCIDsByHeaderID(tx, headerCID[0].ID)
|
uncleCIDs, err = ecr.RetrieveUncleCIDsByHeaderID(tx, headerCID[0].BlockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("uncle cid retrieval error")
|
log.Error("uncle cid retrieval error")
|
||||||
return models.HeaderModel{}, nil, nil, nil, err
|
return models.HeaderModel{}, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
var txCIDs []models.TxModel
|
var txCIDs []models.TxModel
|
||||||
txCIDs, err = ecr.RetrieveTxCIDsByHeaderID(tx, headerCID[0].ID)
|
txCIDs, err = ecr.RetrieveTxCIDsByHeaderID(tx, headerCID[0].BlockHash, blockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("tx cid retrieval error")
|
log.Error("tx cid retrieval error")
|
||||||
return models.HeaderModel{}, nil, nil, nil, err
|
return models.HeaderModel{}, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
txIDs := make([]int64, len(txCIDs))
|
txHashes := make([]string, len(txCIDs))
|
||||||
for i, txCID := range txCIDs {
|
for i, txCID := range txCIDs {
|
||||||
txIDs[i] = txCID.ID
|
txHashes[i] = txCID.TxHash
|
||||||
}
|
}
|
||||||
var rctCIDs []models.ReceiptModel
|
var rctCIDs []models.ReceiptModel
|
||||||
rctCIDs, err = ecr.RetrieveReceiptCIDsByTxIDs(tx, txIDs)
|
rctCIDs, err = ecr.RetrieveReceiptCIDsByByHeaderIDAndTxIDs(tx, headerCID[0].BlockHash, txHashes, blockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("rct cid retrieval error")
|
log.Error("rct cid retrieval error")
|
||||||
}
|
}
|
||||||
@@ -576,31 +655,106 @@ func (ecr *CIDRetriever) RetrieveBlockByNumber(blockNumber int64) (models.Header
|
|||||||
// RetrieveHeaderCIDByHash returns the header for the given block hash
|
// RetrieveHeaderCIDByHash returns the header for the given block hash
|
||||||
func (ecr *CIDRetriever) RetrieveHeaderCIDByHash(tx *sqlx.Tx, blockHash common.Hash) (models.HeaderModel, error) {
|
func (ecr *CIDRetriever) RetrieveHeaderCIDByHash(tx *sqlx.Tx, blockHash common.Hash) (models.HeaderModel, error) {
|
||||||
log.Debug("retrieving header cids for block hash ", blockHash.String())
|
log.Debug("retrieving header cids for block hash ", blockHash.String())
|
||||||
pgStr := `SELECT * FROM eth.header_cids
|
pgStr := `SELECT block_hash, CAST(block_number as Text), parent_hash, cid, mh_key, CAST(td as Text),
|
||||||
|
state_root, uncle_root, tx_root, receipt_root, bloom, timestamp FROM eth.header_cids
|
||||||
WHERE block_hash = $1`
|
WHERE block_hash = $1`
|
||||||
var headerCID models.HeaderModel
|
var headerCID models.HeaderModel
|
||||||
return headerCID, tx.Get(&headerCID, pgStr, blockHash.String())
|
return headerCID, tx.Get(&headerCID, pgStr, blockHash.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveTxCIDsByHeaderID retrieves all tx CIDs for the given header id
|
// RetrieveTxCIDsByHeaderID retrieves all tx CIDs for the given header id
|
||||||
func (ecr *CIDRetriever) RetrieveTxCIDsByHeaderID(tx *sqlx.Tx, headerID int64) ([]models.TxModel, error) {
|
func (ecr *CIDRetriever) RetrieveTxCIDsByHeaderID(tx *sqlx.Tx, headerID string, blockNumber int64) ([]models.TxModel, error) {
|
||||||
log.Debug("retrieving tx cids for block id ", headerID)
|
log.Debug("retrieving tx cids for block id ", headerID)
|
||||||
pgStr := `SELECT * FROM eth.transaction_cids
|
pgStr := `SELECT CAST(block_number as Text), header_id, index, tx_hash, cid, mh_key,
|
||||||
WHERE header_id = $1
|
dst, src, tx_data, tx_type, value
|
||||||
|
FROM eth.transaction_cids
|
||||||
|
WHERE header_id = $1 AND block_number = $2
|
||||||
ORDER BY index`
|
ORDER BY index`
|
||||||
var txCIDs []models.TxModel
|
var txCIDs []models.TxModel
|
||||||
return txCIDs, tx.Select(&txCIDs, pgStr, headerID)
|
return txCIDs, tx.Select(&txCIDs, pgStr, headerID, blockNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveReceiptCIDsByTxIDs retrieves receipt CIDs by their associated tx IDs
|
// RetrieveReceiptCIDsByByHeaderIDAndTxIDs retrieves receipt CIDs by their associated tx IDs for the given header id
|
||||||
func (ecr *CIDRetriever) RetrieveReceiptCIDsByTxIDs(tx *sqlx.Tx, txIDs []int64) ([]models.ReceiptModel, error) {
|
func (ecr *CIDRetriever) RetrieveReceiptCIDsByByHeaderIDAndTxIDs(tx *sqlx.Tx, headerID string, txHashes []string, blockNumber int64) ([]models.ReceiptModel, error) {
|
||||||
log.Debugf("retrieving receipt cids for tx ids %v", txIDs)
|
log.Debugf("retrieving receipt cids for tx hashes %v", txHashes)
|
||||||
pgStr := `SELECT receipt_cids.id, receipt_cids.tx_id, receipt_cids.leaf_cid, receipt_cids.leaf_mh_key,
|
pgStr := `SELECT CAST(receipt_cids.block_number as Text), receipt_cids.header_id, receipt_cids.tx_id, receipt_cids.leaf_cid,
|
||||||
receipt_cids.contract, receipt_cids.contract_hash
|
receipt_cids.leaf_mh_key, receipt_cids.contract, receipt_cids.contract_hash
|
||||||
FROM eth.receipt_cids, eth.transaction_cids
|
FROM eth.receipt_cids, eth.transaction_cids
|
||||||
WHERE tx_id = ANY($1::INTEGER[])
|
WHERE tx_id = ANY($2)
|
||||||
AND receipt_cids.tx_id = transaction_cids.id
|
AND receipt_cids.tx_id = transaction_cids.tx_hash
|
||||||
|
AND receipt_cids.header_id = transaction_cids.header_id
|
||||||
|
AND receipt_cids.block_number = transaction_cids.block_number
|
||||||
|
AND transaction_cids.header_id = $1
|
||||||
|
AND transaction_cids.block_number = $3
|
||||||
ORDER BY transaction_cids.index`
|
ORDER BY transaction_cids.index`
|
||||||
var rctCIDs []models.ReceiptModel
|
var rctCIDs []models.ReceiptModel
|
||||||
return rctCIDs, tx.Select(&rctCIDs, pgStr, pq.Array(txIDs))
|
return rctCIDs, tx.Select(&rctCIDs, pgStr, headerID, pq.Array(txHashes), blockNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RetrieveHeaderAndTxCIDsByBlockNumber retrieves header CIDs and their associated tx CIDs by block number
|
||||||
|
func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockNumber(blockNumber int64) ([]HeaderCIDRecord, error) {
|
||||||
|
log.Debug("retrieving header cids and tx cids for block number ", blockNumber)
|
||||||
|
|
||||||
|
var headerCIDs []HeaderCIDRecord
|
||||||
|
|
||||||
|
// https://github.com/go-gorm/gorm/issues/4083#issuecomment-778883283
|
||||||
|
// Will use join for TransactionCIDs once preload for 1:N is supported.
|
||||||
|
err := ecr.gormDB.Preload("TransactionCIDs", func(tx *gorm.DB) *gorm.DB {
|
||||||
|
return tx.Select("cid", "tx_hash", "index", "src", "dst", "header_id", "block_number")
|
||||||
|
}).Joins("IPLD").Find(&headerCIDs, "header_cids.block_number = ?", blockNumber).Error
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error("header cid retrieval error")
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return headerCIDs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RetrieveHeaderAndTxCIDsByBlockHash retrieves header CID and their associated tx CIDs by block hash
|
||||||
|
func (ecr *CIDRetriever) RetrieveHeaderAndTxCIDsByBlockHash(blockHash common.Hash) (HeaderCIDRecord, error) {
|
||||||
|
log.Debug("retrieving header cid and tx cids for block hash ", blockHash.String())
|
||||||
|
|
||||||
|
var headerCIDs []HeaderCIDRecord
|
||||||
|
|
||||||
|
// https://github.com/go-gorm/gorm/issues/4083#issuecomment-778883283
|
||||||
|
// Will use join for TransactionCIDs once preload for 1:N is supported.
|
||||||
|
err := ecr.gormDB.Preload("TransactionCIDs", func(tx *gorm.DB) *gorm.DB {
|
||||||
|
return tx.Select("cid", "tx_hash", "index", "src", "dst", "header_id", "block_number")
|
||||||
|
}).Joins("IPLD").Find(&headerCIDs, "block_hash = ?", blockHash.String()).Error
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error("header cid retrieval error")
|
||||||
|
return HeaderCIDRecord{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(headerCIDs) == 0 {
|
||||||
|
return HeaderCIDRecord{}, errHeaderHashNotFound
|
||||||
|
} else if len(headerCIDs) > 1 {
|
||||||
|
return HeaderCIDRecord{}, errMultipleHeadersForHash
|
||||||
|
}
|
||||||
|
|
||||||
|
return headerCIDs[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RetrieveTxCIDByHash returns the tx for the given tx hash
|
||||||
|
func (ecr *CIDRetriever) RetrieveTxCIDByHash(txHash string) (TransactionCIDRecord, error) {
|
||||||
|
log.Debug("retrieving tx cid for tx hash ", txHash)
|
||||||
|
|
||||||
|
var txCIDs []TransactionCIDRecord
|
||||||
|
|
||||||
|
err := ecr.gormDB.Joins("IPLD").Find(&txCIDs, "tx_hash = ? AND transaction_cids.header_id = (SELECT canonical_header_hash(transaction_cids.block_number))", txHash).Error
|
||||||
|
if err != nil {
|
||||||
|
log.Error("header cid retrieval error")
|
||||||
|
return TransactionCIDRecord{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(txCIDs) == 0 {
|
||||||
|
return TransactionCIDRecord{}, errTxHashNotFound
|
||||||
|
} else if len(txCIDs) > 1 {
|
||||||
|
// a transaction can be part of a only one canonical block
|
||||||
|
return TransactionCIDRecord{}, errTxHashInMultipleBlocks
|
||||||
|
}
|
||||||
|
|
||||||
|
return txCIDs[0], nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,19 +19,18 @@ package eth_test
|
|||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth/test_helpers"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"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/statediff/indexer/models"
|
||||||
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth/test_helpers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -211,21 +210,18 @@ var (
|
|||||||
|
|
||||||
var _ = Describe("Retriever", func() {
|
var _ = Describe("Retriever", func() {
|
||||||
var (
|
var (
|
||||||
db *postgres.DB
|
db *sqlx.DB
|
||||||
diffIndexer *indexer.StateDiffIndexer
|
diffIndexer interfaces.StateDiffIndexer
|
||||||
retriever *eth.CIDRetriever
|
retriever *eth.CIDRetriever
|
||||||
)
|
)
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
var err error
|
db = shared.SetupDB()
|
||||||
db, err = SetupDB()
|
diffIndexer = shared.SetupTestStateDiffIndexer(ctx, params.TestChainConfig, test_helpers.Genesis.Hash())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
diffIndexer, err = indexer.NewStateDiffIndexer(params.TestChainConfig, db)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
retriever = eth.NewCIDRetriever(db)
|
retriever = eth.NewCIDRetriever(db)
|
||||||
})
|
})
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
eth.TearDownDB(db)
|
shared.TearDownDB(db)
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("Retrieve", func() {
|
Describe("Retrieve", func() {
|
||||||
@@ -233,11 +229,11 @@ var _ = Describe("Retriever", func() {
|
|||||||
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
for _, node := range test_helpers.MockStateNodes {
|
for _, node := range test_helpers.MockStateNodes {
|
||||||
err = diffIndexer.PushStateNode(tx, node)
|
err = diffIndexer.PushStateNode(tx, node, test_helpers.MockBlock.Hash().String())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
It("Retrieves all CIDs for the given blocknumber when provided an open filter", func() {
|
It("Retrieves all CIDs for the given blocknumber when provided an open filter", func() {
|
||||||
@@ -247,11 +243,12 @@ var _ = Describe("Retriever", func() {
|
|||||||
}
|
}
|
||||||
expectedRctCIDsAndLeafNodes := make([]rctCIDAndMHKeyResult, 0)
|
expectedRctCIDsAndLeafNodes := make([]rctCIDAndMHKeyResult, 0)
|
||||||
pgStr := `SELECT receipt_cids.leaf_cid, receipt_cids.leaf_mh_key FROM eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
pgStr := `SELECT receipt_cids.leaf_cid, receipt_cids.leaf_mh_key FROM eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
||||||
WHERE receipt_cids.tx_id = transaction_cids.id
|
WHERE receipt_cids.tx_id = transaction_cids.tx_hash
|
||||||
AND transaction_cids.header_id = header_cids.id
|
AND transaction_cids.header_id = header_cids.block_hash
|
||||||
AND header_cids.block_number = $1
|
AND header_cids.block_number = $1
|
||||||
ORDER BY transaction_cids.index`
|
ORDER BY transaction_cids.index`
|
||||||
err := db.Select(&expectedRctCIDsAndLeafNodes, pgStr, test_helpers.BlockNumber.Uint64())
|
err := db.Select(&expectedRctCIDsAndLeafNodes, pgStr, test_helpers.BlockNumber.Uint64())
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
cids, empty, err := retriever.Retrieve(openFilter, 1)
|
cids, empty, err := retriever.Retrieve(openFilter, 1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(empty).ToNot(BeTrue())
|
Expect(empty).ToNot(BeTrue())
|
||||||
@@ -259,7 +256,7 @@ var _ = Describe("Retriever", func() {
|
|||||||
Expect(cids[0].BlockNumber).To(Equal(test_helpers.MockCIDWrapper.BlockNumber))
|
Expect(cids[0].BlockNumber).To(Equal(test_helpers.MockCIDWrapper.BlockNumber))
|
||||||
|
|
||||||
expectedHeaderCID := test_helpers.MockCIDWrapper.Header
|
expectedHeaderCID := test_helpers.MockCIDWrapper.Header
|
||||||
expectedHeaderCID.ID = cids[0].Header.ID
|
expectedHeaderCID.BlockHash = cids[0].Header.BlockHash
|
||||||
expectedHeaderCID.NodeID = cids[0].Header.NodeID
|
expectedHeaderCID.NodeID = cids[0].Header.NodeID
|
||||||
Expect(cids[0].Header).To(Equal(expectedHeaderCID))
|
Expect(cids[0].Header).To(Equal(expectedHeaderCID))
|
||||||
Expect(len(cids[0].Transactions)).To(Equal(4))
|
Expect(len(cids[0].Transactions)).To(Equal(4))
|
||||||
@@ -286,8 +283,8 @@ var _ = Describe("Retriever", func() {
|
|||||||
}
|
}
|
||||||
Expect(len(cids[0].StorageNodes)).To(Equal(1))
|
Expect(len(cids[0].StorageNodes)).To(Equal(1))
|
||||||
expectedStorageNodeCIDs := test_helpers.MockCIDWrapper.StorageNodes
|
expectedStorageNodeCIDs := test_helpers.MockCIDWrapper.StorageNodes
|
||||||
expectedStorageNodeCIDs[0].ID = cids[0].StorageNodes[0].ID
|
expectedStorageNodeCIDs[0].HeaderID = cids[0].StorageNodes[0].HeaderID
|
||||||
expectedStorageNodeCIDs[0].StateID = cids[0].StorageNodes[0].StateID
|
expectedStorageNodeCIDs[0].StatePath = cids[0].StorageNodes[0].StatePath
|
||||||
Expect(cids[0].StorageNodes).To(Equal(expectedStorageNodeCIDs))
|
Expect(cids[0].StorageNodes).To(Equal(expectedStorageNodeCIDs))
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -298,8 +295,8 @@ var _ = Describe("Retriever", func() {
|
|||||||
}
|
}
|
||||||
expectedRctCIDsAndLeafNodes := make([]rctCIDAndMHKeyResult, 0)
|
expectedRctCIDsAndLeafNodes := make([]rctCIDAndMHKeyResult, 0)
|
||||||
pgStr := `SELECT receipt_cids.leaf_cid, receipt_cids.leaf_mh_key FROM eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
pgStr := `SELECT receipt_cids.leaf_cid, receipt_cids.leaf_mh_key FROM eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
||||||
WHERE receipt_cids.tx_id = transaction_cids.id
|
WHERE receipt_cids.tx_id = transaction_cids.tx_hash
|
||||||
AND transaction_cids.header_id = header_cids.id
|
AND transaction_cids.header_id = header_cids.block_hash
|
||||||
AND header_cids.block_number = $1
|
AND header_cids.block_number = $1
|
||||||
ORDER BY transaction_cids.index`
|
ORDER BY transaction_cids.index`
|
||||||
err := db.Select(&expectedRctCIDsAndLeafNodes, pgStr, test_helpers.BlockNumber.Uint64())
|
err := db.Select(&expectedRctCIDsAndLeafNodes, pgStr, test_helpers.BlockNumber.Uint64())
|
||||||
@@ -314,7 +311,6 @@ var _ = Describe("Retriever", func() {
|
|||||||
Expect(len(cids1[0].StorageNodes)).To(Equal(0))
|
Expect(len(cids1[0].StorageNodes)).To(Equal(0))
|
||||||
Expect(len(cids1[0].Receipts)).To(Equal(1))
|
Expect(len(cids1[0].Receipts)).To(Equal(1))
|
||||||
expectedReceiptCID := test_helpers.MockCIDWrapper.Receipts[0]
|
expectedReceiptCID := test_helpers.MockCIDWrapper.Receipts[0]
|
||||||
expectedReceiptCID.ID = cids1[0].Receipts[0].ID
|
|
||||||
expectedReceiptCID.TxID = cids1[0].Receipts[0].TxID
|
expectedReceiptCID.TxID = cids1[0].Receipts[0].TxID
|
||||||
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[0].LeafCID
|
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[0].LeafCID
|
||||||
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[0].LeafMhKey
|
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[0].LeafMhKey
|
||||||
@@ -331,7 +327,6 @@ var _ = Describe("Retriever", func() {
|
|||||||
Expect(len(cids2[0].StorageNodes)).To(Equal(0))
|
Expect(len(cids2[0].StorageNodes)).To(Equal(0))
|
||||||
Expect(len(cids2[0].Receipts)).To(Equal(1))
|
Expect(len(cids2[0].Receipts)).To(Equal(1))
|
||||||
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[0]
|
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[0]
|
||||||
expectedReceiptCID.ID = cids2[0].Receipts[0].ID
|
|
||||||
expectedReceiptCID.TxID = cids2[0].Receipts[0].TxID
|
expectedReceiptCID.TxID = cids2[0].Receipts[0].TxID
|
||||||
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[0].LeafCID
|
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[0].LeafCID
|
||||||
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[0].LeafMhKey
|
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[0].LeafMhKey
|
||||||
@@ -348,7 +343,6 @@ var _ = Describe("Retriever", func() {
|
|||||||
Expect(len(cids3[0].StorageNodes)).To(Equal(0))
|
Expect(len(cids3[0].StorageNodes)).To(Equal(0))
|
||||||
Expect(len(cids3[0].Receipts)).To(Equal(1))
|
Expect(len(cids3[0].Receipts)).To(Equal(1))
|
||||||
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[0]
|
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[0]
|
||||||
expectedReceiptCID.ID = cids3[0].Receipts[0].ID
|
|
||||||
expectedReceiptCID.TxID = cids3[0].Receipts[0].TxID
|
expectedReceiptCID.TxID = cids3[0].Receipts[0].TxID
|
||||||
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[0].LeafCID
|
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[0].LeafCID
|
||||||
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[0].LeafMhKey
|
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[0].LeafMhKey
|
||||||
@@ -365,7 +359,6 @@ var _ = Describe("Retriever", func() {
|
|||||||
Expect(len(cids4[0].StorageNodes)).To(Equal(0))
|
Expect(len(cids4[0].StorageNodes)).To(Equal(0))
|
||||||
Expect(len(cids4[0].Receipts)).To(Equal(1))
|
Expect(len(cids4[0].Receipts)).To(Equal(1))
|
||||||
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[1]
|
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[1]
|
||||||
expectedReceiptCID.ID = cids4[0].Receipts[0].ID
|
|
||||||
expectedReceiptCID.TxID = cids4[0].Receipts[0].TxID
|
expectedReceiptCID.TxID = cids4[0].Receipts[0].TxID
|
||||||
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[1].LeafCID
|
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[1].LeafCID
|
||||||
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[1].LeafMhKey
|
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[1].LeafMhKey
|
||||||
@@ -396,14 +389,13 @@ var _ = Describe("Retriever", func() {
|
|||||||
Expect(cids6[0].Header).To(Equal(models.HeaderModel{}))
|
Expect(cids6[0].Header).To(Equal(models.HeaderModel{}))
|
||||||
Expect(len(cids6[0].Transactions)).To(Equal(1))
|
Expect(len(cids6[0].Transactions)).To(Equal(1))
|
||||||
expectedTxCID := test_helpers.MockCIDWrapper.Transactions[1]
|
expectedTxCID := test_helpers.MockCIDWrapper.Transactions[1]
|
||||||
expectedTxCID.ID = cids6[0].Transactions[0].ID
|
expectedTxCID.TxHash = cids6[0].Transactions[0].TxHash
|
||||||
expectedTxCID.HeaderID = cids6[0].Transactions[0].HeaderID
|
expectedTxCID.HeaderID = cids6[0].Transactions[0].HeaderID
|
||||||
Expect(cids6[0].Transactions[0]).To(Equal(expectedTxCID))
|
Expect(cids6[0].Transactions[0]).To(Equal(expectedTxCID))
|
||||||
Expect(len(cids6[0].StateNodes)).To(Equal(0))
|
Expect(len(cids6[0].StateNodes)).To(Equal(0))
|
||||||
Expect(len(cids6[0].StorageNodes)).To(Equal(0))
|
Expect(len(cids6[0].StorageNodes)).To(Equal(0))
|
||||||
Expect(len(cids6[0].Receipts)).To(Equal(1))
|
Expect(len(cids6[0].Receipts)).To(Equal(1))
|
||||||
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[1]
|
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[1]
|
||||||
expectedReceiptCID.ID = cids6[0].Receipts[0].ID
|
|
||||||
expectedReceiptCID.TxID = cids6[0].Receipts[0].TxID
|
expectedReceiptCID.TxID = cids6[0].Receipts[0].TxID
|
||||||
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[1].LeafCID
|
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[1].LeafCID
|
||||||
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[1].LeafMhKey
|
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[1].LeafMhKey
|
||||||
@@ -420,7 +412,7 @@ var _ = Describe("Retriever", func() {
|
|||||||
Expect(len(cids7[0].StorageNodes)).To(Equal(0))
|
Expect(len(cids7[0].StorageNodes)).To(Equal(0))
|
||||||
Expect(len(cids7[0].StateNodes)).To(Equal(1))
|
Expect(len(cids7[0].StateNodes)).To(Equal(1))
|
||||||
Expect(cids7[0].StateNodes[0]).To(Equal(models.StateNodeModel{
|
Expect(cids7[0].StateNodes[0]).To(Equal(models.StateNodeModel{
|
||||||
ID: cids7[0].StateNodes[0].ID,
|
BlockNumber: "1",
|
||||||
HeaderID: cids7[0].StateNodes[0].HeaderID,
|
HeaderID: cids7[0].StateNodes[0].HeaderID,
|
||||||
NodeType: 2,
|
NodeType: 2,
|
||||||
StateKey: common.BytesToHash(test_helpers.AccountLeafKey).Hex(),
|
StateKey: common.BytesToHash(test_helpers.AccountLeafKey).Hex(),
|
||||||
@@ -444,7 +436,7 @@ var _ = Describe("Retriever", func() {
|
|||||||
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
num, err := retriever.RetrieveFirstBlockNumber()
|
num, err := retriever.RetrieveFirstBlockNumber()
|
||||||
@@ -458,7 +450,7 @@ var _ = Describe("Retriever", func() {
|
|||||||
tx, err := diffIndexer.PushBlock(payload.Block, payload.Receipts, payload.Block.Difficulty())
|
tx, err := diffIndexer.PushBlock(payload.Block, payload.Receipts, payload.Block.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
num, err := retriever.RetrieveFirstBlockNumber()
|
num, err := retriever.RetrieveFirstBlockNumber()
|
||||||
@@ -473,12 +465,12 @@ var _ = Describe("Retriever", func() {
|
|||||||
payload2.Block = newMockBlock(5)
|
payload2.Block = newMockBlock(5)
|
||||||
tx, err := diffIndexer.PushBlock(payload1.Block, payload1.Receipts, payload1.Block.Difficulty())
|
tx, err := diffIndexer.PushBlock(payload1.Block, payload1.Receipts, payload1.Block.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
tx, err = diffIndexer.PushBlock(payload2.Block, payload2.Receipts, payload2.Block.Difficulty())
|
tx, err = diffIndexer.PushBlock(payload2.Block, payload2.Receipts, payload2.Block.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
num, err := retriever.RetrieveFirstBlockNumber()
|
num, err := retriever.RetrieveFirstBlockNumber()
|
||||||
@@ -495,7 +487,7 @@ var _ = Describe("Retriever", func() {
|
|||||||
It("Gets the number of the latest block that has data in the database", 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())
|
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
num, err := retriever.RetrieveLastBlockNumber()
|
num, err := retriever.RetrieveLastBlockNumber()
|
||||||
@@ -509,7 +501,7 @@ var _ = Describe("Retriever", func() {
|
|||||||
tx, err := diffIndexer.PushBlock(payload.Block, payload.Receipts, payload.Block.Difficulty())
|
tx, err := diffIndexer.PushBlock(payload.Block, payload.Receipts, payload.Block.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
num, err := retriever.RetrieveLastBlockNumber()
|
num, err := retriever.RetrieveLastBlockNumber()
|
||||||
@@ -524,12 +516,12 @@ var _ = Describe("Retriever", func() {
|
|||||||
payload2.Block = newMockBlock(5)
|
payload2.Block = newMockBlock(5)
|
||||||
tx, err := diffIndexer.PushBlock(payload1.Block, payload1.Receipts, payload1.Block.Difficulty())
|
tx, err := diffIndexer.PushBlock(payload1.Block, payload1.Receipts, payload1.Block.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
tx, err = diffIndexer.PushBlock(payload2.Block, payload2.Receipts, payload2.Block.Difficulty())
|
tx, err = diffIndexer.PushBlock(payload2.Block, payload2.Receipts, payload2.Block.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
num, err := retriever.RetrieveLastBlockNumber()
|
num, err := retriever.RetrieveLastBlockNumber()
|
||||||
|
|||||||
+17
-19
@@ -21,7 +21,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth/test_helpers"
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
|
ethServerShared "github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
@@ -31,15 +36,10 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/statediff"
|
"github.com/ethereum/go-ethereum/statediff"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer"
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
|
||||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth/test_helpers"
|
|
||||||
ethServerShared "github.com/vulcanize/ipld-eth-server/pkg/shared"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -64,7 +64,7 @@ var _ = Describe("eth state reading tests", func() {
|
|||||||
blocks []*types.Block
|
blocks []*types.Block
|
||||||
receipts []types.Receipts
|
receipts []types.Receipts
|
||||||
chain *core.BlockChain
|
chain *core.BlockChain
|
||||||
db *postgres.DB
|
db *sqlx.DB
|
||||||
api *eth.PublicEthAPI
|
api *eth.PublicEthAPI
|
||||||
backend *eth.Backend
|
backend *eth.Backend
|
||||||
chainConfig = params.TestChainConfig
|
chainConfig = params.TestChainConfig
|
||||||
@@ -74,11 +74,8 @@ var _ = Describe("eth state reading tests", func() {
|
|||||||
It("test init", func() {
|
It("test init", func() {
|
||||||
// db and type initializations
|
// db and type initializations
|
||||||
var err error
|
var err error
|
||||||
db, err = SetupDB()
|
db = shared.SetupDB()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
transformer := shared.SetupTestStateDiffIndexer(ctx, chainConfig, test_helpers.Genesis.Hash())
|
||||||
|
|
||||||
transformer, err := indexer.NewStateDiffIndexer(chainConfig, db)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
backend, err = eth.NewEthBackend(db, ð.Config{
|
backend, err = eth.NewEthBackend(db, ð.Config{
|
||||||
ChainConfig: chainConfig,
|
ChainConfig: chainConfig,
|
||||||
@@ -150,21 +147,20 @@ var _ = Describe("eth state reading tests", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
for _, node := range diff.Nodes {
|
for _, node := range diff.Nodes {
|
||||||
err = transformer.PushStateNode(tx, node)
|
err = transformer.PushStateNode(tx, node, block.Hash().String())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert some non-canonical data into the database so that we test our ability to discern canonicity
|
// Insert some non-canonical data into the database so that we test our ability to discern canonicity
|
||||||
indexAndPublisher, err := indexer.NewStateDiffIndexer(chainConfig, db)
|
indexAndPublisher := shared.SetupTestStateDiffIndexer(ctx, chainConfig, test_helpers.Genesis.Hash())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
tx, err := indexAndPublisher.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
tx, err := indexAndPublisher.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
// The non-canonical header has a child
|
// The non-canonical header has a child
|
||||||
@@ -179,11 +175,13 @@ var _ = Describe("eth state reading tests", func() {
|
|||||||
err = indexAndPublisher.PushCodeAndCodeHash(tx, hash)
|
err = indexAndPublisher.PushCodeAndCodeHash(tx, hash)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = tx.Close(err)
|
// wait for tx batch process to complete.
|
||||||
|
time.Sleep(10000 * time.Millisecond)
|
||||||
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
defer It("test teardown", func() {
|
defer It("test teardown", func() {
|
||||||
eth.TearDownDB(db)
|
shared.TearDownDB(db)
|
||||||
chain.Stop()
|
chain.Stop()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+22
-18
@@ -23,12 +23,11 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs/ipld"
|
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
|
||||||
|
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/multiformats/go-multihash"
|
"github.com/multiformats/go-multihash"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Filterer interface for substituing mocks in tests
|
// Filterer interface for substituing mocks in tests
|
||||||
@@ -82,12 +81,13 @@ func (s *ResponseFilterer) filterHeaders(headerFilter HeaderFilter, response *IP
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
response.Header = ipfs.BlockModel{
|
response.Header = models.IPLDModel{
|
||||||
|
BlockNumber: payload.Block.Number().String(),
|
||||||
Data: headerRLP,
|
Data: headerRLP,
|
||||||
CID: cid.String(),
|
Key: cid.String(),
|
||||||
}
|
}
|
||||||
if headerFilter.Uncles {
|
if headerFilter.Uncles {
|
||||||
response.Uncles = make([]ipfs.BlockModel, len(payload.Block.Body().Uncles))
|
response.Uncles = make([]models.IPLDModel, len(payload.Block.Body().Uncles))
|
||||||
for i, uncle := range payload.Block.Body().Uncles {
|
for i, uncle := range payload.Block.Body().Uncles {
|
||||||
uncleRlp, err := rlp.EncodeToBytes(uncle)
|
uncleRlp, err := rlp.EncodeToBytes(uncle)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -97,9 +97,10 @@ func (s *ResponseFilterer) filterHeaders(headerFilter HeaderFilter, response *IP
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
response.Uncles[i] = ipfs.BlockModel{
|
response.Uncles[i] = models.IPLDModel{
|
||||||
|
BlockNumber: uncle.Number.String(),
|
||||||
Data: uncleRlp,
|
Data: uncleRlp,
|
||||||
CID: cid.String(),
|
Key: cid.String(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,7 +120,7 @@ func (s *ResponseFilterer) filterTransactions(trxFilter TxFilter, response *IPLD
|
|||||||
if !trxFilter.Off {
|
if !trxFilter.Off {
|
||||||
trxLen := len(payload.Block.Body().Transactions)
|
trxLen := len(payload.Block.Body().Transactions)
|
||||||
trxHashes = make([]common.Hash, 0, trxLen)
|
trxHashes = make([]common.Hash, 0, trxLen)
|
||||||
response.Transactions = make([]ipfs.BlockModel, 0, trxLen)
|
response.Transactions = make([]models.IPLDModel, 0, trxLen)
|
||||||
for i, trx := range payload.Block.Body().Transactions {
|
for i, trx := range payload.Block.Body().Transactions {
|
||||||
// TODO: check if want corresponding receipt and if we do we must include this transaction
|
// TODO: check if want corresponding receipt and if we do we must include this transaction
|
||||||
if checkTransactionAddrs(trxFilter.Src, trxFilter.Dst, payload.TxMetaData[i].Src, payload.TxMetaData[i].Dst) {
|
if checkTransactionAddrs(trxFilter.Src, trxFilter.Dst, payload.TxMetaData[i].Src, payload.TxMetaData[i].Dst) {
|
||||||
@@ -132,9 +133,9 @@ func (s *ResponseFilterer) filterTransactions(trxFilter TxFilter, response *IPLD
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
response.Transactions = append(response.Transactions, ipfs.BlockModel{
|
response.Transactions = append(response.Transactions, models.IPLDModel{
|
||||||
Data: data,
|
Data: data,
|
||||||
CID: cid.String(),
|
Key: cid.String(),
|
||||||
})
|
})
|
||||||
trxHashes = append(trxHashes, trx.Hash())
|
trxHashes = append(trxHashes, trx.Hash())
|
||||||
}
|
}
|
||||||
@@ -164,7 +165,7 @@ func checkTransactionAddrs(wantedSrc, wantedDst []string, actualSrc, actualDst s
|
|||||||
|
|
||||||
func (s *ResponseFilterer) filerReceipts(receiptFilter ReceiptFilter, response *IPLDs, payload ConvertedPayload, trxHashes []common.Hash) error {
|
func (s *ResponseFilterer) filerReceipts(receiptFilter ReceiptFilter, response *IPLDs, payload ConvertedPayload, trxHashes []common.Hash) error {
|
||||||
if !receiptFilter.Off {
|
if !receiptFilter.Off {
|
||||||
response.Receipts = make([]ipfs.BlockModel, 0, len(payload.Receipts))
|
response.Receipts = make([]models.IPLDModel, 0, len(payload.Receipts))
|
||||||
rctLeafCID, rctIPLDData, err := GetRctLeafNodeData(payload.Receipts)
|
rctLeafCID, rctIPLDData, err := GetRctLeafNodeData(payload.Receipts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -183,9 +184,10 @@ func (s *ResponseFilterer) filerReceipts(receiptFilter ReceiptFilter, response *
|
|||||||
|
|
||||||
// TODO: Verify this filter logic.
|
// TODO: Verify this filter logic.
|
||||||
if checkReceipts(receipt, receiptFilter.Topics, topics, receiptFilter.LogAddresses, contracts, trxHashes) {
|
if checkReceipts(receipt, receiptFilter.Topics, topics, receiptFilter.LogAddresses, contracts, trxHashes) {
|
||||||
response.Receipts = append(response.Receipts, ipfs.BlockModel{
|
response.Receipts = append(response.Receipts, models.IPLDModel{
|
||||||
|
BlockNumber: payload.Block.Number().String(),
|
||||||
Data: rctIPLDData[idx],
|
Data: rctIPLDData[idx],
|
||||||
CID: rctLeafCID[idx].String(),
|
Key: rctLeafCID[idx].String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,9 +284,10 @@ func (s *ResponseFilterer) filterStateAndStorage(stateFilter StateFilter, storag
|
|||||||
response.StateNodes = append(response.StateNodes, StateNode{
|
response.StateNodes = append(response.StateNodes, StateNode{
|
||||||
StateLeafKey: common.BytesToHash(stateNode.LeafKey),
|
StateLeafKey: common.BytesToHash(stateNode.LeafKey),
|
||||||
Path: stateNode.Path,
|
Path: stateNode.Path,
|
||||||
IPLD: ipfs.BlockModel{
|
IPLD: models.IPLDModel{
|
||||||
|
BlockNumber: payload.Block.Number().String(),
|
||||||
Data: stateNode.NodeValue,
|
Data: stateNode.NodeValue,
|
||||||
CID: cid.String(),
|
Key: cid.String(),
|
||||||
},
|
},
|
||||||
Type: stateNode.NodeType,
|
Type: stateNode.NodeType,
|
||||||
})
|
})
|
||||||
@@ -300,9 +303,10 @@ func (s *ResponseFilterer) filterStateAndStorage(stateFilter StateFilter, storag
|
|||||||
response.StorageNodes = append(response.StorageNodes, StorageNode{
|
response.StorageNodes = append(response.StorageNodes, StorageNode{
|
||||||
StateLeafKey: common.BytesToHash(stateNode.LeafKey),
|
StateLeafKey: common.BytesToHash(stateNode.LeafKey),
|
||||||
StorageLeafKey: common.BytesToHash(storageNode.LeafKey),
|
StorageLeafKey: common.BytesToHash(storageNode.LeafKey),
|
||||||
IPLD: ipfs.BlockModel{
|
IPLD: models.IPLDModel{
|
||||||
|
BlockNumber: payload.Block.Number().String(),
|
||||||
Data: storageNode.NodeValue,
|
Data: storageNode.NodeValue,
|
||||||
CID: cid.String(),
|
Key: cid.String(),
|
||||||
},
|
},
|
||||||
Type: storageNode.NodeType,
|
Type: storageNode.NodeType,
|
||||||
Path: storageNode.Path,
|
Path: storageNode.Path,
|
||||||
|
|||||||
+37
-29
@@ -19,15 +19,15 @@ package eth_test
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs"
|
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth/test_helpers"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth/test_helpers"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/shared"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -46,7 +46,7 @@ var _ = Describe("Filterer", func() {
|
|||||||
Expect(iplds).ToNot(BeNil())
|
Expect(iplds).ToNot(BeNil())
|
||||||
Expect(iplds.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
Expect(iplds.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
||||||
Expect(iplds.Header).To(Equal(test_helpers.MockIPLDs.Header))
|
Expect(iplds.Header).To(Equal(test_helpers.MockIPLDs.Header))
|
||||||
var expectedEmptyUncles []ipfs.BlockModel
|
var expectedEmptyUncles []models.IPLDModel
|
||||||
Expect(iplds.Uncles).To(Equal(expectedEmptyUncles))
|
Expect(iplds.Uncles).To(Equal(expectedEmptyUncles))
|
||||||
Expect(len(iplds.Transactions)).To(Equal(4))
|
Expect(len(iplds.Transactions)).To(Equal(4))
|
||||||
Expect(shared.IPLDsContainBytes(iplds.Transactions, test_helpers.Tx1)).To(BeTrue())
|
Expect(shared.IPLDsContainBytes(iplds.Transactions, test_helpers.Tx1)).To(BeTrue())
|
||||||
@@ -60,15 +60,17 @@ var _ = Describe("Filterer", func() {
|
|||||||
for _, stateNode := range iplds.StateNodes {
|
for _, stateNode := range iplds.StateNodes {
|
||||||
Expect(stateNode.Type).To(Equal(sdtypes.Leaf))
|
Expect(stateNode.Type).To(Equal(sdtypes.Leaf))
|
||||||
if bytes.Equal(stateNode.StateLeafKey.Bytes(), test_helpers.AccountLeafKey) {
|
if bytes.Equal(stateNode.StateLeafKey.Bytes(), test_helpers.AccountLeafKey) {
|
||||||
Expect(stateNode.IPLD).To(Equal(ipfs.BlockModel{
|
Expect(stateNode.IPLD).To(Equal(models.IPLDModel{
|
||||||
|
BlockNumber: test_helpers.BlockNumber.String(),
|
||||||
Data: test_helpers.State2IPLD.RawData(),
|
Data: test_helpers.State2IPLD.RawData(),
|
||||||
CID: test_helpers.State2IPLD.Cid().String(),
|
Key: test_helpers.State2IPLD.Cid().String(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
if bytes.Equal(stateNode.StateLeafKey.Bytes(), test_helpers.ContractLeafKey) {
|
if bytes.Equal(stateNode.StateLeafKey.Bytes(), test_helpers.ContractLeafKey) {
|
||||||
Expect(stateNode.IPLD).To(Equal(ipfs.BlockModel{
|
Expect(stateNode.IPLD).To(Equal(models.IPLDModel{
|
||||||
|
BlockNumber: test_helpers.BlockNumber.String(),
|
||||||
Data: test_helpers.State1IPLD.RawData(),
|
Data: test_helpers.State1IPLD.RawData(),
|
||||||
CID: test_helpers.State1IPLD.Cid().String(),
|
Key: test_helpers.State1IPLD.Cid().String(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,67 +82,71 @@ var _ = Describe("Filterer", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(iplds1).ToNot(BeNil())
|
Expect(iplds1).ToNot(BeNil())
|
||||||
Expect(iplds1.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
Expect(iplds1.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
||||||
Expect(iplds1.Header).To(Equal(ipfs.BlockModel{}))
|
Expect(iplds1.Header).To(Equal(models.IPLDModel{}))
|
||||||
Expect(len(iplds1.Uncles)).To(Equal(0))
|
Expect(len(iplds1.Uncles)).To(Equal(0))
|
||||||
Expect(len(iplds1.Transactions)).To(Equal(0))
|
Expect(len(iplds1.Transactions)).To(Equal(0))
|
||||||
Expect(len(iplds1.StorageNodes)).To(Equal(0))
|
Expect(len(iplds1.StorageNodes)).To(Equal(0))
|
||||||
Expect(len(iplds1.StateNodes)).To(Equal(0))
|
Expect(len(iplds1.StateNodes)).To(Equal(0))
|
||||||
Expect(len(iplds1.Receipts)).To(Equal(1))
|
Expect(len(iplds1.Receipts)).To(Equal(1))
|
||||||
Expect(iplds1.Receipts[0]).To(Equal(ipfs.BlockModel{
|
Expect(iplds1.Receipts[0]).To(Equal(models.IPLDModel{
|
||||||
|
BlockNumber: test_helpers.BlockNumber.String(),
|
||||||
Data: test_helpers.Rct1IPLD,
|
Data: test_helpers.Rct1IPLD,
|
||||||
CID: test_helpers.Rct1CID.String(),
|
Key: test_helpers.Rct1CID.String(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
iplds2, err := filterer.Filter(rctTopicsFilter, test_helpers.MockConvertedPayload)
|
iplds2, err := filterer.Filter(rctTopicsFilter, test_helpers.MockConvertedPayload)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(iplds2).ToNot(BeNil())
|
Expect(iplds2).ToNot(BeNil())
|
||||||
Expect(iplds2.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
Expect(iplds2.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
||||||
Expect(iplds2.Header).To(Equal(ipfs.BlockModel{}))
|
Expect(iplds2.Header).To(Equal(models.IPLDModel{}))
|
||||||
Expect(len(iplds2.Uncles)).To(Equal(0))
|
Expect(len(iplds2.Uncles)).To(Equal(0))
|
||||||
Expect(len(iplds2.Transactions)).To(Equal(0))
|
Expect(len(iplds2.Transactions)).To(Equal(0))
|
||||||
Expect(len(iplds2.StorageNodes)).To(Equal(0))
|
Expect(len(iplds2.StorageNodes)).To(Equal(0))
|
||||||
Expect(len(iplds2.StateNodes)).To(Equal(0))
|
Expect(len(iplds2.StateNodes)).To(Equal(0))
|
||||||
Expect(len(iplds2.Receipts)).To(Equal(1))
|
Expect(len(iplds2.Receipts)).To(Equal(1))
|
||||||
Expect(iplds2.Receipts[0]).To(Equal(ipfs.BlockModel{
|
Expect(iplds2.Receipts[0]).To(Equal(models.IPLDModel{
|
||||||
|
BlockNumber: test_helpers.BlockNumber.String(),
|
||||||
Data: test_helpers.Rct1IPLD,
|
Data: test_helpers.Rct1IPLD,
|
||||||
CID: test_helpers.Rct1CID.String(),
|
Key: test_helpers.Rct1CID.String(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
iplds3, err := filterer.Filter(rctTopicsAndAddressFilter, test_helpers.MockConvertedPayload)
|
iplds3, err := filterer.Filter(rctTopicsAndAddressFilter, test_helpers.MockConvertedPayload)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(iplds3).ToNot(BeNil())
|
Expect(iplds3).ToNot(BeNil())
|
||||||
Expect(iplds3.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
Expect(iplds3.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
||||||
Expect(iplds3.Header).To(Equal(ipfs.BlockModel{}))
|
Expect(iplds3.Header).To(Equal(models.IPLDModel{}))
|
||||||
Expect(len(iplds3.Uncles)).To(Equal(0))
|
Expect(len(iplds3.Uncles)).To(Equal(0))
|
||||||
Expect(len(iplds3.Transactions)).To(Equal(0))
|
Expect(len(iplds3.Transactions)).To(Equal(0))
|
||||||
Expect(len(iplds3.StorageNodes)).To(Equal(0))
|
Expect(len(iplds3.StorageNodes)).To(Equal(0))
|
||||||
Expect(len(iplds3.StateNodes)).To(Equal(0))
|
Expect(len(iplds3.StateNodes)).To(Equal(0))
|
||||||
Expect(len(iplds3.Receipts)).To(Equal(1))
|
Expect(len(iplds3.Receipts)).To(Equal(1))
|
||||||
Expect(iplds3.Receipts[0]).To(Equal(ipfs.BlockModel{
|
Expect(iplds3.Receipts[0]).To(Equal(models.IPLDModel{
|
||||||
|
BlockNumber: test_helpers.BlockNumber.String(),
|
||||||
Data: test_helpers.Rct1IPLD,
|
Data: test_helpers.Rct1IPLD,
|
||||||
CID: test_helpers.Rct1CID.String(),
|
Key: test_helpers.Rct1CID.String(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
iplds4, err := filterer.Filter(rctAddressesAndTopicFilter, test_helpers.MockConvertedPayload)
|
iplds4, err := filterer.Filter(rctAddressesAndTopicFilter, test_helpers.MockConvertedPayload)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(iplds4).ToNot(BeNil())
|
Expect(iplds4).ToNot(BeNil())
|
||||||
Expect(iplds4.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
Expect(iplds4.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
||||||
Expect(iplds4.Header).To(Equal(ipfs.BlockModel{}))
|
Expect(iplds4.Header).To(Equal(models.IPLDModel{}))
|
||||||
Expect(len(iplds4.Uncles)).To(Equal(0))
|
Expect(len(iplds4.Uncles)).To(Equal(0))
|
||||||
Expect(len(iplds4.Transactions)).To(Equal(0))
|
Expect(len(iplds4.Transactions)).To(Equal(0))
|
||||||
Expect(len(iplds4.StorageNodes)).To(Equal(0))
|
Expect(len(iplds4.StorageNodes)).To(Equal(0))
|
||||||
Expect(len(iplds4.StateNodes)).To(Equal(0))
|
Expect(len(iplds4.StateNodes)).To(Equal(0))
|
||||||
Expect(len(iplds4.Receipts)).To(Equal(1))
|
Expect(len(iplds4.Receipts)).To(Equal(1))
|
||||||
Expect(iplds4.Receipts[0]).To(Equal(ipfs.BlockModel{
|
Expect(iplds4.Receipts[0]).To(Equal(models.IPLDModel{
|
||||||
|
BlockNumber: test_helpers.BlockNumber.String(),
|
||||||
Data: test_helpers.Rct2IPLD,
|
Data: test_helpers.Rct2IPLD,
|
||||||
CID: test_helpers.Rct2CID.String(),
|
Key: test_helpers.Rct2CID.String(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
iplds5, err := filterer.Filter(rctsForAllCollectedTrxs, test_helpers.MockConvertedPayload)
|
iplds5, err := filterer.Filter(rctsForAllCollectedTrxs, test_helpers.MockConvertedPayload)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(iplds5).ToNot(BeNil())
|
Expect(iplds5).ToNot(BeNil())
|
||||||
Expect(iplds5.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
Expect(iplds5.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
||||||
Expect(iplds5.Header).To(Equal(ipfs.BlockModel{}))
|
Expect(iplds5.Header).To(Equal(models.IPLDModel{}))
|
||||||
Expect(len(iplds5.Uncles)).To(Equal(0))
|
Expect(len(iplds5.Uncles)).To(Equal(0))
|
||||||
Expect(len(iplds5.Transactions)).To(Equal(4))
|
Expect(len(iplds5.Transactions)).To(Equal(4))
|
||||||
Expect(shared.IPLDsContainBytes(iplds5.Transactions, test_helpers.Tx1)).To(BeTrue())
|
Expect(shared.IPLDsContainBytes(iplds5.Transactions, test_helpers.Tx1)).To(BeTrue())
|
||||||
@@ -157,39 +163,41 @@ var _ = Describe("Filterer", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(iplds6).ToNot(BeNil())
|
Expect(iplds6).ToNot(BeNil())
|
||||||
Expect(iplds6.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
Expect(iplds6.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
||||||
Expect(iplds6.Header).To(Equal(ipfs.BlockModel{}))
|
Expect(iplds6.Header).To(Equal(models.IPLDModel{}))
|
||||||
Expect(len(iplds6.Uncles)).To(Equal(0))
|
Expect(len(iplds6.Uncles)).To(Equal(0))
|
||||||
Expect(len(iplds6.Transactions)).To(Equal(1))
|
Expect(len(iplds6.Transactions)).To(Equal(1))
|
||||||
Expect(shared.IPLDsContainBytes(iplds5.Transactions, test_helpers.Tx2)).To(BeTrue())
|
Expect(shared.IPLDsContainBytes(iplds5.Transactions, test_helpers.Tx2)).To(BeTrue())
|
||||||
Expect(len(iplds6.StorageNodes)).To(Equal(0))
|
Expect(len(iplds6.StorageNodes)).To(Equal(0))
|
||||||
Expect(len(iplds6.StateNodes)).To(Equal(0))
|
Expect(len(iplds6.StateNodes)).To(Equal(0))
|
||||||
Expect(len(iplds6.Receipts)).To(Equal(1))
|
Expect(len(iplds6.Receipts)).To(Equal(1))
|
||||||
Expect(iplds4.Receipts[0]).To(Equal(ipfs.BlockModel{
|
Expect(iplds4.Receipts[0]).To(Equal(models.IPLDModel{
|
||||||
|
BlockNumber: test_helpers.BlockNumber.String(),
|
||||||
Data: test_helpers.Rct2IPLD,
|
Data: test_helpers.Rct2IPLD,
|
||||||
CID: test_helpers.Rct2CID.String(),
|
Key: test_helpers.Rct2CID.String(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
iplds7, err := filterer.Filter(stateFilter, test_helpers.MockConvertedPayload)
|
iplds7, err := filterer.Filter(stateFilter, test_helpers.MockConvertedPayload)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(iplds7).ToNot(BeNil())
|
Expect(iplds7).ToNot(BeNil())
|
||||||
Expect(iplds7.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
Expect(iplds7.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
||||||
Expect(iplds7.Header).To(Equal(ipfs.BlockModel{}))
|
Expect(iplds7.Header).To(Equal(models.IPLDModel{}))
|
||||||
Expect(len(iplds7.Uncles)).To(Equal(0))
|
Expect(len(iplds7.Uncles)).To(Equal(0))
|
||||||
Expect(len(iplds7.Transactions)).To(Equal(0))
|
Expect(len(iplds7.Transactions)).To(Equal(0))
|
||||||
Expect(len(iplds7.StorageNodes)).To(Equal(0))
|
Expect(len(iplds7.StorageNodes)).To(Equal(0))
|
||||||
Expect(len(iplds7.Receipts)).To(Equal(0))
|
Expect(len(iplds7.Receipts)).To(Equal(0))
|
||||||
Expect(len(iplds7.StateNodes)).To(Equal(1))
|
Expect(len(iplds7.StateNodes)).To(Equal(1))
|
||||||
Expect(iplds7.StateNodes[0].StateLeafKey.Bytes()).To(Equal(test_helpers.AccountLeafKey))
|
Expect(iplds7.StateNodes[0].StateLeafKey.Bytes()).To(Equal(test_helpers.AccountLeafKey))
|
||||||
Expect(iplds7.StateNodes[0].IPLD).To(Equal(ipfs.BlockModel{
|
Expect(iplds7.StateNodes[0].IPLD).To(Equal(models.IPLDModel{
|
||||||
|
BlockNumber: test_helpers.BlockNumber.String(),
|
||||||
Data: test_helpers.State2IPLD.RawData(),
|
Data: test_helpers.State2IPLD.RawData(),
|
||||||
CID: test_helpers.State2IPLD.Cid().String(),
|
Key: test_helpers.State2IPLD.Cid().String(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
iplds8, err := filterer.Filter(rctTopicsAndAddressFilterFail, test_helpers.MockConvertedPayload)
|
iplds8, err := filterer.Filter(rctTopicsAndAddressFilterFail, test_helpers.MockConvertedPayload)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(iplds8).ToNot(BeNil())
|
Expect(iplds8).ToNot(BeNil())
|
||||||
Expect(iplds8.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
Expect(iplds8.BlockNumber.Int64()).To(Equal(test_helpers.MockIPLDs.BlockNumber.Int64()))
|
||||||
Expect(iplds8.Header).To(Equal(ipfs.BlockModel{}))
|
Expect(iplds8.Header).To(Equal(models.IPLDModel{}))
|
||||||
Expect(len(iplds8.Uncles)).To(Equal(0))
|
Expect(len(iplds8.Uncles)).To(Equal(0))
|
||||||
Expect(len(iplds8.Transactions)).To(Equal(0))
|
Expect(len(iplds8.Transactions)).To(Equal(0))
|
||||||
Expect(len(iplds8.StorageNodes)).To(Equal(0))
|
Expect(len(iplds8.StorageNodes)).To(Equal(0))
|
||||||
|
|||||||
@@ -17,16 +17,7 @@
|
|||||||
package eth
|
package eth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func ResolveToNodeType(nodeType int) sdtypes.NodeType {
|
func ResolveToNodeType(nodeType int) sdtypes.NodeType {
|
||||||
@@ -43,41 +34,3 @@ func ResolveToNodeType(nodeType int) sdtypes.NodeType {
|
|||||||
return sdtypes.Unknown
|
return sdtypes.Unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadConfig loads chain config from json file
|
|
||||||
func LoadConfig(chainConfigPath string) (*params.ChainConfig, error) {
|
|
||||||
file, err := os.Open(chainConfigPath)
|
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("Failed to read chain config file: %v", err)
|
|
||||||
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
chainConfig := new(params.ChainConfig)
|
|
||||||
if err := json.NewDecoder(file).Decode(chainConfig); err != nil {
|
|
||||||
utils.Fatalf("invalid chain config file: %v", err)
|
|
||||||
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Infof("Using chain config from %s file. Content %+v", chainConfigPath, chainConfig)
|
|
||||||
|
|
||||||
return chainConfig, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChainConfig returns the appropriate ethereum chain config for the provided chain id
|
|
||||||
func ChainConfig(chainID uint64) (*params.ChainConfig, error) {
|
|
||||||
switch chainID {
|
|
||||||
case 1:
|
|
||||||
return params.MainnetChainConfig, nil
|
|
||||||
case 3:
|
|
||||||
return params.RopstenChainConfig, nil
|
|
||||||
case 4:
|
|
||||||
return params.RinkebyChainConfig, nil
|
|
||||||
case 5:
|
|
||||||
return params.GoerliChainConfig, nil
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("chain config for chainid %d not available", chainID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+62
-32
@@ -20,14 +20,13 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs"
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/shared"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fetcher interface for substituting mocks in tests
|
// Fetcher interface for substituting mocks in tests
|
||||||
@@ -38,11 +37,11 @@ type Fetcher interface {
|
|||||||
// IPLDFetcher satisfies the IPLDFetcher interface for ethereum
|
// IPLDFetcher satisfies the IPLDFetcher interface for ethereum
|
||||||
// It interfaces directly with PG-IPFS
|
// It interfaces directly with PG-IPFS
|
||||||
type IPLDFetcher struct {
|
type IPLDFetcher struct {
|
||||||
db *postgres.DB
|
db *sqlx.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewIPLDFetcher creates a pointer to a new IPLDFetcher
|
// NewIPLDFetcher creates a pointer to a new IPLDFetcher
|
||||||
func NewIPLDFetcher(db *postgres.DB) *IPLDFetcher {
|
func NewIPLDFetcher(db *sqlx.DB) *IPLDFetcher {
|
||||||
return &IPLDFetcher{
|
return &IPLDFetcher{
|
||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
@@ -101,66 +100,87 @@ func (f *IPLDFetcher) Fetch(cids CIDWrapper) (*IPLDs, error) {
|
|||||||
return iplds, err
|
return iplds, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchHeaders fetches headers
|
// FetchHeader fetches header
|
||||||
func (f *IPLDFetcher) FetchHeader(tx *sqlx.Tx, c models.HeaderModel) (ipfs.BlockModel, error) {
|
func (f *IPLDFetcher) FetchHeader(tx *sqlx.Tx, c models.HeaderModel) (models.IPLDModel, error) {
|
||||||
log.Debug("fetching header ipld")
|
log.Debug("fetching header ipld")
|
||||||
headerBytes, err := shared.FetchIPLDByMhKey(tx, c.MhKey)
|
blockNumber, err := strconv.ParseUint(c.BlockNumber, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ipfs.BlockModel{}, err
|
return models.IPLDModel{}, err
|
||||||
}
|
}
|
||||||
return ipfs.BlockModel{
|
|
||||||
|
headerBytes, err := shared.FetchIPLDByMhKeyAndBlockNumber(tx, c.MhKey, blockNumber)
|
||||||
|
if err != nil {
|
||||||
|
return models.IPLDModel{}, err
|
||||||
|
}
|
||||||
|
return models.IPLDModel{
|
||||||
|
BlockNumber: c.BlockNumber,
|
||||||
Data: headerBytes,
|
Data: headerBytes,
|
||||||
CID: c.CID,
|
Key: c.CID,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchUncles fetches uncles
|
// FetchUncles fetches uncles
|
||||||
func (f *IPLDFetcher) FetchUncles(tx *sqlx.Tx, cids []models.UncleModel) ([]ipfs.BlockModel, error) {
|
func (f *IPLDFetcher) FetchUncles(tx *sqlx.Tx, cids []models.UncleModel) ([]models.IPLDModel, error) {
|
||||||
log.Debug("fetching uncle iplds")
|
log.Debug("fetching uncle iplds")
|
||||||
uncleIPLDs := make([]ipfs.BlockModel, len(cids))
|
uncleIPLDs := make([]models.IPLDModel, len(cids))
|
||||||
for i, c := range cids {
|
for i, c := range cids {
|
||||||
uncleBytes, err := shared.FetchIPLDByMhKey(tx, c.MhKey)
|
blockNumber, err := strconv.ParseUint(c.BlockNumber, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uncleIPLDs[i] = ipfs.BlockModel{
|
uncleBytes, err := shared.FetchIPLDByMhKeyAndBlockNumber(tx, c.MhKey, blockNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
uncleIPLDs[i] = models.IPLDModel{
|
||||||
|
BlockNumber: c.BlockNumber,
|
||||||
Data: uncleBytes,
|
Data: uncleBytes,
|
||||||
CID: c.CID,
|
Key: c.CID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return uncleIPLDs, nil
|
return uncleIPLDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchTrxs fetches transactions
|
// FetchTrxs fetches transactions
|
||||||
func (f *IPLDFetcher) FetchTrxs(tx *sqlx.Tx, cids []models.TxModel) ([]ipfs.BlockModel, error) {
|
func (f *IPLDFetcher) FetchTrxs(tx *sqlx.Tx, cids []models.TxModel) ([]models.IPLDModel, error) {
|
||||||
log.Debug("fetching transaction iplds")
|
log.Debug("fetching transaction iplds")
|
||||||
trxIPLDs := make([]ipfs.BlockModel, len(cids))
|
trxIPLDs := make([]models.IPLDModel, len(cids))
|
||||||
for i, c := range cids {
|
for i, c := range cids {
|
||||||
txBytes, err := shared.FetchIPLDByMhKey(tx, c.MhKey)
|
blockNumber, err := strconv.ParseUint(c.BlockNumber, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
trxIPLDs[i] = ipfs.BlockModel{
|
txBytes, err := shared.FetchIPLDByMhKeyAndBlockNumber(tx, c.MhKey, blockNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
trxIPLDs[i] = models.IPLDModel{
|
||||||
|
BlockNumber: c.BlockNumber,
|
||||||
Data: txBytes,
|
Data: txBytes,
|
||||||
CID: c.CID,
|
Key: c.CID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return trxIPLDs, nil
|
return trxIPLDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchRcts fetches receipts
|
// FetchRcts fetches receipts
|
||||||
func (f *IPLDFetcher) FetchRcts(tx *sqlx.Tx, cids []models.ReceiptModel) ([]ipfs.BlockModel, error) {
|
func (f *IPLDFetcher) FetchRcts(tx *sqlx.Tx, cids []models.ReceiptModel) ([]models.IPLDModel, error) {
|
||||||
log.Debug("fetching receipt iplds")
|
log.Debug("fetching receipt iplds")
|
||||||
rctIPLDs := make([]ipfs.BlockModel, len(cids))
|
rctIPLDs := make([]models.IPLDModel, len(cids))
|
||||||
for i, c := range cids {
|
for i, c := range cids {
|
||||||
rctBytes, err := shared.FetchIPLDByMhKey(tx, c.LeafMhKey)
|
blockNumber, err := strconv.ParseUint(c.BlockNumber, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
rctBytes, err := shared.FetchIPLDByMhKeyAndBlockNumber(tx, c.LeafMhKey, blockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
//nodeVal, err := DecodeLeafNode(rctBytes)
|
//nodeVal, err := DecodeLeafNode(rctBytes)
|
||||||
rctIPLDs[i] = ipfs.BlockModel{
|
rctIPLDs[i] = models.IPLDModel{
|
||||||
|
BlockNumber: c.BlockNumber,
|
||||||
Data: rctBytes,
|
Data: rctBytes,
|
||||||
CID: c.LeafCID,
|
Key: c.LeafCID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rctIPLDs, nil
|
return rctIPLDs, nil
|
||||||
@@ -174,14 +194,19 @@ func (f *IPLDFetcher) FetchState(tx *sqlx.Tx, cids []models.StateNodeModel) ([]S
|
|||||||
if stateNode.CID == "" {
|
if stateNode.CID == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
stateBytes, err := shared.FetchIPLDByMhKey(tx, stateNode.MhKey)
|
blockNumber, err := strconv.ParseUint(stateNode.BlockNumber, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
stateBytes, err := shared.FetchIPLDByMhKeyAndBlockNumber(tx, stateNode.MhKey, blockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
stateNodes = append(stateNodes, StateNode{
|
stateNodes = append(stateNodes, StateNode{
|
||||||
IPLD: ipfs.BlockModel{
|
IPLD: models.IPLDModel{
|
||||||
|
BlockNumber: stateNode.BlockNumber,
|
||||||
Data: stateBytes,
|
Data: stateBytes,
|
||||||
CID: stateNode.CID,
|
Key: stateNode.CID,
|
||||||
},
|
},
|
||||||
StateLeafKey: common.HexToHash(stateNode.StateKey),
|
StateLeafKey: common.HexToHash(stateNode.StateKey),
|
||||||
Type: ResolveToNodeType(stateNode.NodeType),
|
Type: ResolveToNodeType(stateNode.NodeType),
|
||||||
@@ -199,14 +224,19 @@ func (f *IPLDFetcher) FetchStorage(tx *sqlx.Tx, cids []models.StorageNodeWithSta
|
|||||||
if storageNode.CID == "" || storageNode.StateKey == "" {
|
if storageNode.CID == "" || storageNode.StateKey == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
storageBytes, err := shared.FetchIPLDByMhKey(tx, storageNode.MhKey)
|
blockNumber, err := strconv.ParseUint(storageNode.BlockNumber, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
storageBytes, err := shared.FetchIPLDByMhKeyAndBlockNumber(tx, storageNode.MhKey, blockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
storageNodes = append(storageNodes, StorageNode{
|
storageNodes = append(storageNodes, StorageNode{
|
||||||
IPLD: ipfs.BlockModel{
|
IPLD: models.IPLDModel{
|
||||||
|
BlockNumber: storageNode.BlockNumber,
|
||||||
Data: storageBytes,
|
Data: storageBytes,
|
||||||
CID: storageNode.CID,
|
Key: storageNode.CID,
|
||||||
},
|
},
|
||||||
StateLeafKey: common.HexToHash(storageNode.StateKey),
|
StateLeafKey: common.HexToHash(storageNode.StateKey),
|
||||||
StorageLeafKey: common.HexToHash(storageNode.StorageKey),
|
StorageLeafKey: common.HexToHash(storageNode.StorageKey),
|
||||||
|
|||||||
@@ -18,45 +18,44 @@ package eth_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer"
|
"github.com/ethereum/go-ethereum/statediff/indexer/interfaces"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
"github.com/jmoiron/sqlx"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth/test_helpers"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth/test_helpers"
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("IPLDFetcher", func() {
|
var _ = Describe("IPLDFetcher", func() {
|
||||||
var (
|
var (
|
||||||
db *postgres.DB
|
db *sqlx.DB
|
||||||
pubAndIndexer *indexer.StateDiffIndexer
|
pubAndIndexer interfaces.StateDiffIndexer
|
||||||
fetcher *eth.IPLDFetcher
|
fetcher *eth.IPLDFetcher
|
||||||
)
|
)
|
||||||
Describe("Fetch", func() {
|
Describe("Fetch", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
tx *indexer.BlockTx
|
tx interfaces.Batch
|
||||||
)
|
)
|
||||||
db, err = SetupDB()
|
db = shared.SetupDB()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
pubAndIndexer = shared.SetupTestStateDiffIndexer(ctx, params.TestChainConfig, test_helpers.Genesis.Hash())
|
||||||
pubAndIndexer, err = indexer.NewStateDiffIndexer(params.TestChainConfig, db)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
tx, err = pubAndIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
tx, err = pubAndIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||||
for _, node := range test_helpers.MockStateNodes {
|
for _, node := range test_helpers.MockStateNodes {
|
||||||
err = pubAndIndexer.PushStateNode(tx, node)
|
err = pubAndIndexer.PushStateNode(tx, node, test_helpers.MockBlock.Hash().String())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
fetcher = eth.NewIPLDFetcher(db)
|
fetcher = eth.NewIPLDFetcher(db)
|
||||||
|
|
||||||
})
|
})
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
eth.TearDownDB(db)
|
shared.TearDownDB(db)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("Fetches and returns IPLDs for the CIDs provided in the CIDWrapper", func() {
|
It("Fetches and returns IPLDs for the CIDs provided in the CIDWrapper", func() {
|
||||||
|
|||||||
+208
-72
@@ -18,137 +18,239 @@ package eth
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/trie"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
|
"github.com/ethereum/go-ethereum/statediff/trie_helpers"
|
||||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
|
||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// node type removed value.
|
// node type removed value.
|
||||||
// https://github.com/vulcanize/go-ethereum/blob/271f4d01e7e2767ffd8e0cd469bf545be96f2a84/statediff/indexer/helpers.go#L34
|
// https://github.com/cerc-io/go-ethereum/blob/271f4d01e7e2767ffd8e0cd469bf545be96f2a84/statediff/indexer/helpers.go#L34
|
||||||
removedNode = 3
|
removedNode = 3
|
||||||
|
|
||||||
RetrieveHeadersByHashesPgStr = `SELECT cid, data
|
RetrieveHeadersByHashesPgStr = `SELECT cid, data
|
||||||
FROM eth.header_cids
|
FROM eth.header_cids
|
||||||
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
|
INNER JOIN public.blocks ON (
|
||||||
|
header_cids.mh_key = blocks.key
|
||||||
|
AND header_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
WHERE block_hash = ANY($1::VARCHAR(66)[])`
|
WHERE block_hash = ANY($1::VARCHAR(66)[])`
|
||||||
RetrieveHeadersByBlockNumberPgStr = `SELECT cid, data
|
RetrieveHeadersByBlockNumberPgStr = `SELECT cid, data
|
||||||
FROM eth.header_cids
|
FROM eth.header_cids
|
||||||
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
|
INNER JOIN public.blocks ON (
|
||||||
WHERE block_number = $1`
|
header_cids.mh_key = blocks.key
|
||||||
|
AND header_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
|
WHERE header_cids.block_number = $1`
|
||||||
RetrieveHeaderByHashPgStr = `SELECT cid, data
|
RetrieveHeaderByHashPgStr = `SELECT cid, data
|
||||||
FROM eth.header_cids
|
FROM eth.header_cids
|
||||||
INNER JOIN public.blocks ON (header_cids.mh_key = blocks.key)
|
INNER JOIN public.blocks ON (
|
||||||
|
header_cids.mh_key = blocks.key
|
||||||
|
AND header_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
WHERE block_hash = $1`
|
WHERE block_hash = $1`
|
||||||
RetrieveUnclesByHashesPgStr = `SELECT cid, data
|
RetrieveUnclesByHashesPgStr = `SELECT cid, data
|
||||||
FROM eth.uncle_cids
|
FROM eth.uncle_cids
|
||||||
INNER JOIN public.blocks ON (uncle_cids.mh_key = blocks.key)
|
INNER JOIN public.blocks ON (
|
||||||
|
uncle_cids.mh_key = blocks.key
|
||||||
|
AND uncle_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
WHERE block_hash = ANY($1::VARCHAR(66)[])`
|
WHERE block_hash = ANY($1::VARCHAR(66)[])`
|
||||||
RetrieveUnclesByBlockHashPgStr = `SELECT uncle_cids.cid, data
|
RetrieveUnclesByBlockHashPgStr = `SELECT uncle_cids.cid, data
|
||||||
FROM eth.uncle_cids
|
FROM eth.uncle_cids
|
||||||
INNER JOIN eth.header_cids ON (uncle_cids.header_id = header_cids.id)
|
INNER JOIN eth.header_cids ON (
|
||||||
INNER JOIN public.blocks ON (uncle_cids.mh_key = blocks.key)
|
uncle_cids.header_id = header_cids.block_hash
|
||||||
WHERE block_hash = $1`
|
AND uncle_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN public.blocks ON (
|
||||||
|
uncle_cids.mh_key = blocks.key
|
||||||
|
AND uncle_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
|
WHERE header_cids.block_hash = $1
|
||||||
|
ORDER BY uncle_cids.parent_hash`
|
||||||
RetrieveUnclesByBlockNumberPgStr = `SELECT uncle_cids.cid, data
|
RetrieveUnclesByBlockNumberPgStr = `SELECT uncle_cids.cid, data
|
||||||
FROM eth.uncle_cids
|
FROM eth.uncle_cids
|
||||||
INNER JOIN eth.header_cids ON (uncle_cids.header_id = header_cids.id)
|
INNER JOIN eth.header_cids ON (
|
||||||
INNER JOIN public.blocks ON (uncle_cids.mh_key = blocks.key)
|
uncle_cids.header_id = header_cids.block_hash
|
||||||
WHERE block_number = $1`
|
AND uncle_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN public.blocks ON (
|
||||||
|
uncle_cids.mh_key = blocks.key
|
||||||
|
AND uncle_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
|
WHERE header_cids.block_number = $1`
|
||||||
RetrieveUncleByHashPgStr = `SELECT cid, data
|
RetrieveUncleByHashPgStr = `SELECT cid, data
|
||||||
FROM eth.uncle_cids
|
FROM eth.uncle_cids
|
||||||
INNER JOIN public.blocks ON (uncle_cids.mh_key = blocks.key)
|
INNER JOIN public.blocks ON (
|
||||||
|
uncle_cids.mh_key = blocks.key
|
||||||
|
AND uncle_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
WHERE block_hash = $1`
|
WHERE block_hash = $1`
|
||||||
RetrieveTransactionsByHashesPgStr = `SELECT cid, data
|
RetrieveTransactionsByHashesPgStr = `SELECT DISTINCT ON (tx_hash) cid, data
|
||||||
FROM eth.transaction_cids
|
FROM eth.transaction_cids
|
||||||
INNER JOIN public.blocks ON (transaction_cids.mh_key = blocks.key)
|
INNER JOIN public.blocks ON (
|
||||||
|
transaction_cids.mh_key = blocks.key
|
||||||
|
AND transaction_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
WHERE tx_hash = ANY($1::VARCHAR(66)[])`
|
WHERE tx_hash = ANY($1::VARCHAR(66)[])`
|
||||||
RetrieveTransactionsByBlockHashPgStr = `SELECT transaction_cids.cid, data
|
RetrieveTransactionsByBlockHashPgStr = `SELECT transaction_cids.cid, data
|
||||||
FROM eth.transaction_cids
|
FROM eth.transaction_cids
|
||||||
INNER JOIN eth.header_cids ON (transaction_cids.header_id = header_cids.id)
|
INNER JOIN eth.header_cids ON (
|
||||||
INNER JOIN public.blocks ON (transaction_cids.mh_key = blocks.key)
|
transaction_cids.header_id = header_cids.block_hash
|
||||||
|
AND transaction_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN public.blocks ON (
|
||||||
|
transaction_cids.mh_key = blocks.key
|
||||||
|
AND transaction_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
WHERE block_hash = $1
|
WHERE block_hash = $1
|
||||||
ORDER BY eth.transaction_cids.index ASC`
|
ORDER BY eth.transaction_cids.index ASC`
|
||||||
RetrieveTransactionsByBlockNumberPgStr = `SELECT transaction_cids.cid, data
|
RetrieveTransactionsByBlockNumberPgStr = `SELECT transaction_cids.cid, data
|
||||||
FROM eth.transaction_cids
|
FROM eth.transaction_cids
|
||||||
INNER JOIN eth.header_cids ON (transaction_cids.header_id = header_cids.id)
|
INNER JOIN eth.header_cids ON (
|
||||||
INNER JOIN public.blocks ON (transaction_cids.mh_key = blocks.key)
|
transaction_cids.header_id = header_cids.block_hash
|
||||||
WHERE block_number = $1
|
AND transaction_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN public.blocks ON (
|
||||||
|
transaction_cids.mh_key = blocks.key
|
||||||
|
AND transaction_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
|
WHERE header_cids.block_number = $1
|
||||||
|
AND block_hash = (SELECT canonical_header_hash(header_cids.block_number))
|
||||||
ORDER BY eth.transaction_cids.index ASC`
|
ORDER BY eth.transaction_cids.index ASC`
|
||||||
RetrieveTransactionByHashPgStr = `SELECT cid, data
|
RetrieveTransactionByHashPgStr = `SELECT DISTINCT ON (tx_hash) cid, data
|
||||||
FROM eth.transaction_cids
|
FROM eth.transaction_cids
|
||||||
INNER JOIN public.blocks ON (transaction_cids.mh_key = blocks.key)
|
INNER JOIN public.blocks ON (
|
||||||
|
transaction_cids.mh_key = blocks.key
|
||||||
|
AND transaction_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
WHERE tx_hash = $1`
|
WHERE tx_hash = $1`
|
||||||
RetrieveReceiptsByTxHashesPgStr = `SELECT receipt_cids.leaf_cid, data
|
RetrieveReceiptsByTxHashesPgStr = `SELECT receipt_cids.leaf_cid, data
|
||||||
FROM eth.receipt_cids
|
FROM eth.receipt_cids
|
||||||
INNER JOIN eth.transaction_cids ON (receipt_cids.tx_id = transaction_cids.id)
|
INNER JOIN eth.transaction_cids ON (
|
||||||
INNER JOIN public.blocks ON (receipt_cids.leaf_mh_key = blocks.key)
|
receipt_cids.tx_id = transaction_cids.tx_hash
|
||||||
WHERE tx_hash = ANY($1::VARCHAR(66)[])`
|
AND receipt_cids.header_id = transaction_cids.header_id
|
||||||
|
AND receipt_cids.block_number = transaction_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN public.blocks ON (
|
||||||
|
receipt_cids.leaf_mh_key = blocks.key
|
||||||
|
AND receipt_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
|
WHERE tx_hash = ANY($1::VARCHAR(66)[])
|
||||||
|
AND transaction_cids.header_id = (SELECT canonical_header_hash(transaction_cids.block_number))`
|
||||||
RetrieveReceiptsByBlockHashPgStr = `SELECT receipt_cids.leaf_cid, data, eth.transaction_cids.tx_hash
|
RetrieveReceiptsByBlockHashPgStr = `SELECT receipt_cids.leaf_cid, data, eth.transaction_cids.tx_hash
|
||||||
FROM eth.receipt_cids
|
FROM eth.receipt_cids
|
||||||
INNER JOIN eth.transaction_cids ON (receipt_cids.tx_id = transaction_cids.id)
|
INNER JOIN eth.transaction_cids ON (
|
||||||
INNER JOIN eth.header_cids ON (transaction_cids.header_id = header_cids.id)
|
receipt_cids.tx_id = transaction_cids.tx_hash
|
||||||
INNER JOIN public.blocks ON (receipt_cids.leaf_mh_key = blocks.key)
|
AND receipt_cids.header_id = transaction_cids.header_id
|
||||||
|
AND receipt_cids.block_number = transaction_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN eth.header_cids ON (
|
||||||
|
transaction_cids.header_id = header_cids.block_hash
|
||||||
|
AND transaction_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN public.blocks ON (
|
||||||
|
receipt_cids.leaf_mh_key = blocks.key
|
||||||
|
AND receipt_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
WHERE block_hash = $1
|
WHERE block_hash = $1
|
||||||
ORDER BY eth.transaction_cids.index ASC`
|
ORDER BY eth.transaction_cids.index ASC`
|
||||||
RetrieveReceiptsByBlockNumberPgStr = `SELECT receipt_cids.leaf_cid, data
|
RetrieveReceiptsByBlockNumberPgStr = `SELECT receipt_cids.leaf_cid, data
|
||||||
FROM eth.receipt_cids
|
FROM eth.receipt_cids
|
||||||
INNER JOIN eth.transaction_cids ON (receipt_cids.tx_id = transaction_cids.id)
|
INNER JOIN eth.transaction_cids ON (
|
||||||
INNER JOIN eth.header_cids ON (transaction_cids.header_id = header_cids.id)
|
receipt_cids.tx_id = transaction_cids.tx_hash
|
||||||
INNER JOIN public.blocks ON (receipt_cids.leaf_mh_key = blocks.key)
|
AND receipt_cids.header_id = transaction_cids.header_id
|
||||||
WHERE block_number = $1
|
AND receipt_cids.block_number = transaction_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN eth.header_cids ON (
|
||||||
|
transaction_cids.header_id = header_cids.block_hash
|
||||||
|
AND transaction_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN public.blocks ON (
|
||||||
|
receipt_cids.leaf_mh_key = blocks.key
|
||||||
|
AND receipt_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
|
WHERE header_cids.block_number = $1
|
||||||
|
AND block_hash = (SELECT canonical_header_hash(header_cids.block_number))
|
||||||
ORDER BY eth.transaction_cids.index ASC`
|
ORDER BY eth.transaction_cids.index ASC`
|
||||||
RetrieveReceiptByTxHashPgStr = `SELECT receipt_cids.leaf_cid, data
|
RetrieveReceiptByTxHashPgStr = `SELECT receipt_cids.leaf_cid, data
|
||||||
FROM eth.receipt_cids
|
FROM eth.receipt_cids
|
||||||
INNER JOIN eth.transaction_cids ON (receipt_cids.tx_id = transaction_cids.id)
|
INNER JOIN eth.transaction_cids ON (
|
||||||
INNER JOIN public.blocks ON (receipt_cids.leaf_mh_key = blocks.key)
|
receipt_cids.tx_id = transaction_cids.tx_hash
|
||||||
WHERE tx_hash = $1`
|
AND receipt_cids.header_id = transaction_cids.header_id
|
||||||
RetrieveAccountByLeafKeyAndBlockHashPgStr = `SELECT state_cids.cid, data, state_cids.node_type
|
AND receipt_cids.block_number = transaction_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN public.blocks ON (
|
||||||
|
receipt_cids.leaf_mh_key = blocks.key
|
||||||
|
AND receipt_cids.block_number = blocks.block_number
|
||||||
|
)
|
||||||
|
WHERE tx_hash = $1
|
||||||
|
AND transaction_cids.header_id = (SELECT canonical_header_hash(transaction_cids.block_number))`
|
||||||
|
RetrieveAccountByLeafKeyAndBlockHashPgStr = `SELECT state_cids.cid, state_cids.mh_key, state_cids.block_number, state_cids.node_type
|
||||||
FROM eth.state_cids
|
FROM eth.state_cids
|
||||||
INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id)
|
INNER JOIN eth.header_cids ON (
|
||||||
INNER JOIN public.blocks ON (state_cids.mh_key = blocks.key)
|
state_cids.header_id = header_cids.block_hash
|
||||||
|
AND state_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
WHERE state_leaf_key = $1
|
WHERE state_leaf_key = $1
|
||||||
AND block_number <= (SELECT block_number
|
AND header_cids.block_number <= (SELECT block_number
|
||||||
FROM eth.header_cids
|
FROM eth.header_cids
|
||||||
WHERE block_hash = $2)
|
WHERE block_hash = $2)
|
||||||
AND header_cids.id = (SELECT canonical_header_id(block_number))
|
AND header_cids.block_hash = (SELECT canonical_header_hash(header_cids.block_number))
|
||||||
ORDER BY block_number DESC
|
ORDER BY header_cids.block_number DESC
|
||||||
LIMIT 1`
|
LIMIT 1`
|
||||||
RetrieveAccountByLeafKeyAndBlockNumberPgStr = `SELECT state_cids.cid, data, state_cids.node_type
|
RetrieveAccountByLeafKeyAndBlockNumberPgStr = `SELECT state_cids.cid, state_cids.mh_key, state_cids.node_type
|
||||||
FROM eth.state_cids
|
FROM eth.state_cids
|
||||||
INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id)
|
INNER JOIN eth.header_cids ON (
|
||||||
INNER JOIN public.blocks ON (state_cids.mh_key = blocks.key)
|
state_cids.header_id = header_cids.block_hash
|
||||||
|
AND state_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
WHERE state_leaf_key = $1
|
WHERE state_leaf_key = $1
|
||||||
AND block_number <= $2
|
AND header_cids.block_number <= $2
|
||||||
ORDER BY block_number DESC
|
ORDER BY header_cids.block_number DESC
|
||||||
LIMIT 1`
|
LIMIT 1`
|
||||||
RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockNumberPgStr = `SELECT storage_cids.cid, data, storage_cids.node_type, was_state_leaf_removed($1, $3) AS state_leaf_removed
|
RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockNumberPgStr = `SELECT storage_cids.cid, storage_cids.mh_key, storage_cids.node_type, was_state_leaf_removed($1, $3) AS state_leaf_removed
|
||||||
FROM eth.storage_cids
|
FROM eth.storage_cids
|
||||||
INNER JOIN eth.state_cids ON (storage_cids.state_id = state_cids.id)
|
INNER JOIN eth.state_cids ON (
|
||||||
INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id)
|
storage_cids.header_id = state_cids.header_id
|
||||||
INNER JOIN public.blocks ON (storage_cids.mh_key = blocks.key)
|
AND storage_cids.state_path = state_cids.state_path
|
||||||
|
AND storage_cids.block_number = state_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN eth.header_cids ON (
|
||||||
|
state_cids.header_id = header_cids.block_hash
|
||||||
|
AND state_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
WHERE state_leaf_key = $1
|
WHERE state_leaf_key = $1
|
||||||
AND storage_leaf_key = $2
|
AND storage_leaf_key = $2
|
||||||
AND block_number <= $3
|
AND header_cids.block_number <= $3
|
||||||
ORDER BY block_number DESC
|
ORDER BY header_cids.block_number DESC
|
||||||
LIMIT 1`
|
LIMIT 1`
|
||||||
RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr = `SELECT storage_cids.cid, data, storage_cids.node_type, was_state_leaf_removed($1, $3) AS state_leaf_removed
|
RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr = `SELECT storage_cids.cid, storage_cids.mh_key, storage_cids.block_number, storage_cids.node_type, was_state_leaf_removed($1, $3) AS state_leaf_removed
|
||||||
FROM eth.storage_cids
|
FROM eth.storage_cids
|
||||||
INNER JOIN eth.state_cids ON (storage_cids.state_id = state_cids.id)
|
INNER JOIN eth.state_cids ON (
|
||||||
INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id)
|
storage_cids.header_id = state_cids.header_id
|
||||||
INNER JOIN public.blocks ON (storage_cids.mh_key = blocks.key)
|
AND storage_cids.state_path = state_cids.state_path
|
||||||
|
AND storage_cids.block_number = state_cids.block_number
|
||||||
|
)
|
||||||
|
INNER JOIN eth.header_cids ON (
|
||||||
|
state_cids.header_id = header_cids.block_hash
|
||||||
|
AND state_cids.block_number = header_cids.block_number
|
||||||
|
)
|
||||||
WHERE state_leaf_key = $1
|
WHERE state_leaf_key = $1
|
||||||
AND storage_leaf_key = $2
|
AND storage_leaf_key = $2
|
||||||
AND block_number <= (SELECT block_number
|
AND header_cids.block_number <= (SELECT block_number
|
||||||
FROM eth.header_cids
|
FROM eth.header_cids
|
||||||
WHERE block_hash = $3)
|
WHERE block_hash = $3)
|
||||||
AND header_cids.id = (SELECT canonical_header_id(block_number))
|
AND header_cids.block_hash = (SELECT canonical_header_hash(header_cids.block_number))
|
||||||
ORDER BY block_number DESC
|
ORDER BY header_cids.block_number DESC
|
||||||
LIMIT 1`
|
LIMIT 1`
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -167,10 +269,10 @@ type ipldResult struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IPLDRetriever struct {
|
type IPLDRetriever struct {
|
||||||
db *postgres.DB
|
db *sqlx.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIPLDRetriever(db *postgres.DB) *IPLDRetriever {
|
func NewIPLDRetriever(db *sqlx.DB) *IPLDRetriever {
|
||||||
return &IPLDRetriever{
|
return &IPLDRetriever{
|
||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
@@ -212,9 +314,9 @@ func (r *IPLDRetriever) RetrieveHeadersByBlockNumber(number uint64) ([]string, [
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveHeaderByHash returns the cid and rlp bytes for the header corresponding to the provided block hash
|
// RetrieveHeaderByHash returns the cid and rlp bytes for the header corresponding to the provided block hash
|
||||||
func (r *IPLDRetriever) RetrieveHeaderByHash(hash common.Hash) (string, []byte, error) {
|
func (r *IPLDRetriever) RetrieveHeaderByHash(tx *sqlx.Tx, hash common.Hash) (string, []byte, error) {
|
||||||
headerResult := new(ipldResult)
|
headerResult := new(ipldResult)
|
||||||
return headerResult.CID, headerResult.Data, r.db.Get(headerResult, RetrieveHeaderByHashPgStr, hash.Hex())
|
return headerResult.CID, headerResult.Data, tx.Get(headerResult, RetrieveHeaderByHashPgStr, hash.Hex())
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveUnclesByHashes returns the cids and rlp bytes for the uncles corresponding to the provided uncle hashes
|
// RetrieveUnclesByHashes returns the cids and rlp bytes for the uncles corresponding to the provided uncle hashes
|
||||||
@@ -237,9 +339,9 @@ func (r *IPLDRetriever) RetrieveUnclesByHashes(hashes []common.Hash) ([]string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveUnclesByBlockHash returns the cids and rlp bytes for the uncles corresponding to the provided block hash (of non-omner root block)
|
// RetrieveUnclesByBlockHash returns the cids and rlp bytes for the uncles corresponding to the provided block hash (of non-omner root block)
|
||||||
func (r *IPLDRetriever) RetrieveUnclesByBlockHash(hash common.Hash) ([]string, [][]byte, error) {
|
func (r *IPLDRetriever) RetrieveUnclesByBlockHash(tx *sqlx.Tx, hash common.Hash) ([]string, [][]byte, error) {
|
||||||
uncleResults := make([]ipldResult, 0)
|
uncleResults := make([]ipldResult, 0)
|
||||||
if err := r.db.Select(&uncleResults, RetrieveUnclesByBlockHashPgStr, hash.Hex()); err != nil {
|
if err := tx.Select(&uncleResults, RetrieveUnclesByBlockHashPgStr, hash.Hex()); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
cids := make([]string, len(uncleResults))
|
cids := make([]string, len(uncleResults))
|
||||||
@@ -292,9 +394,9 @@ func (r *IPLDRetriever) RetrieveTransactionsByHashes(hashes []common.Hash) ([]st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RetrieveTransactionsByBlockHash returns the cids and rlp bytes for the transactions corresponding to the provided block hash
|
// RetrieveTransactionsByBlockHash returns the cids and rlp bytes for the transactions corresponding to the provided block hash
|
||||||
func (r *IPLDRetriever) RetrieveTransactionsByBlockHash(hash common.Hash) ([]string, [][]byte, error) {
|
func (r *IPLDRetriever) RetrieveTransactionsByBlockHash(tx *sqlx.Tx, hash common.Hash) ([]string, [][]byte, error) {
|
||||||
txResults := make([]ipldResult, 0)
|
txResults := make([]ipldResult, 0)
|
||||||
if err := r.db.Select(&txResults, RetrieveTransactionsByBlockHashPgStr, hash.Hex()); err != nil {
|
if err := tx.Select(&txResults, RetrieveTransactionsByBlockHashPgStr, hash.Hex()); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
cids := make([]string, len(txResults))
|
cids := make([]string, len(txResults))
|
||||||
@@ -333,7 +435,7 @@ func DecodeLeafNode(node []byte) ([]byte, error) {
|
|||||||
if err := rlp.DecodeBytes(node, &nodeElements); err != nil {
|
if err := rlp.DecodeBytes(node, &nodeElements); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ty, err := trie.CheckKeyType(nodeElements)
|
ty, err := trie_helpers.CheckKeyType(nodeElements)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -369,9 +471,9 @@ func (r *IPLDRetriever) RetrieveReceiptsByTxHashes(hashes []common.Hash) ([]stri
|
|||||||
|
|
||||||
// RetrieveReceiptsByBlockHash returns the cids and rlp bytes for the receipts corresponding to the provided block hash.
|
// RetrieveReceiptsByBlockHash returns the cids and rlp bytes for the receipts corresponding to the provided block hash.
|
||||||
// cid returned corresponds to the leaf node data which contains the receipt.
|
// cid returned corresponds to the leaf node data which contains the receipt.
|
||||||
func (r *IPLDRetriever) RetrieveReceiptsByBlockHash(hash common.Hash) ([]string, [][]byte, []common.Hash, error) {
|
func (r *IPLDRetriever) RetrieveReceiptsByBlockHash(tx *sqlx.Tx, hash common.Hash) ([]string, [][]byte, []common.Hash, error) {
|
||||||
rctResults := make([]rctIpldResult, 0)
|
rctResults := make([]rctIpldResult, 0)
|
||||||
if err := r.db.Select(&rctResults, RetrieveReceiptsByBlockHashPgStr, hash.Hex()); err != nil {
|
if err := tx.Select(&rctResults, RetrieveReceiptsByBlockHashPgStr, hash.Hex()); err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
cids := make([]string, len(rctResults))
|
cids := make([]string, len(rctResults))
|
||||||
@@ -428,6 +530,8 @@ func (r *IPLDRetriever) RetrieveReceiptByHash(hash common.Hash) (string, []byte,
|
|||||||
|
|
||||||
type nodeInfo struct {
|
type nodeInfo struct {
|
||||||
CID string `db:"cid"`
|
CID string `db:"cid"`
|
||||||
|
MhKey string `db:"mh_key"`
|
||||||
|
BlockNumber string `db:"block_number"`
|
||||||
Data []byte `db:"data"`
|
Data []byte `db:"data"`
|
||||||
NodeType int `db:"node_type"`
|
NodeType int `db:"node_type"`
|
||||||
StateLeafRemoved bool `db:"state_leaf_removed"`
|
StateLeafRemoved bool `db:"state_leaf_removed"`
|
||||||
@@ -446,6 +550,15 @@ func (r *IPLDRetriever) RetrieveAccountByAddressAndBlockHash(address common.Addr
|
|||||||
return "", EmptyNodeValue, nil
|
return "", EmptyNodeValue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockNumber, err := strconv.ParseUint(accountResult.BlockNumber, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
accountResult.Data, err = shared.FetchIPLD(r.db, accountResult.MhKey, blockNumber)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var i []interface{}
|
var i []interface{}
|
||||||
if err := rlp.DecodeBytes(accountResult.Data, &i); err != nil {
|
if err := rlp.DecodeBytes(accountResult.Data, &i); err != nil {
|
||||||
return "", nil, fmt.Errorf("error decoding state leaf node rlp: %s", err.Error())
|
return "", nil, fmt.Errorf("error decoding state leaf node rlp: %s", err.Error())
|
||||||
@@ -469,6 +582,12 @@ func (r *IPLDRetriever) RetrieveAccountByAddressAndBlockNumber(address common.Ad
|
|||||||
return "", EmptyNodeValue, nil
|
return "", EmptyNodeValue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
accountResult.Data, err = shared.FetchIPLD(r.db, accountResult.MhKey, number)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var i []interface{}
|
var i []interface{}
|
||||||
if err := rlp.DecodeBytes(accountResult.Data, &i); err != nil {
|
if err := rlp.DecodeBytes(accountResult.Data, &i); err != nil {
|
||||||
return "", nil, fmt.Errorf("error decoding state leaf node rlp: %s", err.Error())
|
return "", nil, fmt.Errorf("error decoding state leaf node rlp: %s", err.Error())
|
||||||
@@ -490,6 +609,16 @@ func (r *IPLDRetriever) RetrieveStorageAtByAddressAndStorageSlotAndBlockHash(add
|
|||||||
if storageResult.StateLeafRemoved || storageResult.NodeType == removedNode {
|
if storageResult.StateLeafRemoved || storageResult.NodeType == removedNode {
|
||||||
return "", EmptyNodeValue, EmptyNodeValue, nil
|
return "", EmptyNodeValue, EmptyNodeValue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockNumber, err := strconv.ParseUint(storageResult.BlockNumber, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, nil, err
|
||||||
|
}
|
||||||
|
storageResult.Data, err = shared.FetchIPLD(r.db, storageResult.MhKey, blockNumber)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var i []interface{}
|
var i []interface{}
|
||||||
if err := rlp.DecodeBytes(storageResult.Data, &i); err != nil {
|
if err := rlp.DecodeBytes(storageResult.Data, &i); err != nil {
|
||||||
err = fmt.Errorf("error decoding storage leaf node rlp: %s", err.Error())
|
err = fmt.Errorf("error decoding storage leaf node rlp: %s", err.Error())
|
||||||
@@ -513,6 +642,13 @@ func (r *IPLDRetriever) RetrieveStorageAtByAddressAndStorageKeyAndBlockNumber(ad
|
|||||||
if storageResult.StateLeafRemoved || storageResult.NodeType == removedNode {
|
if storageResult.StateLeafRemoved || storageResult.NodeType == removedNode {
|
||||||
return "", EmptyNodeValue, nil
|
return "", EmptyNodeValue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
storageResult.Data, err = shared.FetchIPLD(r.db, storageResult.MhKey, number)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var i []interface{}
|
var i []interface{}
|
||||||
if err := rlp.DecodeBytes(storageResult.Data, &i); err != nil {
|
if err := rlp.DecodeBytes(storageResult.Data, &i); err != nil {
|
||||||
return "", nil, fmt.Errorf("error decoding storage leaf node rlp: %s", err.Error())
|
return "", nil, fmt.Errorf("error decoding storage leaf node rlp: %s", err.Error())
|
||||||
|
|||||||
@@ -18,34 +18,8 @@ package eth
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
|
||||||
. "github.com/onsi/gomega"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TearDownDB is used to tear down the watcher dbs after tests
|
|
||||||
func TearDownDB(db *postgres.DB) {
|
|
||||||
tx, err := db.Beginx()
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
|
|
||||||
_, err = tx.Exec(`DELETE FROM eth.header_cids`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
_, err = tx.Exec(`DELETE FROM eth.transaction_cids`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
_, err = tx.Exec(`DELETE FROM eth.receipt_cids`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
_, err = tx.Exec(`DELETE FROM eth.state_cids`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
_, err = tx.Exec(`DELETE FROM eth.storage_cids`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
_, err = tx.Exec(`DELETE FROM blocks`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
_, err = tx.Exec(`DELETE FROM eth.log_cids`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
|
|
||||||
err = tx.Commit()
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
}
|
|
||||||
|
|
||||||
// TxModelsContainsCID used to check if a list of TxModels contains a specific cid string
|
// TxModelsContainsCID used to check if a list of TxModels contains a specific cid string
|
||||||
func TxModelsContainsCID(txs []models.TxModel, cid string) bool {
|
func TxModelsContainsCID(txs []models.TxModel, cid string) bool {
|
||||||
for _, tx := range txs {
|
for _, tx := range txs {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
"github.com/ethereum/go-ethereum/statediff/test_helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Test variables
|
// Test variables
|
||||||
@@ -35,7 +36,7 @@ var (
|
|||||||
TestBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
TestBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||||
TestBankAddress = crypto.PubkeyToAddress(TestBankKey.PublicKey) //0x71562b71999873DB5b286dF957af199Ec94617F7
|
TestBankAddress = crypto.PubkeyToAddress(TestBankKey.PublicKey) //0x71562b71999873DB5b286dF957af199Ec94617F7
|
||||||
TestBankFunds = big.NewInt(100000000)
|
TestBankFunds = big.NewInt(100000000)
|
||||||
Genesis = core.GenesisBlockForTesting(Testdb, TestBankAddress, TestBankFunds)
|
Genesis = test_helpers.GenesisBlockForTesting(Testdb, TestBankAddress, TestBankFunds)
|
||||||
|
|
||||||
Account1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
|
Account1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
|
||||||
Account2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
|
Account2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
|
||||||
|
|||||||
@@ -28,26 +28,22 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer"
|
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs"
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs/ipld"
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/shared"
|
"github.com/ethereum/go-ethereum/statediff/indexer/shared"
|
||||||
"github.com/ethereum/go-ethereum/statediff/testhelpers"
|
testhelpers "github.com/ethereum/go-ethereum/statediff/test_helpers"
|
||||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
blocks "github.com/ipfs/go-block-format"
|
blocks "github.com/ipfs/go-block-format"
|
||||||
"github.com/multiformats/go-multihash"
|
"github.com/multiformats/go-multihash"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Test variables
|
// Test variables
|
||||||
var (
|
var (
|
||||||
// block data
|
// block data
|
||||||
db *postgres.DB
|
|
||||||
BlockNumber = big.NewInt(1)
|
BlockNumber = big.NewInt(1)
|
||||||
MockHeader = types.Header{
|
MockHeader = types.Header{
|
||||||
Time: 0,
|
Time: 0,
|
||||||
@@ -235,6 +231,7 @@ var (
|
|||||||
}
|
}
|
||||||
MockTrxMetaPostPublsh = []models.TxModel{
|
MockTrxMetaPostPublsh = []models.TxModel{
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
CID: Trx1CID.String(), // This is empty until we go to publish to ipfs
|
CID: Trx1CID.String(), // This is empty until we go to publish to ipfs
|
||||||
MhKey: Trx1MhKey,
|
MhKey: Trx1MhKey,
|
||||||
Src: SenderAddr.Hex(),
|
Src: SenderAddr.Hex(),
|
||||||
@@ -244,6 +241,7 @@ var (
|
|||||||
Data: []byte{},
|
Data: []byte{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
CID: Trx2CID.String(),
|
CID: Trx2CID.String(),
|
||||||
MhKey: Trx2MhKey,
|
MhKey: Trx2MhKey,
|
||||||
Src: SenderAddr.Hex(),
|
Src: SenderAddr.Hex(),
|
||||||
@@ -253,6 +251,7 @@ var (
|
|||||||
Data: []byte{},
|
Data: []byte{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
CID: Trx3CID.String(),
|
CID: Trx3CID.String(),
|
||||||
MhKey: Trx3MhKey,
|
MhKey: Trx3MhKey,
|
||||||
Src: SenderAddr.Hex(),
|
Src: SenderAddr.Hex(),
|
||||||
@@ -262,6 +261,7 @@ var (
|
|||||||
Data: MockContractByteCode,
|
Data: MockContractByteCode,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
CID: Trx4CID.String(),
|
CID: Trx4CID.String(),
|
||||||
MhKey: Trx4MhKey,
|
MhKey: Trx4MhKey,
|
||||||
Src: SenderAddr.Hex(),
|
Src: SenderAddr.Hex(),
|
||||||
@@ -300,24 +300,32 @@ var (
|
|||||||
|
|
||||||
MockRctMetaPostPublish = []models.ReceiptModel{
|
MockRctMetaPostPublish = []models.ReceiptModel{
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
|
HeaderID: MockBlock.Hash().String(),
|
||||||
LeafCID: Rct1CID.String(),
|
LeafCID: Rct1CID.String(),
|
||||||
LeafMhKey: Rct1MhKey,
|
LeafMhKey: Rct1MhKey,
|
||||||
Contract: "",
|
Contract: "",
|
||||||
ContractHash: "",
|
ContractHash: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
|
HeaderID: MockBlock.Hash().String(),
|
||||||
LeafCID: Rct2CID.String(),
|
LeafCID: Rct2CID.String(),
|
||||||
LeafMhKey: Rct2MhKey,
|
LeafMhKey: Rct2MhKey,
|
||||||
Contract: "",
|
Contract: "",
|
||||||
ContractHash: "",
|
ContractHash: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
|
HeaderID: MockBlock.Hash().String(),
|
||||||
LeafCID: Rct3CID.String(),
|
LeafCID: Rct3CID.String(),
|
||||||
LeafMhKey: Rct3MhKey,
|
LeafMhKey: Rct3MhKey,
|
||||||
Contract: ContractAddress.String(),
|
Contract: ContractAddress.String(),
|
||||||
ContractHash: ContractHash,
|
ContractHash: ContractHash,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
|
HeaderID: MockBlock.Hash().String(),
|
||||||
LeafCID: Rct4CID.String(),
|
LeafCID: Rct4CID.String(),
|
||||||
LeafMhKey: Rct4MhKey,
|
LeafMhKey: Rct4MhKey,
|
||||||
Contract: "",
|
Contract: "",
|
||||||
@@ -330,7 +338,7 @@ var (
|
|||||||
StorageLeafKey = crypto.Keccak256Hash(storageLocation[:]).Bytes()
|
StorageLeafKey = crypto.Keccak256Hash(storageLocation[:]).Bytes()
|
||||||
StorageValue = crypto.Keccak256([]byte{1, 2, 3, 4, 5})
|
StorageValue = crypto.Keccak256([]byte{1, 2, 3, 4, 5})
|
||||||
StoragePartialPath = common.Hex2Bytes("20290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563")
|
StoragePartialPath = common.Hex2Bytes("20290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563")
|
||||||
StorageLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
StorageLeafNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||||
StoragePartialPath,
|
StoragePartialPath,
|
||||||
StorageValue,
|
StorageValue,
|
||||||
})
|
})
|
||||||
@@ -340,14 +348,14 @@ var (
|
|||||||
ContractCodeHash = crypto.Keccak256Hash(MockContractByteCode)
|
ContractCodeHash = crypto.Keccak256Hash(MockContractByteCode)
|
||||||
contractPath = common.Bytes2Hex([]byte{'\x06'})
|
contractPath = common.Bytes2Hex([]byte{'\x06'})
|
||||||
ContractLeafKey = testhelpers.AddressToLeafKey(ContractAddress)
|
ContractLeafKey = testhelpers.AddressToLeafKey(ContractAddress)
|
||||||
ContractAccount, _ = rlp.EncodeToBytes(types.StateAccount{
|
ContractAccount, _ = rlp.EncodeToBytes(&types.StateAccount{
|
||||||
Nonce: nonce1,
|
Nonce: nonce1,
|
||||||
Balance: big.NewInt(0),
|
Balance: big.NewInt(0),
|
||||||
CodeHash: ContractCodeHash.Bytes(),
|
CodeHash: ContractCodeHash.Bytes(),
|
||||||
Root: common.HexToHash(ContractRoot),
|
Root: common.HexToHash(ContractRoot),
|
||||||
})
|
})
|
||||||
ContractPartialPath = common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45")
|
ContractPartialPath = common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45")
|
||||||
ContractLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
ContractLeafNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||||
ContractPartialPath,
|
ContractPartialPath,
|
||||||
ContractAccount,
|
ContractAccount,
|
||||||
})
|
})
|
||||||
@@ -358,14 +366,14 @@ var (
|
|||||||
AccountCodeHash = common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
|
AccountCodeHash = common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
|
||||||
AccountAddresss = common.HexToAddress("0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e")
|
AccountAddresss = common.HexToAddress("0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e")
|
||||||
AccountLeafKey = testhelpers.Account2LeafKey
|
AccountLeafKey = testhelpers.Account2LeafKey
|
||||||
Account, _ = rlp.EncodeToBytes(types.StateAccount{
|
Account, _ = rlp.EncodeToBytes(&types.StateAccount{
|
||||||
Nonce: nonce0,
|
Nonce: nonce0,
|
||||||
Balance: AccountBalance,
|
Balance: AccountBalance,
|
||||||
CodeHash: AccountCodeHash.Bytes(),
|
CodeHash: AccountCodeHash.Bytes(),
|
||||||
Root: common.HexToHash(AccountRoot),
|
Root: common.HexToHash(AccountRoot),
|
||||||
})
|
})
|
||||||
AccountPartialPath = common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45")
|
AccountPartialPath = common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45")
|
||||||
AccountLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
AccountLeafNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||||
AccountPartialPath,
|
AccountPartialPath,
|
||||||
Account,
|
Account,
|
||||||
})
|
})
|
||||||
@@ -395,6 +403,7 @@ var (
|
|||||||
}
|
}
|
||||||
MockStateMetaPostPublish = []models.StateNodeModel{
|
MockStateMetaPostPublish = []models.StateNodeModel{
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
CID: State1CID.String(),
|
CID: State1CID.String(),
|
||||||
MhKey: State1MhKey,
|
MhKey: State1MhKey,
|
||||||
Path: []byte{'\x06'},
|
Path: []byte{'\x06'},
|
||||||
@@ -402,6 +411,7 @@ var (
|
|||||||
StateKey: common.BytesToHash(ContractLeafKey).Hex(),
|
StateKey: common.BytesToHash(ContractLeafKey).Hex(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
CID: State2CID.String(),
|
CID: State2CID.String(),
|
||||||
MhKey: State2MhKey,
|
MhKey: State2MhKey,
|
||||||
Path: []byte{'\x0c'},
|
Path: []byte{'\x0c'},
|
||||||
@@ -439,8 +449,7 @@ var (
|
|||||||
StateNodes: MockStateNodes,
|
StateNodes: MockStateNodes,
|
||||||
}
|
}
|
||||||
|
|
||||||
Reward = indexer.CalcEthBlockReward(MockBlock.Header(), MockBlock.Uncles(), MockBlock.Transactions(), MockReceipts)
|
Reward = shared.CalcEthBlockReward(MockBlock.Header(), MockBlock.Uncles(), MockBlock.Transactions(), MockReceipts)
|
||||||
|
|
||||||
MockCIDWrapper = ð.CIDWrapper{
|
MockCIDWrapper = ð.CIDWrapper{
|
||||||
BlockNumber: new(big.Int).Set(BlockNumber),
|
BlockNumber: new(big.Int).Set(BlockNumber),
|
||||||
Header: models.HeaderModel{
|
Header: models.HeaderModel{
|
||||||
@@ -458,6 +467,7 @@ var (
|
|||||||
Bloom: MockBlock.Bloom().Bytes(),
|
Bloom: MockBlock.Bloom().Bytes(),
|
||||||
Timestamp: MockBlock.Time(),
|
Timestamp: MockBlock.Time(),
|
||||||
TimesValidated: 1,
|
TimesValidated: 1,
|
||||||
|
Coinbase: "0x0000000000000000000000000000000000000000",
|
||||||
},
|
},
|
||||||
Transactions: MockTrxMetaPostPublsh,
|
Transactions: MockTrxMetaPostPublsh,
|
||||||
Receipts: MockRctMetaPostPublish,
|
Receipts: MockRctMetaPostPublish,
|
||||||
@@ -465,6 +475,7 @@ var (
|
|||||||
StateNodes: MockStateMetaPostPublish,
|
StateNodes: MockStateMetaPostPublish,
|
||||||
StorageNodes: []models.StorageNodeWithStateKeyModel{
|
StorageNodes: []models.StorageNodeWithStateKeyModel{
|
||||||
{
|
{
|
||||||
|
BlockNumber: "1",
|
||||||
Path: []byte{},
|
Path: []byte{},
|
||||||
CID: StorageCID.String(),
|
CID: StorageCID.String(),
|
||||||
MhKey: StorageMhKey,
|
MhKey: StorageMhKey,
|
||||||
@@ -486,62 +497,73 @@ var (
|
|||||||
|
|
||||||
MockIPLDs = eth.IPLDs{
|
MockIPLDs = eth.IPLDs{
|
||||||
BlockNumber: new(big.Int).Set(BlockNumber),
|
BlockNumber: new(big.Int).Set(BlockNumber),
|
||||||
Header: ipfs.BlockModel{
|
Header: models.IPLDModel{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: HeaderIPLD.RawData(),
|
Data: HeaderIPLD.RawData(),
|
||||||
CID: HeaderIPLD.Cid().String(),
|
Key: HeaderIPLD.Cid().String(),
|
||||||
},
|
},
|
||||||
Transactions: []ipfs.BlockModel{
|
Transactions: []models.IPLDModel{
|
||||||
{
|
{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: Trx1IPLD.RawData(),
|
Data: Trx1IPLD.RawData(),
|
||||||
CID: Trx1IPLD.Cid().String(),
|
Key: Trx1IPLD.Cid().String(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: Trx2IPLD.RawData(),
|
Data: Trx2IPLD.RawData(),
|
||||||
CID: Trx2IPLD.Cid().String(),
|
Key: Trx2IPLD.Cid().String(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: Trx3IPLD.RawData(),
|
Data: Trx3IPLD.RawData(),
|
||||||
CID: Trx3IPLD.Cid().String(),
|
Key: Trx3IPLD.Cid().String(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: Trx4IPLD.RawData(),
|
Data: Trx4IPLD.RawData(),
|
||||||
CID: Trx4IPLD.Cid().String(),
|
Key: Trx4IPLD.Cid().String(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Receipts: []ipfs.BlockModel{
|
Receipts: []models.IPLDModel{
|
||||||
{
|
{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: Rct1IPLD,
|
Data: Rct1IPLD,
|
||||||
CID: Rct1CID.String(),
|
Key: Rct1CID.String(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: Rct2IPLD,
|
Data: Rct2IPLD,
|
||||||
CID: Rct2CID.String(),
|
Key: Rct2CID.String(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: Rct3IPLD,
|
Data: Rct3IPLD,
|
||||||
CID: Rct3CID.String(),
|
Key: Rct3CID.String(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: Rct4IPLD,
|
Data: Rct4IPLD,
|
||||||
CID: Rct4CID.String(),
|
Key: Rct4CID.String(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
StateNodes: []eth.StateNode{
|
StateNodes: []eth.StateNode{
|
||||||
{
|
{
|
||||||
StateLeafKey: common.BytesToHash(ContractLeafKey),
|
StateLeafKey: common.BytesToHash(ContractLeafKey),
|
||||||
Type: sdtypes.Leaf,
|
Type: sdtypes.Leaf,
|
||||||
IPLD: ipfs.BlockModel{
|
IPLD: models.IPLDModel{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: State1IPLD.RawData(),
|
Data: State1IPLD.RawData(),
|
||||||
CID: State1IPLD.Cid().String(),
|
Key: State1IPLD.Cid().String(),
|
||||||
},
|
},
|
||||||
Path: []byte{'\x06'},
|
Path: []byte{'\x06'},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
StateLeafKey: common.BytesToHash(AccountLeafKey),
|
StateLeafKey: common.BytesToHash(AccountLeafKey),
|
||||||
Type: sdtypes.Leaf,
|
Type: sdtypes.Leaf,
|
||||||
IPLD: ipfs.BlockModel{
|
IPLD: models.IPLDModel{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: State2IPLD.RawData(),
|
Data: State2IPLD.RawData(),
|
||||||
CID: State2IPLD.Cid().String(),
|
Key: State2IPLD.Cid().String(),
|
||||||
},
|
},
|
||||||
Path: []byte{'\x0c'},
|
Path: []byte{'\x0c'},
|
||||||
},
|
},
|
||||||
@@ -551,9 +573,10 @@ var (
|
|||||||
StateLeafKey: common.BytesToHash(ContractLeafKey),
|
StateLeafKey: common.BytesToHash(ContractLeafKey),
|
||||||
StorageLeafKey: common.BytesToHash(StorageLeafKey),
|
StorageLeafKey: common.BytesToHash(StorageLeafKey),
|
||||||
Type: sdtypes.Leaf,
|
Type: sdtypes.Leaf,
|
||||||
IPLD: ipfs.BlockModel{
|
IPLD: models.IPLDModel{
|
||||||
|
BlockNumber: BlockNumber.String(),
|
||||||
Data: StorageIPLD.RawData(),
|
Data: StorageIPLD.RawData(),
|
||||||
CID: StorageIPLD.Cid().String(),
|
Key: StorageIPLD.Cid().String(),
|
||||||
},
|
},
|
||||||
Path: []byte{},
|
Path: []byte{},
|
||||||
},
|
},
|
||||||
@@ -571,7 +594,29 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
MockLondonTransactions, MockLondonReceipts, _ = createDynamicTransactionsAndReceipts(LondonBlockNum)
|
MockLondonTransactions, MockLondonReceipts, _ = createDynamicTransactionsAndReceipts(LondonBlockNum)
|
||||||
MockLondonBlock = createNewBlock(&MockLondonHeader, MockLondonTransactions, nil, MockLondonReceipts, new(trie.Trie))
|
MockLondonUncles = []*types.Header{
|
||||||
|
{
|
||||||
|
Time: 1,
|
||||||
|
Number: new(big.Int).Add(BlockNumber, big.NewInt(1)),
|
||||||
|
ParentHash: common.HexToHash("0x2"),
|
||||||
|
Root: common.HexToHash("0x1"),
|
||||||
|
TxHash: common.HexToHash("0x1"),
|
||||||
|
ReceiptHash: common.HexToHash("0x1"),
|
||||||
|
Difficulty: big.NewInt(500001),
|
||||||
|
Extra: []byte{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Time: 2,
|
||||||
|
Number: new(big.Int).Add(BlockNumber, big.NewInt(1)),
|
||||||
|
ParentHash: common.HexToHash("0x1"),
|
||||||
|
Root: common.HexToHash("0x2"),
|
||||||
|
TxHash: common.HexToHash("0x2"),
|
||||||
|
ReceiptHash: common.HexToHash("0x2"),
|
||||||
|
Difficulty: big.NewInt(500002),
|
||||||
|
Extra: []byte{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
MockLondonBlock = createNewBlock(&MockLondonHeader, MockLondonTransactions, MockLondonUncles, MockLondonReceipts, new(trie.Trie))
|
||||||
)
|
)
|
||||||
|
|
||||||
func createNewBlock(header *types.Header, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt, hasher types.TrieHasher) *types.Block {
|
func createNewBlock(header *types.Header, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt, hasher types.TrieHasher) *types.Block {
|
||||||
|
|||||||
+7
-8
@@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs"
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
||||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@@ -197,10 +196,10 @@ func (arg *CallArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (types.Mes
|
|||||||
type IPLDs struct {
|
type IPLDs struct {
|
||||||
BlockNumber *big.Int
|
BlockNumber *big.Int
|
||||||
TotalDifficulty *big.Int
|
TotalDifficulty *big.Int
|
||||||
Header ipfs.BlockModel
|
Header models.IPLDModel
|
||||||
Uncles []ipfs.BlockModel
|
Uncles []models.IPLDModel
|
||||||
Transactions []ipfs.BlockModel
|
Transactions []models.IPLDModel
|
||||||
Receipts []ipfs.BlockModel
|
Receipts []models.IPLDModel
|
||||||
StateNodes []StateNode
|
StateNodes []StateNode
|
||||||
StorageNodes []StorageNode
|
StorageNodes []StorageNode
|
||||||
}
|
}
|
||||||
@@ -209,7 +208,7 @@ type StateNode struct {
|
|||||||
Type sdtypes.NodeType
|
Type sdtypes.NodeType
|
||||||
StateLeafKey common.Hash
|
StateLeafKey common.Hash
|
||||||
Path []byte
|
Path []byte
|
||||||
IPLD ipfs.BlockModel
|
IPLD models.IPLDModel
|
||||||
}
|
}
|
||||||
|
|
||||||
type StorageNode struct {
|
type StorageNode struct {
|
||||||
@@ -217,7 +216,7 @@ type StorageNode struct {
|
|||||||
StateLeafKey common.Hash
|
StateLeafKey common.Hash
|
||||||
StorageLeafKey common.Hash
|
StorageLeafKey common.Hash
|
||||||
Path []byte
|
Path []byte
|
||||||
IPLD ipfs.BlockModel
|
IPLD models.IPLDModel
|
||||||
}
|
}
|
||||||
|
|
||||||
// CIDWrapper is used to direct fetching of IPLDs from IPFS
|
// CIDWrapper is used to direct fetching of IPLDs from IPFS
|
||||||
@@ -249,7 +248,7 @@ type ConvertedPayload struct {
|
|||||||
// LogResult represent a log.
|
// LogResult represent a log.
|
||||||
type LogResult struct {
|
type LogResult struct {
|
||||||
LeafCID string `db:"leaf_cid"`
|
LeafCID string `db:"leaf_cid"`
|
||||||
ReceiptID int64 `db:"receipt_id"`
|
ReceiptID string `db:"rct_id"`
|
||||||
Address string `db:"address"`
|
Address string `db:"address"`
|
||||||
Index int64 `db:"index"`
|
Index int64 `db:"index"`
|
||||||
Data []byte `db:"log_data"`
|
Data []byte `db:"log_data"`
|
||||||
|
|||||||
+151
-3
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type StorageResponse struct {
|
type StorageResponse struct {
|
||||||
Cid string `json:"cid"`
|
CID string `json:"cid"`
|
||||||
Value common.Hash `json:"value"`
|
Value common.Hash `json:"value"`
|
||||||
IpldBlock hexutil.Bytes `json:"ipldBlock"`
|
IpldBlock hexutil.Bytes `json:"ipldBlock"`
|
||||||
}
|
}
|
||||||
@@ -23,12 +23,12 @@ type GetStorageAt struct {
|
|||||||
type LogResponse struct {
|
type LogResponse struct {
|
||||||
Topics []common.Hash `json:"topics"`
|
Topics []common.Hash `json:"topics"`
|
||||||
Data hexutil.Bytes `json:"data"`
|
Data hexutil.Bytes `json:"data"`
|
||||||
Transaction TransactionResp `json:"transaction"`
|
Transaction TransactionResponse `json:"transaction"`
|
||||||
ReceiptCID string `json:"receiptCID"`
|
ReceiptCID string `json:"receiptCID"`
|
||||||
Status int32 `json:"status"`
|
Status int32 `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TransactionResp struct {
|
type TransactionResponse struct {
|
||||||
Hash common.Hash `json:"hash"`
|
Hash common.Hash `json:"hash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +36,52 @@ type GetLogs struct {
|
|||||||
Responses []LogResponse `json:"getLogs"`
|
Responses []LogResponse `json:"getLogs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IPFSBlockResponse struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthTransactionCIDResponse struct {
|
||||||
|
CID string `json:"cid"`
|
||||||
|
TxHash string `json:"txHash"`
|
||||||
|
Index int32 `json:"index"`
|
||||||
|
Src string `json:"src"`
|
||||||
|
Dst string `json:"dst"`
|
||||||
|
BlockByMhKey IPFSBlockResponse `json:"blockByMhKey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthTransactionCIDByTxHash struct {
|
||||||
|
Response EthTransactionCIDResponse `json:"ethTransactionCidByTxHash"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthTransactionCIDsByHeaderIdResponse struct {
|
||||||
|
Nodes []EthTransactionCIDResponse `json:"nodes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthHeaderCIDResponse struct {
|
||||||
|
CID string `json:"cid"`
|
||||||
|
BlockNumber BigInt `json:"blockNumber"`
|
||||||
|
BlockHash string `json:"blockHash"`
|
||||||
|
ParentHash string `json:"parentHash"`
|
||||||
|
Timestamp BigInt `json:"timestamp"`
|
||||||
|
StateRoot string `json:"stateRoot"`
|
||||||
|
Td BigInt `json:"td"`
|
||||||
|
TxRoot string `json:"txRoot"`
|
||||||
|
ReceiptRoot string `json:"receiptRoot"`
|
||||||
|
UncleRoot string `json:"uncleRoot"`
|
||||||
|
Bloom string `json:"bloom"`
|
||||||
|
EthTransactionCIDsByHeaderId EthTransactionCIDsByHeaderIdResponse `json:"ethTransactionCidsByHeaderId"`
|
||||||
|
BlockByMhKey IPFSBlockResponse `json:"blockByMhKey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AllEthHeaderCIDsResponse struct {
|
||||||
|
Nodes []EthHeaderCIDResponse `json:"nodes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AllEthHeaderCIDs struct {
|
||||||
|
Response AllEthHeaderCIDsResponse `json:"allEthHeaderCids"`
|
||||||
|
}
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
client *gqlclient.Client
|
client *gqlclient.Client
|
||||||
}
|
}
|
||||||
@@ -117,3 +163,105 @@ func (c *Client) GetStorageAt(ctx context.Context, hash common.Hash, address com
|
|||||||
}
|
}
|
||||||
return &storageAt.Response, nil
|
return &storageAt.Response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) AllEthHeaderCIDs(ctx context.Context, condition EthHeaderCIDCondition) (*AllEthHeaderCIDsResponse, error) {
|
||||||
|
var params string
|
||||||
|
if condition.BlockHash != nil {
|
||||||
|
params = fmt.Sprintf(`blockHash: "%s"`, *condition.BlockHash)
|
||||||
|
}
|
||||||
|
if condition.BlockNumber != nil {
|
||||||
|
params += fmt.Sprintf(`blockNumber: "%s"`, condition.BlockNumber.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
getHeadersQuery := fmt.Sprintf(`
|
||||||
|
query{
|
||||||
|
allEthHeaderCids(condition: { %s }) {
|
||||||
|
nodes {
|
||||||
|
cid
|
||||||
|
blockNumber
|
||||||
|
blockHash
|
||||||
|
parentHash
|
||||||
|
timestamp
|
||||||
|
stateRoot
|
||||||
|
td
|
||||||
|
txRoot
|
||||||
|
receiptRoot
|
||||||
|
uncleRoot
|
||||||
|
bloom
|
||||||
|
blockByMhKey {
|
||||||
|
key
|
||||||
|
data
|
||||||
|
}
|
||||||
|
ethTransactionCidsByHeaderId {
|
||||||
|
nodes {
|
||||||
|
cid
|
||||||
|
txHash
|
||||||
|
index
|
||||||
|
src
|
||||||
|
dst
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, params)
|
||||||
|
|
||||||
|
req := gqlclient.NewRequest(getHeadersQuery)
|
||||||
|
req.Header.Set("Cache-Control", "no-cache")
|
||||||
|
|
||||||
|
var respData map[string]interface{}
|
||||||
|
err := c.client.Run(ctx, req, &respData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonStr, err := json.Marshal(respData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var allEthHeaderCIDs AllEthHeaderCIDs
|
||||||
|
err = json.Unmarshal(jsonStr, &allEthHeaderCIDs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &allEthHeaderCIDs.Response, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) EthTransactionCIDByTxHash(ctx context.Context, txHash string) (*EthTransactionCIDResponse, error) {
|
||||||
|
getTxQuery := fmt.Sprintf(`
|
||||||
|
query{
|
||||||
|
ethTransactionCidByTxHash(txHash: "%s") {
|
||||||
|
cid
|
||||||
|
txHash
|
||||||
|
index
|
||||||
|
src
|
||||||
|
dst
|
||||||
|
blockByMhKey {
|
||||||
|
data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, txHash)
|
||||||
|
|
||||||
|
req := gqlclient.NewRequest(getTxQuery)
|
||||||
|
req.Header.Set("Cache-Control", "no-cache")
|
||||||
|
|
||||||
|
var respData map[string]interface{}
|
||||||
|
err := c.client.Run(ctx, req, &respData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonStr, err := json.Marshal(respData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var ethTxCID EthTransactionCIDByTxHash
|
||||||
|
err = json.Unmarshal(jsonStr, ðTxCID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ðTxCID.Response, nil
|
||||||
|
}
|
||||||
|
|||||||
+252
-5
@@ -22,6 +22,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
@@ -33,7 +35,8 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -774,8 +777,8 @@ func (b *Block) Logs(ctx context.Context, args struct{ Filter BlockFilterCriteri
|
|||||||
hash = header.Hash()
|
hash = header.Hash()
|
||||||
}
|
}
|
||||||
// Construct the range filter
|
// Construct the range filter
|
||||||
filter := filters.NewBlockFilter(b.backend, hash, addresses, topics)
|
filterSys := filters.NewFilterSystem(b.backend, filters.Config{})
|
||||||
|
filter := filterSys.NewBlockFilter(hash, addresses, topics)
|
||||||
// Run the filter and return all the logs
|
// Run the filter and return all the logs
|
||||||
return runFilter(ctx, b.backend, filter)
|
return runFilter(ctx, b.backend, filter)
|
||||||
}
|
}
|
||||||
@@ -977,7 +980,8 @@ func (r *Resolver) Logs(ctx context.Context, args struct{ Filter FilterCriteria
|
|||||||
topics = *args.Filter.Topics
|
topics = *args.Filter.Topics
|
||||||
}
|
}
|
||||||
// Construct the range filter
|
// Construct the range filter
|
||||||
filter := filters.NewRangeFilter(filters.Backend(r.backend), begin, end, addresses, topics)
|
filterSys := filters.NewFilterSystem(r.backend, filters.Config{})
|
||||||
|
filter := filterSys.NewRangeFilter(begin, end, addresses, topics)
|
||||||
return runFilter(ctx, r.backend, filter)
|
return runFilter(ctx, r.backend, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1017,7 +1021,7 @@ func (r *Resolver) GetStorageAt(ctx context.Context, args struct {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if bytes.Compare(rlpValue, eth.EmptyNodeValue) == 0 {
|
if bytes.Equal(rlpValue, eth.EmptyNodeValue) {
|
||||||
return &StorageResult{value: eth.EmptyNodeValue, cid: cid, ipldBlock: ipldBlock}, nil
|
return &StorageResult{value: eth.EmptyNodeValue, cid: cid, ipldBlock: ipldBlock}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1122,3 +1126,246 @@ func decomposeGQLLogs(logCIDs []eth.LogResult) []logsCID {
|
|||||||
|
|
||||||
return logs
|
return logs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EthTransactionCID struct {
|
||||||
|
cid string
|
||||||
|
txHash string
|
||||||
|
index int32
|
||||||
|
src string
|
||||||
|
dst string
|
||||||
|
ipfsBlock IPFSBlock
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t EthTransactionCID) Cid(ctx context.Context) string {
|
||||||
|
return t.cid
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t EthTransactionCID) TxHash(ctx context.Context) string {
|
||||||
|
return t.txHash
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t EthTransactionCID) Index(ctx context.Context) int32 {
|
||||||
|
return t.index
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t EthTransactionCID) Src(ctx context.Context) string {
|
||||||
|
return t.src
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t EthTransactionCID) Dst(ctx context.Context) string {
|
||||||
|
return t.dst
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t EthTransactionCID) BlockByMhKey(ctx context.Context) IPFSBlock {
|
||||||
|
return t.ipfsBlock
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthTransactionCIDsConnection struct {
|
||||||
|
nodes []*EthTransactionCID
|
||||||
|
}
|
||||||
|
|
||||||
|
func (transactionCIDResult EthTransactionCIDsConnection) Nodes(ctx context.Context) []*EthTransactionCID {
|
||||||
|
return transactionCIDResult.nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
type IPFSBlock struct {
|
||||||
|
key string
|
||||||
|
data string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b IPFSBlock) Key(ctx context.Context) string {
|
||||||
|
return b.key
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b IPFSBlock) Data(ctx context.Context) string {
|
||||||
|
return b.data
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthHeaderCID struct {
|
||||||
|
cid string
|
||||||
|
blockNumber BigInt
|
||||||
|
blockHash string
|
||||||
|
parentHash string
|
||||||
|
timestamp BigInt
|
||||||
|
stateRoot string
|
||||||
|
td BigInt
|
||||||
|
txRoot string
|
||||||
|
receiptRoot string
|
||||||
|
uncleRoot string
|
||||||
|
bloom string
|
||||||
|
transactions []*EthTransactionCID
|
||||||
|
ipfsBlock IPFSBlock
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) Cid(ctx context.Context) string {
|
||||||
|
return h.cid
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) BlockNumber(ctx context.Context) BigInt {
|
||||||
|
return h.blockNumber
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) BlockHash(ctx context.Context) string {
|
||||||
|
return h.blockHash
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) ParentHash(ctx context.Context) string {
|
||||||
|
return h.parentHash
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) Timestamp(ctx context.Context) BigInt {
|
||||||
|
return h.timestamp
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) StateRoot(ctx context.Context) string {
|
||||||
|
return h.stateRoot
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) Td(ctx context.Context) BigInt {
|
||||||
|
return h.td
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) TxRoot(ctx context.Context) string {
|
||||||
|
return h.txRoot
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) ReceiptRoot(ctx context.Context) string {
|
||||||
|
return h.receiptRoot
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) UncleRoot(ctx context.Context) string {
|
||||||
|
return h.uncleRoot
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) Bloom(ctx context.Context) string {
|
||||||
|
return h.bloom
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) EthTransactionCidsByHeaderId(ctx context.Context) EthTransactionCIDsConnection {
|
||||||
|
return EthTransactionCIDsConnection{nodes: h.transactions}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h EthHeaderCID) BlockByMhKey(ctx context.Context) IPFSBlock {
|
||||||
|
return h.ipfsBlock
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthHeaderCIDsConnection struct {
|
||||||
|
nodes []*EthHeaderCID
|
||||||
|
}
|
||||||
|
|
||||||
|
func (headerCIDResult EthHeaderCIDsConnection) Nodes(ctx context.Context) []*EthHeaderCID {
|
||||||
|
return headerCIDResult.nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthHeaderCIDCondition struct {
|
||||||
|
BlockNumber *BigInt
|
||||||
|
BlockHash *string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Resolver) AllEthHeaderCids(ctx context.Context, args struct {
|
||||||
|
Condition *EthHeaderCIDCondition
|
||||||
|
}) (*EthHeaderCIDsConnection, error) {
|
||||||
|
var headerCIDs []eth.HeaderCIDRecord
|
||||||
|
var err error
|
||||||
|
if args.Condition.BlockHash != nil {
|
||||||
|
headerCID, err := r.backend.Retriever.RetrieveHeaderAndTxCIDsByBlockHash(common.HexToHash(*args.Condition.BlockHash))
|
||||||
|
if err != nil {
|
||||||
|
if !strings.Contains(err.Error(), "not found") {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
headerCIDs = append(headerCIDs, headerCID)
|
||||||
|
}
|
||||||
|
} else if args.Condition.BlockNumber != nil {
|
||||||
|
headerCIDs, err = r.backend.Retriever.RetrieveHeaderAndTxCIDsByBlockNumber(args.Condition.BlockNumber.ToInt().Int64())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("provide block number or block hash")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Begin tx
|
||||||
|
tx, err := r.backend.DB.Beginx()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if p := recover(); p != nil {
|
||||||
|
shared.Rollback(tx)
|
||||||
|
panic(p)
|
||||||
|
} else if err != nil {
|
||||||
|
shared.Rollback(tx)
|
||||||
|
} else {
|
||||||
|
err = tx.Commit()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
var resultNodes []*EthHeaderCID
|
||||||
|
for _, headerCID := range headerCIDs {
|
||||||
|
var blockNumber BigInt
|
||||||
|
blockNumber.UnmarshalText([]byte(headerCID.BlockNumber))
|
||||||
|
|
||||||
|
var timestamp BigInt
|
||||||
|
timestamp.SetUint64(headerCID.Timestamp)
|
||||||
|
|
||||||
|
var td BigInt
|
||||||
|
td.UnmarshalText([]byte(headerCID.TotalDifficulty))
|
||||||
|
|
||||||
|
ethHeaderCIDNode := EthHeaderCID{
|
||||||
|
cid: headerCID.CID,
|
||||||
|
blockNumber: blockNumber,
|
||||||
|
blockHash: headerCID.BlockHash,
|
||||||
|
parentHash: headerCID.ParentHash,
|
||||||
|
timestamp: timestamp,
|
||||||
|
stateRoot: headerCID.StateRoot,
|
||||||
|
td: td,
|
||||||
|
txRoot: headerCID.TxRoot,
|
||||||
|
receiptRoot: headerCID.RctRoot,
|
||||||
|
uncleRoot: headerCID.UncleRoot,
|
||||||
|
bloom: Bytes(headerCID.Bloom).String(),
|
||||||
|
ipfsBlock: IPFSBlock{
|
||||||
|
key: headerCID.IPLD.Key,
|
||||||
|
data: Bytes(headerCID.IPLD.Data).String(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, txCID := range headerCID.TransactionCIDs {
|
||||||
|
ethHeaderCIDNode.transactions = append(ethHeaderCIDNode.transactions, &EthTransactionCID{
|
||||||
|
cid: txCID.CID,
|
||||||
|
txHash: txCID.TxHash,
|
||||||
|
index: int32(txCID.Index),
|
||||||
|
src: txCID.Src,
|
||||||
|
dst: txCID.Dst,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
resultNodes = append(resultNodes, ðHeaderCIDNode)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &EthHeaderCIDsConnection{
|
||||||
|
nodes: resultNodes,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Resolver) EthTransactionCidByTxHash(ctx context.Context, args struct {
|
||||||
|
TxHash string
|
||||||
|
}) (*EthTransactionCID, error) {
|
||||||
|
txCID, err := r.backend.Retriever.RetrieveTxCIDByHash(args.TxHash)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &EthTransactionCID{
|
||||||
|
cid: txCID.CID,
|
||||||
|
txHash: txCID.TxHash,
|
||||||
|
index: int32(txCID.Index),
|
||||||
|
src: txCID.Src,
|
||||||
|
dst: txCID.Dst,
|
||||||
|
ipfsBlock: IPFSBlock{
|
||||||
|
key: txCID.IPLD.Key,
|
||||||
|
data: Bytes(txCID.IPLD.Data).String(),
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|||||||
+98
-36
@@ -20,7 +20,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
@@ -32,32 +31,18 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/statediff"
|
"github.com/ethereum/go-ethereum/statediff"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer"
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/node"
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
|
||||||
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth/test_helpers"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth/test_helpers"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/graphql"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/graphql"
|
||||||
ethServerShared "github.com/vulcanize/ipld-eth-server/pkg/shared"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
|
ethServerShared "github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetupDB is use to setup a db for watcher tests
|
|
||||||
func SetupDB() (*postgres.DB, error) {
|
|
||||||
port, _ := strconv.Atoi(os.Getenv("DATABASE_PORT"))
|
|
||||||
uri := postgres.DbConnectionString(postgres.ConnectionParams{
|
|
||||||
User: os.Getenv("DATABASE_USER"),
|
|
||||||
Password: os.Getenv("DATABASE_PASSWORD"),
|
|
||||||
Hostname: os.Getenv("DATABASE_HOSTNAME"),
|
|
||||||
Name: os.Getenv("DATABASE_NAME"),
|
|
||||||
Port: port,
|
|
||||||
})
|
|
||||||
return postgres.NewDB(uri, postgres.ConnectionConfig{}, node.Info{})
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ = Describe("GraphQL", func() {
|
var _ = Describe("GraphQL", func() {
|
||||||
const (
|
const (
|
||||||
gqlEndPoint = "127.0.0.1:8083"
|
gqlEndPoint = "127.0.0.1:8083"
|
||||||
@@ -68,7 +53,7 @@ var _ = Describe("GraphQL", func() {
|
|||||||
blocks []*types.Block
|
blocks []*types.Block
|
||||||
receipts []types.Receipts
|
receipts []types.Receipts
|
||||||
chain *core.BlockChain
|
chain *core.BlockChain
|
||||||
db *postgres.DB
|
db *sqlx.DB
|
||||||
blockHashes []common.Hash
|
blockHashes []common.Hash
|
||||||
backend *eth.Backend
|
backend *eth.Backend
|
||||||
graphQLServer *graphql.Service
|
graphQLServer *graphql.Service
|
||||||
@@ -82,11 +67,9 @@ var _ = Describe("GraphQL", func() {
|
|||||||
|
|
||||||
It("test init", func() {
|
It("test init", func() {
|
||||||
var err error
|
var err error
|
||||||
db, err = SetupDB()
|
db = shared.SetupDB()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
transformer := shared.SetupTestStateDiffIndexer(ctx, chainConfig, test_helpers.Genesis.Hash())
|
||||||
|
|
||||||
transformer, err := indexer.NewStateDiffIndexer(chainConfig, db)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
backend, err = eth.NewEthBackend(db, ð.Config{
|
backend, err = eth.NewEthBackend(db, ð.Config{
|
||||||
ChainConfig: chainConfig,
|
ChainConfig: chainConfig,
|
||||||
VMConfig: vm.Config{},
|
VMConfig: vm.Config{},
|
||||||
@@ -132,7 +115,7 @@ var _ = Describe("GraphQL", func() {
|
|||||||
rcts = receipts[i-1]
|
rcts = receipts[i-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
var diff statediff.StateObject
|
var diff sdtypes.StateObject
|
||||||
diff, err = builder.BuildStateDiffObject(args, params)
|
diff, err = builder.BuildStateDiffObject(args, params)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
@@ -140,17 +123,16 @@ var _ = Describe("GraphQL", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
for _, node := range diff.Nodes {
|
for _, node := range diff.Nodes {
|
||||||
err = transformer.PushStateNode(tx, node)
|
err = transformer.PushStateNode(tx, node, block.Hash().String())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert some non-canonical data into the database so that we test our ability to discern canonicity
|
// Insert some non-canonical data into the database so that we test our ability to discern canonicity
|
||||||
indexAndPublisher, err := indexer.NewStateDiffIndexer(chainConfig, db)
|
indexAndPublisher := shared.SetupTestStateDiffIndexer(ctx, chainConfig, test_helpers.Genesis.Hash())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
blockHash = test_helpers.MockBlock.Hash()
|
blockHash = test_helpers.MockBlock.Hash()
|
||||||
contractAddress = test_helpers.ContractAddr
|
contractAddress = test_helpers.ContractAddr
|
||||||
@@ -158,7 +140,7 @@ var _ = Describe("GraphQL", func() {
|
|||||||
tx, err := indexAndPublisher.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
tx, err := indexAndPublisher.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
// The non-canonical header has a child
|
// The non-canonical header has a child
|
||||||
@@ -173,7 +155,7 @@ var _ = Describe("GraphQL", func() {
|
|||||||
err = indexAndPublisher.PushCodeAndCodeHash(tx, ccHash)
|
err = indexAndPublisher.PushCodeAndCodeHash(tx, ccHash)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = tx.Close(err)
|
err = tx.Submit(err)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
graphQLServer, err = graphql.New(backend, gqlEndPoint, nil, []string{"*"}, rpc.HTTPTimeouts{})
|
graphQLServer, err = graphql.New(backend, gqlEndPoint, nil, []string{"*"}, rpc.HTTPTimeouts{})
|
||||||
@@ -186,7 +168,7 @@ var _ = Describe("GraphQL", func() {
|
|||||||
defer It("test teardown", func() {
|
defer It("test teardown", func() {
|
||||||
err := graphQLServer.Stop()
|
err := graphQLServer.Stop()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
eth.TearDownDB(db)
|
shared.TearDownDB(db)
|
||||||
chain.Stop()
|
chain.Stop()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -199,7 +181,7 @@ var _ = Describe("GraphQL", func() {
|
|||||||
{
|
{
|
||||||
Topics: test_helpers.MockLog1.Topics,
|
Topics: test_helpers.MockLog1.Topics,
|
||||||
Data: hexutil.Bytes(test_helpers.MockLog1.Data),
|
Data: hexutil.Bytes(test_helpers.MockLog1.Data),
|
||||||
Transaction: graphql.TransactionResp{Hash: test_helpers.MockTransactions[0].Hash()},
|
Transaction: graphql.TransactionResponse{Hash: test_helpers.MockTransactions[0].Hash()},
|
||||||
ReceiptCID: test_helpers.Rct1CID.String(),
|
ReceiptCID: test_helpers.Rct1CID.String(),
|
||||||
Status: int32(test_helpers.MockReceipts[0].Status),
|
Status: int32(test_helpers.MockReceipts[0].Status),
|
||||||
},
|
},
|
||||||
@@ -216,7 +198,7 @@ var _ = Describe("GraphQL", func() {
|
|||||||
{
|
{
|
||||||
Topics: test_helpers.MockLog6.Topics,
|
Topics: test_helpers.MockLog6.Topics,
|
||||||
Data: hexutil.Bytes(test_helpers.MockLog6.Data),
|
Data: hexutil.Bytes(test_helpers.MockLog6.Data),
|
||||||
Transaction: graphql.TransactionResp{Hash: test_helpers.MockTransactions[3].Hash()},
|
Transaction: graphql.TransactionResponse{Hash: test_helpers.MockTransactions[3].Hash()},
|
||||||
ReceiptCID: test_helpers.Rct4CID.String(),
|
ReceiptCID: test_helpers.Rct4CID.String(),
|
||||||
Status: int32(test_helpers.MockReceipts[3].Status),
|
Status: int32(test_helpers.MockReceipts[3].Status),
|
||||||
},
|
},
|
||||||
@@ -269,4 +251,84 @@ var _ = Describe("GraphQL", func() {
|
|||||||
Expect(storageRes.Value).To(Equal(common.Hash{}))
|
Expect(storageRes.Value).To(Equal(common.Hash{}))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Describe("allEthHeaderCids", func() {
|
||||||
|
It("Retrieves header_cids that matches the provided blockNumber", func() {
|
||||||
|
allEthHeaderCIDsResp, err := client.AllEthHeaderCIDs(ctx, graphql.EthHeaderCIDCondition{BlockNumber: new(graphql.BigInt).SetUint64(2)})
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
headerCIDs, err := backend.Retriever.RetrieveHeaderAndTxCIDsByBlockNumber(2)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
for idx, headerCID := range headerCIDs {
|
||||||
|
ethHeaderCID := allEthHeaderCIDsResp.Nodes[idx]
|
||||||
|
|
||||||
|
compareEthHeaderCID(ethHeaderCID, headerCID)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("Retrieves header_cids that matches the provided blockHash", func() {
|
||||||
|
blockHash := blocks[1].Hash().String()
|
||||||
|
allEthHeaderCIDsResp, err := client.AllEthHeaderCIDs(ctx, graphql.EthHeaderCIDCondition{BlockHash: &blockHash})
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
headerCID, err := backend.Retriever.RetrieveHeaderAndTxCIDsByBlockHash(blocks[1].Hash())
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
Expect(len(allEthHeaderCIDsResp.Nodes)).To(Equal(1))
|
||||||
|
ethHeaderCID := allEthHeaderCIDsResp.Nodes[0]
|
||||||
|
compareEthHeaderCID(ethHeaderCID, headerCID)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Describe("ethTransactionCidByTxHash", func() {
|
||||||
|
It("Retrieves tx_cid that matches the provided txHash", func() {
|
||||||
|
txHash := blocks[2].Transactions()[0].Hash().String()
|
||||||
|
ethTransactionCIDResp, err := client.EthTransactionCIDByTxHash(ctx, txHash)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
txCID, err := backend.Retriever.RetrieveTxCIDByHash(txHash)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
compareEthTxCID(*ethTransactionCIDResp, txCID)
|
||||||
|
|
||||||
|
Expect(ethTransactionCIDResp.BlockByMhKey.Data).To(Equal(graphql.Bytes(txCID.IPLD.Data).String()))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
func compareEthHeaderCID(ethHeaderCID graphql.EthHeaderCIDResponse, headerCID eth.HeaderCIDRecord) {
|
||||||
|
blockNumber, err := strconv.ParseInt(headerCID.BlockNumber, 10, 64)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
td, err := strconv.ParseInt(headerCID.TotalDifficulty, 10, 64)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
Expect(ethHeaderCID.CID).To(Equal(headerCID.CID))
|
||||||
|
Expect(ethHeaderCID.BlockNumber).To(Equal(*new(graphql.BigInt).SetUint64(uint64(blockNumber))))
|
||||||
|
Expect(ethHeaderCID.BlockHash).To(Equal(headerCID.BlockHash))
|
||||||
|
Expect(ethHeaderCID.ParentHash).To(Equal(headerCID.ParentHash))
|
||||||
|
Expect(ethHeaderCID.Timestamp).To(Equal(*new(graphql.BigInt).SetUint64(headerCID.Timestamp)))
|
||||||
|
Expect(ethHeaderCID.StateRoot).To(Equal(headerCID.StateRoot))
|
||||||
|
Expect(ethHeaderCID.Td).To(Equal(*new(graphql.BigInt).SetUint64(uint64(td))))
|
||||||
|
Expect(ethHeaderCID.TxRoot).To(Equal(headerCID.TxRoot))
|
||||||
|
Expect(ethHeaderCID.ReceiptRoot).To(Equal(headerCID.RctRoot))
|
||||||
|
Expect(ethHeaderCID.UncleRoot).To(Equal(headerCID.UncleRoot))
|
||||||
|
Expect(ethHeaderCID.Bloom).To(Equal(graphql.Bytes(headerCID.Bloom).String()))
|
||||||
|
|
||||||
|
for tIdx, txCID := range headerCID.TransactionCIDs {
|
||||||
|
ethTxCID := ethHeaderCID.EthTransactionCIDsByHeaderId.Nodes[tIdx]
|
||||||
|
compareEthTxCID(ethTxCID, txCID)
|
||||||
|
}
|
||||||
|
|
||||||
|
Expect(ethHeaderCID.BlockByMhKey.Data).To(Equal(graphql.Bytes(headerCID.IPLD.Data).String()))
|
||||||
|
Expect(ethHeaderCID.BlockByMhKey.Key).To(Equal(headerCID.IPLD.Key))
|
||||||
|
}
|
||||||
|
|
||||||
|
func compareEthTxCID(ethTxCID graphql.EthTransactionCIDResponse, txCID eth.TransactionCIDRecord) {
|
||||||
|
Expect(ethTxCID.CID).To(Equal(txCID.CID))
|
||||||
|
Expect(ethTxCID.TxHash).To(Equal(txCID.TxHash))
|
||||||
|
Expect(ethTxCID.Index).To(Equal(int32(txCID.Index)))
|
||||||
|
Expect(ethTxCID.Src).To(Equal(txCID.Src))
|
||||||
|
Expect(ethTxCID.Dst).To(Equal(txCID.Dst))
|
||||||
|
}
|
||||||
|
|||||||
+50
-2
@@ -25,8 +25,7 @@ const schema string = `
|
|||||||
# An empty byte string is represented as '0x'. Byte strings must have an even number of hexadecimal nybbles.
|
# An empty byte string is represented as '0x'. Byte strings must have an even number of hexadecimal nybbles.
|
||||||
scalar Bytes
|
scalar Bytes
|
||||||
# BigInt is a large integer. Input is accepted as either a JSON number or as a string.
|
# BigInt is a large integer. Input is accepted as either a JSON number or as a string.
|
||||||
# Strings may be either decimal or 0x-prefixed hexadecimal. Output values are all
|
# Input and output strings may be either decimal or 0x-prefixed hexadecimal depending upon the resolver implementation.
|
||||||
# 0x-prefixed hexadecimal.
|
|
||||||
scalar BigInt
|
scalar BigInt
|
||||||
# Long is a 64 bit unsigned integer.
|
# Long is a 64 bit unsigned integer.
|
||||||
scalar Long
|
scalar Long
|
||||||
@@ -282,6 +281,49 @@ const schema string = `
|
|||||||
ipldBlock: Bytes!
|
ipldBlock: Bytes!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input EthHeaderCidCondition {
|
||||||
|
blockNumber: BigInt
|
||||||
|
blockHash: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthTransactionCid {
|
||||||
|
cid: String!
|
||||||
|
txHash: String!
|
||||||
|
index: Int!
|
||||||
|
src: String!
|
||||||
|
dst: String!
|
||||||
|
blockByMhKey: IPFSBlock!
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthTransactionCidsConnection {
|
||||||
|
nodes: [EthTransactionCid]!
|
||||||
|
}
|
||||||
|
|
||||||
|
type IPFSBlock {
|
||||||
|
key: String!
|
||||||
|
data: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthHeaderCid {
|
||||||
|
cid: String!
|
||||||
|
blockNumber: BigInt!
|
||||||
|
blockHash: String!
|
||||||
|
parentHash: String!
|
||||||
|
timestamp: BigInt!
|
||||||
|
stateRoot: String!
|
||||||
|
td: BigInt!
|
||||||
|
txRoot: String!
|
||||||
|
receiptRoot: String!
|
||||||
|
uncleRoot: String!
|
||||||
|
bloom: String!
|
||||||
|
ethTransactionCidsByHeaderId: EthTransactionCidsConnection!
|
||||||
|
blockByMhKey: IPFSBlock!
|
||||||
|
}
|
||||||
|
|
||||||
|
type EthHeaderCidsConnection {
|
||||||
|
nodes: [EthHeaderCid]!
|
||||||
|
}
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
# Block fetches an Ethereum block by number or by hash. If neither is
|
# Block fetches an Ethereum block by number or by hash. If neither is
|
||||||
# supplied, the most recent known block is returned.
|
# supplied, the most recent known block is returned.
|
||||||
@@ -302,5 +344,11 @@ const schema string = `
|
|||||||
|
|
||||||
# Get contract logs by block hash and contract address.
|
# Get contract logs by block hash and contract address.
|
||||||
getLogs(blockHash: Bytes32!, contract: Address): [Log!]
|
getLogs(blockHash: Bytes32!, contract: Address): [Log!]
|
||||||
|
|
||||||
|
# PostGraphile alternative to get headers with transactions using block number or block hash.
|
||||||
|
allEthHeaderCids(condition: EthHeaderCidCondition): EthHeaderCidsConnection
|
||||||
|
|
||||||
|
# PostGraphile alternative to get transactions using transaction hash.
|
||||||
|
ethTransactionCidByTxHash(txHash: String!): EthTransactionCid
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import (
|
|||||||
"github.com/graph-gophers/graphql-go/relay"
|
"github.com/graph-gophers/graphql-go/relay"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Service encapsulates a GraphQL service.
|
// Service encapsulates a GraphQL service.
|
||||||
@@ -69,7 +69,7 @@ func (s *Service) Start(server *p2p.Server) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
handler := node.NewHTTPHandlerStack(s.handler, s.cors, s.vhosts)
|
handler := node.NewHTTPHandlerStack(s.handler, s.cors, s.vhosts, nil)
|
||||||
|
|
||||||
// start http server
|
// start http server
|
||||||
_, addr, err := node.StartHTTPEndpoint(s.endpoint, rpc.DefaultHTTPTimeouts, handler)
|
_, addr, err := node.StartHTTPEndpoint(s.endpoint, rpc.DefaultHTTPTimeouts, handler)
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
// VulcanizeDB
|
||||||
|
// Copyright © 2022 Vulcanize
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package graphql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Bytes marshals as a JSON string with \x prefix.
|
||||||
|
// The empty slice marshals as "\x".
|
||||||
|
type Bytes []byte
|
||||||
|
|
||||||
|
// MarshalText implements encoding.TextMarshaler
|
||||||
|
func (b Bytes) MarshalText() ([]byte, error) {
|
||||||
|
result := make([]byte, len(b)*2+2)
|
||||||
|
copy(result, `\x`)
|
||||||
|
hex.Encode(result[2:], b)
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns the hex encoding of b.
|
||||||
|
func (b Bytes) String() string {
|
||||||
|
return b.encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode encodes b as a hex string with "\x" prefix.
|
||||||
|
// This is to make the output to be the same as given by postgraphile.
|
||||||
|
// graphql-go prepends another "\" to the output resulting in prefix "\\x".
|
||||||
|
func (b Bytes) encode() string {
|
||||||
|
result := make([]byte, len(b)*2+2)
|
||||||
|
copy(result, `\x`)
|
||||||
|
hex.Encode(result[2:], b)
|
||||||
|
return string(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
type BigInt big.Int
|
||||||
|
|
||||||
|
// ToInt converts b to a big.Int.
|
||||||
|
func (b *BigInt) ToInt() *big.Int {
|
||||||
|
return (*big.Int)(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns value of b as a decimal string.
|
||||||
|
func (b *BigInt) String() string {
|
||||||
|
return b.ToInt().String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUint64 sets b to x and returns x.
|
||||||
|
func (b *BigInt) SetUint64(x uint64) *BigInt {
|
||||||
|
var val big.Int
|
||||||
|
val.SetUint64(x)
|
||||||
|
*b = (BigInt)(val)
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalText implements encoding.TextMarshaler
|
||||||
|
func (b BigInt) MarshalText() ([]byte, error) {
|
||||||
|
return []byte(b.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalText implements encoding.TextUnmarshaler
|
||||||
|
func (b *BigInt) UnmarshalText(input []byte) error {
|
||||||
|
raw, err := checkNumberText(input)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(raw) > 64 {
|
||||||
|
return hexutil.ErrBig256Range
|
||||||
|
}
|
||||||
|
|
||||||
|
var val big.Int
|
||||||
|
val.SetString(string(input[:]), 10)
|
||||||
|
*b = (BigInt)(val)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImplementsGraphQLType returns true if BigInt implements the provided GraphQL type.
|
||||||
|
func (b BigInt) ImplementsGraphQLType(name string) bool { return name == "BigInt" }
|
||||||
|
|
||||||
|
// UnmarshalGraphQL unmarshals the provided GraphQL query data.
|
||||||
|
func (b *BigInt) UnmarshalGraphQL(input interface{}) error {
|
||||||
|
var err error
|
||||||
|
switch input := input.(type) {
|
||||||
|
case string:
|
||||||
|
return b.UnmarshalText([]byte(input))
|
||||||
|
case int32:
|
||||||
|
var num big.Int
|
||||||
|
num.SetInt64(int64(input))
|
||||||
|
*b = BigInt(num)
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("unexpected type %T for BigInt", input)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkNumberText(input []byte) (raw []byte, err error) {
|
||||||
|
if len(input) == 0 {
|
||||||
|
return nil, nil // empty strings are allowed
|
||||||
|
}
|
||||||
|
if len(input) > 1 && input[0] == '0' {
|
||||||
|
return nil, hexutil.ErrLeadingZero
|
||||||
|
}
|
||||||
|
return input, nil
|
||||||
|
}
|
||||||
+1
-1
@@ -20,7 +20,7 @@ import (
|
|||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/net"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("API", func() {
|
var _ = Describe("API", func() {
|
||||||
|
|||||||
+2
-2
@@ -29,11 +29,11 @@ import (
|
|||||||
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) (*rpc.Server, error) {
|
||||||
|
|
||||||
srv := rpc.NewServer()
|
srv := rpc.NewServer()
|
||||||
err := node.RegisterApis(apis, modules, srv, false)
|
err := node.RegisterApis(apis, modules, srv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Could not register HTTP API: %w", err)
|
utils.Fatalf("Could not register HTTP API: %w", err)
|
||||||
}
|
}
|
||||||
handler := node.NewHTTPHandlerStack(srv, cors, vhosts)
|
handler := node.NewHTTPHandlerStack(srv, cors, vhosts, nil)
|
||||||
|
|
||||||
// start http server
|
// start http server
|
||||||
_, addr, err := node.StartHTTPEndpoint(endpoint, rpc.DefaultHTTPTimeouts, handler)
|
_, addr, err := node.StartHTTPEndpoint(endpoint, rpc.DefaultHTTPTimeouts, handler)
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/p2p/netutil"
|
"github.com/ethereum/go-ethereum/p2p/netutil"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/prom"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/prom"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
+3
-3
@@ -24,11 +24,11 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/prom"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/prom"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StartWSEndpoint starts a websocket endpoint.
|
// StartWSEndpoint starts a websocket endpoint.
|
||||||
func StartWSEndpoint(endpoint string, apis []rpc.API, modules []string, wsOrigins []string, exposeAll bool) (net.Listener, *rpc.Server, error) {
|
func StartWSEndpoint(endpoint string, apis []rpc.API, modules []string, wsOrigins []string) (net.Listener, *rpc.Server, error) {
|
||||||
// All APIs registered, start the HTTP listener
|
// All APIs registered, start the HTTP listener
|
||||||
var (
|
var (
|
||||||
listener net.Listener
|
listener net.Listener
|
||||||
@@ -37,7 +37,7 @@ func StartWSEndpoint(endpoint string, apis []rpc.API, modules []string, wsOrigin
|
|||||||
|
|
||||||
// Register all the APIs exposed by the services
|
// Register all the APIs exposed by the services
|
||||||
handler := rpc.NewServer()
|
handler := rpc.NewServer()
|
||||||
err = node.RegisterApis(apis, modules, handler, exposeAll)
|
err = node.RegisterApis(apis, modules, handler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Could not register WS API: %w", err)
|
utils.Fatalf("Could not register WS API: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-6
@@ -20,10 +20,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/shared"
|
"github.com/ethereum/go-ethereum/statediff/types"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
)
|
)
|
||||||
|
|
||||||
// APIName is the namespace used for the state diffing service API
|
// APIName is the namespace used for the state diffing service API
|
||||||
@@ -35,12 +35,14 @@ const APIVersion = "0.0.1"
|
|||||||
// PublicServerAPI is the public api for the watcher
|
// PublicServerAPI is the public api for the watcher
|
||||||
type PublicServerAPI struct {
|
type PublicServerAPI struct {
|
||||||
w Server
|
w Server
|
||||||
|
rpc *rpc.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPublicServerAPI creates a new PublicServerAPI with the provided underlying Server process
|
// NewPublicServerAPI creates a new PublicServerAPI with the provided underlying Server process
|
||||||
func NewPublicServerAPI(w Server) *PublicServerAPI {
|
func NewPublicServerAPI(w Server, client *rpc.Client) *PublicServerAPI {
|
||||||
return &PublicServerAPI{
|
return &PublicServerAPI{
|
||||||
w: w,
|
w: w,
|
||||||
|
rpc: client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +85,12 @@ func (api *PublicServerAPI) Stream(ctx context.Context, params eth.SubscriptionS
|
|||||||
return rpcSub, nil
|
return rpcSub, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chain returns the chain type that this watcher instance supports
|
// WatchAddress makes a geth WatchAddress API call with the given operation and args
|
||||||
func (api *PublicServerAPI) Chain() shared.ChainType {
|
func (api *PublicServerAPI) WatchAddress(operation types.OperationType, args []types.WatchAddressArg) error {
|
||||||
return shared.Ethereum
|
err := api.rpc.Call(nil, "statediff_watchAddress", operation, args)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-21
@@ -22,16 +22,18 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
"github.com/ethereum/go-ethereum/statediff"
|
||||||
|
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/prom"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/prom"
|
ethServerShared "github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
||||||
ethServerShared "github.com/vulcanize/ipld-eth-server/pkg/shared"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Env variables
|
// Env variables
|
||||||
@@ -57,9 +59,8 @@ const (
|
|||||||
|
|
||||||
// Config struct
|
// Config struct
|
||||||
type Config struct {
|
type Config struct {
|
||||||
DB *postgres.DB
|
DB *sqlx.DB
|
||||||
DBConfig postgres.ConnectionConfig
|
DBConfig postgres.Config
|
||||||
DBParams postgres.ConnectionParams
|
|
||||||
|
|
||||||
WSEnabled bool
|
WSEnabled bool
|
||||||
WSEndpoint string
|
WSEndpoint string
|
||||||
@@ -87,6 +88,7 @@ type Config struct {
|
|||||||
SupportStateDiff bool
|
SupportStateDiff bool
|
||||||
ForwardEthCalls bool
|
ForwardEthCalls bool
|
||||||
ProxyOnError bool
|
ProxyOnError bool
|
||||||
|
NodeNetworkID string
|
||||||
|
|
||||||
// Cache configuration.
|
// Cache configuration.
|
||||||
GroupCache *ethServerShared.GroupCacheConfig
|
GroupCache *ethServerShared.GroupCacheConfig
|
||||||
@@ -112,6 +114,7 @@ func NewConfig() (*Config, error) {
|
|||||||
ethHTTP := viper.GetString("ethereum.httpPath")
|
ethHTTP := viper.GetString("ethereum.httpPath")
|
||||||
ethHTTPEndpoint := fmt.Sprintf("http://%s", ethHTTP)
|
ethHTTPEndpoint := fmt.Sprintf("http://%s", ethHTTP)
|
||||||
nodeInfo, cli, err := getEthNodeAndClient(ethHTTPEndpoint)
|
nodeInfo, cli, err := getEthNodeAndClient(ethHTTPEndpoint)
|
||||||
|
c.NodeNetworkID = nodeInfo.NetworkID
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -198,12 +201,12 @@ func NewConfig() (*Config, error) {
|
|||||||
c.IpldGraphqlEnabled = ipldGraphqlEnabled
|
c.IpldGraphqlEnabled = ipldGraphqlEnabled
|
||||||
|
|
||||||
overrideDBConnConfig(&c.DBConfig)
|
overrideDBConnConfig(&c.DBConfig)
|
||||||
serveDB, err := postgres.NewDB(postgres.DbConnectionString(c.DBParams), c.DBConfig, nodeInfo)
|
serveDB, err := ethServerShared.NewDB(c.DBConfig.DbConnectionString(), c.DBConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
prom.RegisterDBCollector(c.DBParams.Name, serveDB.DB)
|
prom.RegisterDBCollector(c.DBConfig.DatabaseName, serveDB)
|
||||||
c.DB = serveDB
|
c.DB = serveDB
|
||||||
|
|
||||||
defaultSenderStr := viper.GetString("ethereum.defaultSender")
|
defaultSenderStr := viper.GetString("ethereum.defaultSender")
|
||||||
@@ -219,9 +222,9 @@ func NewConfig() (*Config, error) {
|
|||||||
}
|
}
|
||||||
chainConfigPath := viper.GetString("ethereum.chainConfig")
|
chainConfigPath := viper.GetString("ethereum.chainConfig")
|
||||||
if chainConfigPath != "" {
|
if chainConfigPath != "" {
|
||||||
c.ChainConfig, err = eth.LoadConfig(chainConfigPath)
|
c.ChainConfig, err = statediff.LoadConfig(chainConfigPath)
|
||||||
} else {
|
} else {
|
||||||
c.ChainConfig, err = eth.ChainConfig(nodeInfo.ChainID)
|
c.ChainConfig, err = statediff.ChainConfig(nodeInfo.ChainID)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.loadGroupCacheConfig()
|
c.loadGroupCacheConfig()
|
||||||
@@ -231,13 +234,13 @@ func NewConfig() (*Config, error) {
|
|||||||
return c, err
|
return c, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func overrideDBConnConfig(con *postgres.ConnectionConfig) {
|
func overrideDBConnConfig(con *postgres.Config) {
|
||||||
viper.BindEnv("database.server.maxIdle", SERVER_MAX_IDLE_CONNECTIONS)
|
viper.BindEnv("database.server.maxIdle", SERVER_MAX_IDLE_CONNECTIONS)
|
||||||
viper.BindEnv("database.server.maxOpen", SERVER_MAX_OPEN_CONNECTIONS)
|
viper.BindEnv("database.server.maxOpen", SERVER_MAX_OPEN_CONNECTIONS)
|
||||||
viper.BindEnv("database.server.maxLifetime", SERVER_MAX_CONN_LIFETIME)
|
viper.BindEnv("database.server.maxLifetime", SERVER_MAX_CONN_LIFETIME)
|
||||||
con.MaxIdle = viper.GetInt("database.server.maxIdle")
|
con.MaxIdle = viper.GetInt("database.server.maxIdle")
|
||||||
con.MaxOpen = viper.GetInt("database.server.maxOpen")
|
con.MaxConns = viper.GetInt("database.server.maxOpen")
|
||||||
con.MaxLifetime = viper.GetInt("database.server.maxLifetime")
|
con.MaxConnLifetime = time.Duration(viper.GetInt("database.server.maxLifetime"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) dbInit() {
|
func (c *Config) dbInit() {
|
||||||
@@ -250,14 +253,14 @@ func (c *Config) dbInit() {
|
|||||||
viper.BindEnv("database.maxOpen", DATABASE_MAX_OPEN_CONNECTIONS)
|
viper.BindEnv("database.maxOpen", DATABASE_MAX_OPEN_CONNECTIONS)
|
||||||
viper.BindEnv("database.maxLifetime", DATABASE_MAX_CONN_LIFETIME)
|
viper.BindEnv("database.maxLifetime", DATABASE_MAX_CONN_LIFETIME)
|
||||||
|
|
||||||
c.DBParams.Name = viper.GetString("database.name")
|
c.DBConfig.DatabaseName = viper.GetString("database.name")
|
||||||
c.DBParams.Hostname = viper.GetString("database.hostname")
|
c.DBConfig.Hostname = viper.GetString("database.hostname")
|
||||||
c.DBParams.Port = viper.GetInt("database.port")
|
c.DBConfig.Port = viper.GetInt("database.port")
|
||||||
c.DBParams.User = viper.GetString("database.user")
|
c.DBConfig.Username = viper.GetString("database.user")
|
||||||
c.DBParams.Password = viper.GetString("database.password")
|
c.DBConfig.Password = viper.GetString("database.password")
|
||||||
c.DBConfig.MaxIdle = viper.GetInt("database.maxIdle")
|
c.DBConfig.MaxIdle = viper.GetInt("database.maxIdle")
|
||||||
c.DBConfig.MaxOpen = viper.GetInt("database.maxOpen")
|
c.DBConfig.MaxConns = viper.GetInt("database.maxOpen")
|
||||||
c.DBConfig.MaxLifetime = viper.GetInt("database.maxLifetime")
|
c.DBConfig.MaxConnLifetime = time.Duration(viper.GetInt("database.maxLifetime"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) loadGroupCacheConfig() {
|
func (c *Config) loadGroupCacheConfig() {
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
"github.com/jmoiron/sqlx"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/net"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -74,7 +74,7 @@ type Service struct {
|
|||||||
// A mapping of subscription params hash to the corresponding subscription params
|
// A mapping of subscription params hash to the corresponding subscription params
|
||||||
SubscriptionTypes map[common.Hash]eth.SubscriptionSettings
|
SubscriptionTypes map[common.Hash]eth.SubscriptionSettings
|
||||||
// Underlying db
|
// Underlying db
|
||||||
db *postgres.DB
|
db *sqlx.DB
|
||||||
// wg for syncing serve processes
|
// wg for syncing serve processes
|
||||||
serveWg *sync.WaitGroup
|
serveWg *sync.WaitGroup
|
||||||
// rpc client for forwarding cache misses
|
// rpc client for forwarding cache misses
|
||||||
@@ -87,6 +87,8 @@ type Service struct {
|
|||||||
forwardEthCalls bool
|
forwardEthCalls bool
|
||||||
// whether to forward all calls to proxy node if they throw an error locally
|
// whether to forward all calls to proxy node if they throw an error locally
|
||||||
proxyOnError bool
|
proxyOnError bool
|
||||||
|
// eth node network id
|
||||||
|
nodeNetworkId string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer creates a new Server using an underlying Service struct
|
// NewServer creates a new Server using an underlying Service struct
|
||||||
@@ -103,6 +105,7 @@ func NewServer(settings *Config) (Server, error) {
|
|||||||
sap.supportsStateDiffing = settings.SupportStateDiff
|
sap.supportsStateDiffing = settings.SupportStateDiff
|
||||||
sap.forwardEthCalls = settings.ForwardEthCalls
|
sap.forwardEthCalls = settings.ForwardEthCalls
|
||||||
sap.proxyOnError = settings.ProxyOnError
|
sap.proxyOnError = settings.ProxyOnError
|
||||||
|
sap.nodeNetworkId = settings.NodeNetworkID
|
||||||
var err error
|
var err error
|
||||||
sap.backend, err = eth.NewEthBackend(sap.db, ð.Config{
|
sap.backend, err = eth.NewEthBackend(sap.db, ð.Config{
|
||||||
ChainConfig: settings.ChainConfig,
|
ChainConfig: settings.ChainConfig,
|
||||||
@@ -121,12 +124,12 @@ func (sap *Service) Protocols() []p2p.Protocol {
|
|||||||
|
|
||||||
// APIs returns the RPC descriptors the watcher service offers
|
// APIs returns the RPC descriptors the watcher service offers
|
||||||
func (sap *Service) APIs() []rpc.API {
|
func (sap *Service) APIs() []rpc.API {
|
||||||
networkID, _ := strconv.ParseUint(sap.db.Node.NetworkID, 10, 64)
|
networkID, _ := strconv.ParseUint(sap.nodeNetworkId, 10, 64)
|
||||||
apis := []rpc.API{
|
apis := []rpc.API{
|
||||||
{
|
{
|
||||||
Namespace: APIName,
|
Namespace: APIName,
|
||||||
Version: APIVersion,
|
Version: APIVersion,
|
||||||
Service: NewPublicServerAPI(sap),
|
Service: NewPublicServerAPI(sap, sap.client),
|
||||||
Public: true,
|
Public: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
// VulcanizeDB
|
||||||
|
// Copyright © 2022 Vulcanize
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package shared
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewDB creates a new db connection and initializes the connection pool
|
||||||
|
func NewDB(connectString string, config postgres.Config) (*sqlx.DB, error) {
|
||||||
|
db, connectErr := sqlx.Connect("postgres", connectString)
|
||||||
|
if connectErr != nil {
|
||||||
|
return nil, postgres.ErrDBConnectionFailed(connectErr)
|
||||||
|
}
|
||||||
|
if config.MaxConns > 0 {
|
||||||
|
db.SetMaxOpenConns(config.MaxConns)
|
||||||
|
}
|
||||||
|
if config.MaxIdle > 0 {
|
||||||
|
db.SetMaxIdleConns(config.MaxIdle)
|
||||||
|
}
|
||||||
|
if config.MaxConnLifetime > 0 {
|
||||||
|
db.SetConnMaxLifetime(config.MaxConnLifetime)
|
||||||
|
}
|
||||||
|
|
||||||
|
return db, nil
|
||||||
|
}
|
||||||
+9
-36
@@ -18,11 +18,9 @@ package shared
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs/ipld"
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||||
dshelp "github.com/ipfs/go-ipfs-ds-help"
|
dshelp "github.com/ipfs/go-ipfs-ds-help"
|
||||||
node "github.com/ipfs/go-ipld-format"
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@@ -50,31 +48,18 @@ func Rollback(tx *sqlx.Tx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublishIPLD is used to insert an ipld into Postgres blockstore with the provided tx
|
// FetchIPLDByMhKeyAndBlockNumber is used to retrieve an ipld from Postgres blockstore with the provided tx, mhkey string and blockNumber
|
||||||
func PublishIPLD(tx *sqlx.Tx, i node.Node) error {
|
func FetchIPLDByMhKeyAndBlockNumber(tx *sqlx.Tx, mhKey string, blockNumber uint64) ([]byte, error) {
|
||||||
dbKey := dshelp.MultihashToDsKey(i.Cid().Hash())
|
pgStr := `SELECT data FROM public.blocks WHERE key = $1 AND block_number = $2`
|
||||||
prefixedKey := blockstore.BlockPrefix.String() + dbKey.String()
|
var block []byte
|
||||||
raw := i.RawData()
|
return block, tx.Get(&block, pgStr, mhKey, blockNumber)
|
||||||
_, err := tx.Exec(`INSERT INTO public.blocks (key, data) VALUES ($1, $2) ON CONFLICT (key) DO NOTHING`, prefixedKey, raw)
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchIPLD is used to retrieve an ipld from Postgres blockstore with the provided tx and cid string
|
// FetchIPLD is used to retrieve an IPLD from Postgres mhkey and blockNumber
|
||||||
func FetchIPLD(tx *sqlx.Tx, cid string) ([]byte, error) {
|
func FetchIPLD(db *sqlx.DB, mhKey string, blockNumber uint64) ([]byte, error) {
|
||||||
mhKey, err := MultihashKeyFromCIDString(cid)
|
pgStr := `SELECT data FROM public.blocks WHERE key = $1 AND block_number = $2`
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
pgStr := `SELECT data FROM public.blocks WHERE key = $1`
|
|
||||||
var block []byte
|
var block []byte
|
||||||
return block, tx.Get(&block, pgStr, mhKey)
|
return block, db.Get(&block, pgStr, mhKey, blockNumber)
|
||||||
}
|
|
||||||
|
|
||||||
// FetchIPLDByMhKey is used to retrieve an ipld from Postgres blockstore with the provided tx and mhkey string
|
|
||||||
func FetchIPLDByMhKey(tx *sqlx.Tx, mhKey string) ([]byte, error) {
|
|
||||||
pgStr := `SELECT data FROM public.blocks WHERE key = $1`
|
|
||||||
var block []byte
|
|
||||||
return block, tx.Get(&block, pgStr, mhKey)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MultihashKeyFromCID converts a cid into a blockstore-prefixed multihash db key string
|
// MultihashKeyFromCID converts a cid into a blockstore-prefixed multihash db key string
|
||||||
@@ -92,15 +77,3 @@ func MultihashKeyFromCIDString(c string) (string, error) {
|
|||||||
dbKey := dshelp.MultihashToDsKey(dc.Hash())
|
dbKey := dshelp.MultihashToDsKey(dc.Hash())
|
||||||
return blockstore.BlockPrefix.String() + dbKey.String(), nil
|
return blockstore.BlockPrefix.String() + dbKey.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublishRaw derives a cid from raw bytes and provided codec and multihash type, and writes it to the db tx
|
|
||||||
func PublishRaw(tx *sqlx.Tx, codec, mh uint64, raw []byte) (string, error) {
|
|
||||||
c, err := ipld.RawdataToCid(codec, raw, mh)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
dbKey := dshelp.MultihashToDsKey(c.Hash())
|
|
||||||
prefixedKey := blockstore.BlockPrefix.String() + dbKey.String()
|
|
||||||
_, err = tx.Exec(`INSERT INTO public.blocks (key, data) VALUES ($1, $2) ON CONFLICT (key) DO NOTHING`, prefixedKey, raw)
|
|
||||||
return c.String(), err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,12 +18,24 @@ package shared
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipfs"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IPLDsContainBytes used to check if a list of strings contains a particular string
|
// IPLDsContainBytes used to check if a list of strings contains a particular string
|
||||||
func IPLDsContainBytes(iplds []ipfs.BlockModel, b []byte) bool {
|
func IPLDsContainBytes(iplds []models.IPLDModel, b []byte) bool {
|
||||||
for _, ipld := range iplds {
|
for _, ipld := range iplds {
|
||||||
if bytes.Equal(ipld.Data, b) {
|
if bytes.Equal(ipld.Data, b) {
|
||||||
return true
|
return true
|
||||||
@@ -31,3 +43,73 @@ func IPLDsContainBytes(iplds []ipfs.BlockModel, b []byte) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetupDB is use to setup a db for watcher tests
|
||||||
|
func SetupDB() *sqlx.DB {
|
||||||
|
config := getTestDBConfig()
|
||||||
|
|
||||||
|
db, err := NewDB(config.DbConnectionString(), config)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
return db
|
||||||
|
}
|
||||||
|
|
||||||
|
// TearDownDB is used to tear down the watcher dbs after tests
|
||||||
|
func TearDownDB(db *sqlx.DB) {
|
||||||
|
tx, err := db.Beginx()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM nodes`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM eth.header_cids`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM eth.uncle_cids`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM eth.transaction_cids`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM eth.receipt_cids`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM eth.state_cids`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM eth.storage_cids`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM eth.state_accounts`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM eth.access_list_elements`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM blocks`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM eth.log_cids`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
_, err = tx.Exec(`DELETE FROM eth_meta.watched_addresses`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
err = tx.Commit()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetupTestStateDiffIndexer(ctx context.Context, chainConfig *params.ChainConfig, genHash common.Hash) interfaces.StateDiffIndexer {
|
||||||
|
testInfo := node.Info{
|
||||||
|
GenesisBlock: genHash.String(),
|
||||||
|
NetworkID: "1",
|
||||||
|
ID: "1",
|
||||||
|
ClientName: "geth",
|
||||||
|
ChainID: params.TestChainConfig.ChainID.Uint64(),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, stateDiffIndexer, err := indexer.NewStateDiffIndexer(ctx, chainConfig, testInfo, getTestDBConfig())
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
return stateDiffIndexer
|
||||||
|
}
|
||||||
|
|
||||||
|
func getTestDBConfig() postgres.Config {
|
||||||
|
port, _ := strconv.Atoi(os.Getenv("DATABASE_PORT"))
|
||||||
|
return postgres.Config{
|
||||||
|
Hostname: os.Getenv("DATABASE_HOSTNAME"),
|
||||||
|
DatabaseName: os.Getenv("DATABASE_NAME"),
|
||||||
|
Username: os.Getenv("DATABASE_USER"),
|
||||||
|
Password: os.Getenv("DATABASE_PASSWORD"),
|
||||||
|
Port: port,
|
||||||
|
Driver: postgres.SQLX,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,17 +3,8 @@ set -o xtrace
|
|||||||
|
|
||||||
export ETH_FORWARD_ETH_CALLS=false
|
export ETH_FORWARD_ETH_CALLS=false
|
||||||
export DB_WRITE=true
|
export DB_WRITE=true
|
||||||
export ETH_HTTP_PATH=""
|
|
||||||
export ETH_PROXY_ON_ERROR=false
|
export ETH_PROXY_ON_ERROR=false
|
||||||
|
|
||||||
# Clear up existing docker images and volume.
|
|
||||||
docker-compose down --remove-orphans --volumes
|
|
||||||
|
|
||||||
# Build and start the containers.
|
|
||||||
# Note: Build only if `ipld-eth-server` or other container code is modified. Otherwise comment this line.
|
|
||||||
docker-compose -f docker-compose.test.yml -f docker-compose.yml build eth-server
|
|
||||||
docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d ipld-eth-db dapptools contract eth-server
|
|
||||||
|
|
||||||
export PGPASSWORD=password
|
export PGPASSWORD=password
|
||||||
export DATABASE_USER=vdbm
|
export DATABASE_USER=vdbm
|
||||||
export DATABASE_PORT=8077
|
export DATABASE_PORT=8077
|
||||||
|
|||||||
Regular → Executable
-9
@@ -3,17 +3,8 @@ set -o xtrace
|
|||||||
|
|
||||||
export ETH_FORWARD_ETH_CALLS=true
|
export ETH_FORWARD_ETH_CALLS=true
|
||||||
export DB_WRITE=false
|
export DB_WRITE=false
|
||||||
export ETH_HTTP_PATH="dapptools:8545"
|
|
||||||
export ETH_PROXY_ON_ERROR=false
|
export ETH_PROXY_ON_ERROR=false
|
||||||
|
|
||||||
# Clear up existing docker images and volume.
|
|
||||||
docker-compose down --remove-orphans --volumes
|
|
||||||
|
|
||||||
# Build and start the containers.
|
|
||||||
# Note: Build only if `ipld-eth-server` or other container code is modified. Otherwise comment this line.
|
|
||||||
docker-compose -f docker-compose.test.yml -f docker-compose.yml build eth-server
|
|
||||||
docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d ipld-eth-db dapptools contract eth-server
|
|
||||||
|
|
||||||
export PGPASSWORD=password
|
export PGPASSWORD=password
|
||||||
export DATABASE_USER=vdbm
|
export DATABASE_USER=vdbm
|
||||||
export DATABASE_PORT=8077
|
export DATABASE_PORT=8077
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
# Clear up existing docker images and volume.
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Remove any existing containers / volumes
|
||||||
docker-compose down --remove-orphans --volumes
|
docker-compose down --remove-orphans --volumes
|
||||||
|
|
||||||
docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d ipld-eth-db
|
# Spin up DB and run migrations
|
||||||
|
docker-compose up -d migrations ipld-eth-db
|
||||||
|
sleep 30
|
||||||
|
|
||||||
|
# Run unit tests
|
||||||
|
go clean -testcache
|
||||||
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing make test
|
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing make test
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
docker-compose down --remove-orphans --volumes
|
||||||
|
rm -rf out/
|
||||||
|
|||||||
+112
-8
@@ -1,15 +1,119 @@
|
|||||||
|
# Test Insructions
|
||||||
|
|
||||||
Spin up services:
|
## Setup
|
||||||
```
|
|
||||||
docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d db dapptools contract eth-server
|
|
||||||
```
|
|
||||||
|
|
||||||
Running unit tests:
|
- Clone [stack-orchestrator](https://github.com/vulcanize/stack-orchestrator), [ipld-eth-db](https://github.com/vulcanize/ipld-eth-db) [go-ethereum](https://github.com/vulcanize/go-ethereum) repositories.
|
||||||
|
|
||||||
|
- Checkout [v4 release](https://github.com/vulcanize/ipld-eth-db/releases/tag/v4.2.1-alpha) in ipld-eth-db repo.
|
||||||
```bash
|
```bash
|
||||||
make test_local
|
# In ipld-eth-db repo.
|
||||||
|
git checkout v4.2.1-alpha
|
||||||
```
|
```
|
||||||
|
|
||||||
Running integration test:
|
- Checkout [v4 release](https://github.com/vulcanize/go-ethereum/releases/tag/v1.10.21-statediff-4.1.2-alpha) in go-ethereum repo.
|
||||||
```bash
|
```bash
|
||||||
make integrationtest_local
|
# In go-ethereum repo.
|
||||||
|
git checkout v1.10.21-statediff-4.1.2-alpha
|
||||||
|
```
|
||||||
|
|
||||||
|
- Checkout working commit in stack-orchestrator repo.
|
||||||
|
```bash
|
||||||
|
# In stack-orchestrator repo.
|
||||||
|
git checkout f2fd766f5400fcb9eb47b50675d2e3b1f2753702
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
- Run unit tests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# In ipld-eth-server root directory.
|
||||||
|
./scripts/run_unit_test.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
- Run integration tests:
|
||||||
|
|
||||||
|
- In stack-orchestrator repo, create config file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd helper-scripts
|
||||||
|
|
||||||
|
./create-config.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
A `config.sh` will be created in the root directory.
|
||||||
|
|
||||||
|
- Update/Edit the generated config file with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Path to ipld-eth-server repo.
|
||||||
|
vulcanize_ipld_eth_db=~/ipld-eth-db/
|
||||||
|
|
||||||
|
# Path to go-ethereum repo.
|
||||||
|
vulcanize_go_ethereum=~/go-ethereum/
|
||||||
|
|
||||||
|
# Path to ipld-eth-server repo.
|
||||||
|
vulcanize_ipld_eth_server=~/ipld-eth-server/
|
||||||
|
|
||||||
|
# Path to test contract.
|
||||||
|
vulcanize_test_contract=~/ipld-eth-server/test/contract
|
||||||
|
|
||||||
|
genesis_file_path='start-up-files/go-ethereum/genesis.json'
|
||||||
|
db_write=true
|
||||||
|
eth_forward_eth_calls=false
|
||||||
|
eth_proxy_on_error=false
|
||||||
|
eth_http_path="go-ethereum:8545"
|
||||||
|
```
|
||||||
|
|
||||||
|
- Run stack-orchestrator:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# In stack-orchestrator root directory.
|
||||||
|
cd helper-scripts
|
||||||
|
|
||||||
|
./wrapper.sh \
|
||||||
|
-e docker \
|
||||||
|
-d ../docker/local/docker-compose-db-sharding.yml \
|
||||||
|
-d ../docker/local/docker-compose-go-ethereum.yml \
|
||||||
|
-d ../docker/local/docker-compose-ipld-eth-server.yml \
|
||||||
|
-d ../docker/local/docker-compose-contract.yml \
|
||||||
|
-v remove \
|
||||||
|
-p ../config.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
- Run test:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# In ipld-eth-server root directory.
|
||||||
|
./scripts/run_integration_test.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
- Update stack-orchestrator `config.sh` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Path to go-ethereum repo.
|
||||||
|
vulcanize_go_ethereum=~/go-ethereum/
|
||||||
|
|
||||||
|
# Path to ipld-eth-server repo.
|
||||||
|
vulcanize_ipld_eth_server=~/ipld-eth-server/
|
||||||
|
|
||||||
|
# Path to test contract.
|
||||||
|
vulcanize_test_contract=~/ipld-eth-server/test/contract
|
||||||
|
|
||||||
|
genesis_file_path='start-up-files/go-ethereum/genesis.json'
|
||||||
|
db_write=false
|
||||||
|
eth_forward_eth_calls=true
|
||||||
|
eth_proxy_on_error=false
|
||||||
|
eth_http_path="go-ethereum:8545"
|
||||||
|
```
|
||||||
|
|
||||||
|
- Stop the stack-orchestrator and start again using the same command
|
||||||
|
|
||||||
|
- Run integration tests for direct proxy fall-through of eth_calls:
|
||||||
|
```bash
|
||||||
|
./scripts/run_integration_test_forward_eth_calls.sh
|
||||||
```
|
```
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// SPDX-License-Identifier: AGPL-3.0
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||||
|
|
||||||
|
contract SLVToken is ERC20 {
|
||||||
|
uint256 private countA;
|
||||||
|
uint256 private countB;
|
||||||
|
|
||||||
|
constructor() ERC20("Silver", "SLV") {}
|
||||||
|
|
||||||
|
function incrementCountA() public {
|
||||||
|
countA = countA + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function incrementCountB() public {
|
||||||
|
countB = countB + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
receive() external payable {}
|
||||||
|
|
||||||
|
function destroy() public {
|
||||||
|
selfdestruct(payable(msg.sender));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,15 +17,26 @@ task("accounts", "Prints the list of accounts", async () => {
|
|||||||
* @type import('hardhat/config').HardhatUserConfig
|
* @type import('hardhat/config').HardhatUserConfig
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
solidity: "0.8.0",
|
solidity: {
|
||||||
|
version: "0.8.0",
|
||||||
|
settings: {
|
||||||
|
outputSelection: {
|
||||||
|
'*': {
|
||||||
|
'*': [
|
||||||
|
'abi', 'storageLayout',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
networks: {
|
networks: {
|
||||||
local: {
|
local: {
|
||||||
url: 'http://127.0.0.1:8545',
|
url: 'http://127.0.0.1:8545',
|
||||||
chainId: 4
|
chainId: 99
|
||||||
},
|
},
|
||||||
docker: {
|
docker: {
|
||||||
url: process.env.ETH_ADDR,
|
url: process.env.ETH_ADDR,
|
||||||
chainId: 4
|
chainId: 99
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Generated
+46
-95
@@ -5,12 +5,14 @@
|
|||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "contract",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@openzeppelin/contracts": "^4.0.0",
|
"@openzeppelin/contracts": "^4.0.0",
|
||||||
"fastify": "^3.14.2",
|
"fastify": "^3.14.2",
|
||||||
"hardhat": "^2.2.0"
|
"hardhat": "^2.2.0",
|
||||||
|
"solidity-create2-deployer": "^0.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
||||||
@@ -254,10 +256,10 @@
|
|||||||
"@resolver-engine/imports-fs": "^0.3.3",
|
"@resolver-engine/imports-fs": "^0.3.3",
|
||||||
"@typechain/ethers-v5": "^2.0.0",
|
"@typechain/ethers-v5": "^2.0.0",
|
||||||
"@types/mkdirp": "^0.5.2",
|
"@types/mkdirp": "^0.5.2",
|
||||||
"@types/node-fetch": "^2.5.5",
|
"@types/node-fetch": "^2.6.7",
|
||||||
"ethers": "^5.0.1",
|
"ethers": "^5.0.1",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.7",
|
||||||
"solc": "^0.6.3",
|
"solc": "^0.6.3",
|
||||||
"ts-generator": "^0.1.1",
|
"ts-generator": "^0.1.1",
|
||||||
"typechain": "^3.0.0"
|
"typechain": "^3.0.0"
|
||||||
@@ -468,7 +470,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.1.0.tgz",
|
||||||
"integrity": "sha512-N/W9Sbn1/C6Kh2kuHRjf/hX6euMK4+9zdJRBB8sDWmihVntjUAfxbusGZKzDQD8i3szAHhTz8K7XADV5iFNfJw==",
|
"integrity": "sha512-N/W9Sbn1/C6Kh2kuHRjf/hX6euMK4+9zdJRBB8sDWmihVntjUAfxbusGZKzDQD8i3szAHhTz8K7XADV5iFNfJw==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -495,7 +496,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.1.0.tgz",
|
||||||
"integrity": "sha512-8dJUnT8VNvPwWhYIau4dwp7qe1g+KgdRm4XTWvjkI9gAT2zZa90WF5ApdZ3vl1r6NDmnn6vUVvyphClRZRteTQ==",
|
"integrity": "sha512-8dJUnT8VNvPwWhYIau4dwp7qe1g+KgdRm4XTWvjkI9gAT2zZa90WF5ApdZ3vl1r6NDmnn6vUVvyphClRZRteTQ==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -520,7 +520,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.1.0.tgz",
|
||||||
"integrity": "sha512-qQDMkjGZSSJSKl6AnfTgmz9FSnzq3iEoEbHTYwjDlEAv+LNP7zd4ixCcVWlWyk+2siud856M5CRhAmPdupeN9w==",
|
"integrity": "sha512-qQDMkjGZSSJSKl6AnfTgmz9FSnzq3iEoEbHTYwjDlEAv+LNP7zd4ixCcVWlWyk+2siud856M5CRhAmPdupeN9w==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -543,7 +542,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.1.0.tgz",
|
||||||
"integrity": "sha512-rfWQR12eHn2cpstCFS4RF7oGjfbkZb0oqep+BfrT+gWEGWG2IowJvIsacPOvzyS1jhNF4MQ4BS59B04Mbovteg==",
|
"integrity": "sha512-rfWQR12eHn2cpstCFS4RF7oGjfbkZb0oqep+BfrT+gWEGWG2IowJvIsacPOvzyS1jhNF4MQ4BS59B04Mbovteg==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -566,7 +564,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.1.0.tgz",
|
||||||
"integrity": "sha512-npD1bLvK4Bcxz+m4EMkx+F8Rd7CnqS9DYnhNu0/GlQBXhWjvfoAZzk5HJ0f1qeyp8d+A86PTuzLOGOXf4/CN8g==",
|
"integrity": "sha512-npD1bLvK4Bcxz+m4EMkx+F8Rd7CnqS9DYnhNu0/GlQBXhWjvfoAZzk5HJ0f1qeyp8d+A86PTuzLOGOXf4/CN8g==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -585,7 +582,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.1.0.tgz",
|
||||||
"integrity": "sha512-vBKr39bum7DDbOvkr1Sj19bRMEPA4FnST6Utt6xhDzI7o7L6QNkDn2yrCfP+hnvJGhZFKtLygWwqlTBZoBXYLg==",
|
"integrity": "sha512-vBKr39bum7DDbOvkr1Sj19bRMEPA4FnST6Utt6xhDzI7o7L6QNkDn2yrCfP+hnvJGhZFKtLygWwqlTBZoBXYLg==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -605,7 +601,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.1.0.tgz",
|
||||||
"integrity": "sha512-wUvQlhTjPjFXIdLPOuTrFeQmSa6Wvls1bGXQNQWvB/SEn1NsTCE8PmumIEZxmOPjSHl1eV2uyHP5jBm5Cgj92Q==",
|
"integrity": "sha512-wUvQlhTjPjFXIdLPOuTrFeQmSa6Wvls1bGXQNQWvB/SEn1NsTCE8PmumIEZxmOPjSHl1eV2uyHP5jBm5Cgj92Q==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -626,7 +621,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.1.0.tgz",
|
||||||
"integrity": "sha512-sGTxb+LVjFxJcJeUswAIK6ncgOrh3D8c192iEJd7mLr95V6du119rRfYT/b87WPkZ5I3gRBUYIYXtdgCWACe8g==",
|
"integrity": "sha512-sGTxb+LVjFxJcJeUswAIK6ncgOrh3D8c192iEJd7mLr95V6du119rRfYT/b87WPkZ5I3gRBUYIYXtdgCWACe8g==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -645,7 +639,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.1.0.tgz",
|
||||||
"integrity": "sha512-0/SuHrxc8R8k+JiLmJymxHJbojUDWBQqO+b+XFdwaP0jGzqC09YDy/CAlSZB6qHsBifY8X3I89HcK/oMqxRdBw==",
|
"integrity": "sha512-0/SuHrxc8R8k+JiLmJymxHJbojUDWBQqO+b+XFdwaP0jGzqC09YDy/CAlSZB6qHsBifY8X3I89HcK/oMqxRdBw==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -664,7 +657,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.1.0.tgz",
|
||||||
"integrity": "sha512-dvTMs/4XGSc57cYOW0KjgX1NdTujUu7mNb6PQdJWg08m9ULzPyGZuBkFJnijBcp6vTOCQ59RwjboWgNWw393og==",
|
"integrity": "sha512-dvTMs/4XGSc57cYOW0KjgX1NdTujUu7mNb6PQdJWg08m9ULzPyGZuBkFJnijBcp6vTOCQ59RwjboWgNWw393og==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -692,7 +684,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.1.0.tgz",
|
||||||
"integrity": "sha512-fNwry20yLLPpnRRwm3fBL+2ksgO+KMadxM44WJmRIoTKzy4269+rbq9KFoe2LTqq2CXJM2CE70beGaNrpuqflQ==",
|
"integrity": "sha512-fNwry20yLLPpnRRwm3fBL+2ksgO+KMadxM44WJmRIoTKzy4269+rbq9KFoe2LTqq2CXJM2CE70beGaNrpuqflQ==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -718,7 +709,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.1.0.tgz",
|
||||||
"integrity": "sha512-obIWdlujloExPHWJGmhJO/sETOOo7SEb6qemV4f8kyFoXg+cJK+Ta9SvBrj7hsUK85n3LZeZJZRjjM7oez3Clg==",
|
"integrity": "sha512-obIWdlujloExPHWJGmhJO/sETOOo7SEb6qemV4f8kyFoXg+cJK+Ta9SvBrj7hsUK85n3LZeZJZRjjM7oez3Clg==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -748,7 +738,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.1.0.tgz",
|
||||||
"integrity": "sha512-00n2iBy27w8zrGZSiU762UOVuzCQZxUZxopsZC47++js6xUFuI74DHcJ5K/2pddlF1YBskvmMuboEu1geK8mnA==",
|
"integrity": "sha512-00n2iBy27w8zrGZSiU762UOVuzCQZxUZxopsZC47++js6xUFuI74DHcJ5K/2pddlF1YBskvmMuboEu1geK8mnA==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -779,7 +768,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.1.0.tgz",
|
||||||
"integrity": "sha512-vrTB1W6AEYoadww5c9UyVJ2YcSiyIUTNDRccZIgwTmFFoSHwBtcvG1hqy9RzJ1T0bMdATbM9Hfx2mJ6H0i7Hig==",
|
"integrity": "sha512-vrTB1W6AEYoadww5c9UyVJ2YcSiyIUTNDRccZIgwTmFFoSHwBtcvG1hqy9RzJ1T0bMdATbM9Hfx2mJ6H0i7Hig==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -798,14 +786,12 @@
|
|||||||
"node_modules/@ethersproject/keccak256/node_modules/js-sha3": {
|
"node_modules/@ethersproject/keccak256/node_modules/js-sha3": {
|
||||||
"version": "0.5.7",
|
"version": "0.5.7",
|
||||||
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz",
|
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz",
|
||||||
"integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=",
|
"integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node_modules/@ethersproject/logger": {
|
"node_modules/@ethersproject/logger": {
|
||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.1.0.tgz",
|
||||||
"integrity": "sha512-wtUaD1lBX10HBXjjKV9VHCBnTdUaKQnQ2XSET1ezglqLdPdllNOIlLfhyCRqXm5xwcjExVI5ETokOYfjPtaAlw==",
|
"integrity": "sha512-wtUaD1lBX10HBXjjKV9VHCBnTdUaKQnQ2XSET1ezglqLdPdllNOIlLfhyCRqXm5xwcjExVI5ETokOYfjPtaAlw==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -821,7 +807,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.1.0.tgz",
|
||||||
"integrity": "sha512-A/NIrIED/G/IgU1XUukOA3WcFRxn2I4O5GxsYGA5nFlIi+UZWdGojs85I1VXkR1gX9eFnDXzjE6OtbgZHjFhIA==",
|
"integrity": "sha512-A/NIrIED/G/IgU1XUukOA3WcFRxn2I4O5GxsYGA5nFlIi+UZWdGojs85I1VXkR1gX9eFnDXzjE6OtbgZHjFhIA==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -840,7 +825,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.1.0.tgz",
|
||||||
"integrity": "sha512-B8cUbHHTgs8OtgJIafrRcz/YPDobVd5Ru8gTnShOiM9EBuFpYHQpq3+8iQJ6pyczDu6HP/oc/njAsIBhwFZYew==",
|
"integrity": "sha512-B8cUbHHTgs8OtgJIafrRcz/YPDobVd5Ru8gTnShOiM9EBuFpYHQpq3+8iQJ6pyczDu6HP/oc/njAsIBhwFZYew==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -860,7 +844,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.1.0.tgz",
|
||||||
"integrity": "sha512-519KKTwgmH42AQL3+GFV3SX6khYEfHsvI6v8HYejlkigSDuqttdgVygFTDsGlofNFchhDwuclrxQnD5B0YLNMg==",
|
"integrity": "sha512-519KKTwgmH42AQL3+GFV3SX6khYEfHsvI6v8HYejlkigSDuqttdgVygFTDsGlofNFchhDwuclrxQnD5B0YLNMg==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -879,7 +862,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.1.0.tgz",
|
||||||
"integrity": "sha512-FjpZL2lSXrYpQDg2fMjugZ0HjQD9a+2fOOoRhhihh+Z+qi/xZ8vIlPoumrEP1DzIG4DBV6liUqLNqnX2C6FIAA==",
|
"integrity": "sha512-FjpZL2lSXrYpQDg2fMjugZ0HjQD9a+2fOOoRhhihh+Z+qi/xZ8vIlPoumrEP1DzIG4DBV6liUqLNqnX2C6FIAA==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -916,7 +898,6 @@
|
|||||||
"version": "7.2.3",
|
"version": "7.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz",
|
||||||
"integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==",
|
"integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.3.0"
|
"node": ">=8.3.0"
|
||||||
},
|
},
|
||||||
@@ -937,7 +918,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.1.0.tgz",
|
||||||
"integrity": "sha512-+uuczLQZ4+no9cP6TCoCktXx0u2YbNaRT7lRkSt12d8263e702f0u+4JnnRO8Qmv5nylWJebnqCHzyxP+6mLqw==",
|
"integrity": "sha512-+uuczLQZ4+no9cP6TCoCktXx0u2YbNaRT7lRkSt12d8263e702f0u+4JnnRO8Qmv5nylWJebnqCHzyxP+6mLqw==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -957,7 +937,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.1.0.tgz",
|
||||||
"integrity": "sha512-vDTyHIwNPrecy55gKGZ47eJZhBm8LLBxihzi5ou+zrSvYTpkSTWRcKUlXFDFQVwfWB+P5PGyERAdiDEI76clxw==",
|
"integrity": "sha512-vDTyHIwNPrecy55gKGZ47eJZhBm8LLBxihzi5ou+zrSvYTpkSTWRcKUlXFDFQVwfWB+P5PGyERAdiDEI76clxw==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -977,7 +956,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.1.0.tgz",
|
||||||
"integrity": "sha512-+fNSeZRstOpdRJpdGUkRONFCaiAqWkc91zXgg76Nlp5ndBQE25Kk5yK8gCPG1aGnCrbariiPr5j9DmrYH78JCA==",
|
"integrity": "sha512-+fNSeZRstOpdRJpdGUkRONFCaiAqWkc91zXgg76Nlp5ndBQE25Kk5yK8gCPG1aGnCrbariiPr5j9DmrYH78JCA==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -998,7 +976,6 @@
|
|||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz",
|
||||||
"integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==",
|
"integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"inherits": "^2.0.3",
|
"inherits": "^2.0.3",
|
||||||
"minimalistic-assert": "^1.0.0"
|
"minimalistic-assert": "^1.0.0"
|
||||||
@@ -1008,7 +985,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.1.0.tgz",
|
||||||
"integrity": "sha512-tE5LFlbmdObG8bY04NpuwPWSRPgEswfxweAI1sH7TbP0ml1elNfqcq7ii/3AvIN05i5U0Pkm3Tf8bramt8MmLw==",
|
"integrity": "sha512-tE5LFlbmdObG8bY04NpuwPWSRPgEswfxweAI1sH7TbP0ml1elNfqcq7ii/3AvIN05i5U0Pkm3Tf8bramt8MmLw==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -1031,7 +1007,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.1.0.tgz",
|
||||||
"integrity": "sha512-kPodsGyo9zg1g9XSXp1lGhFaezBAUUsAUB1Vf6OkppE5Wksg4Et+x3kG4m7J/uShDMP2upkJtHNsIBK2XkVpKQ==",
|
"integrity": "sha512-kPodsGyo9zg1g9XSXp1lGhFaezBAUUsAUB1Vf6OkppE5Wksg4Et+x3kG4m7J/uShDMP2upkJtHNsIBK2XkVpKQ==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -1054,7 +1029,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.1.0.tgz",
|
||||||
"integrity": "sha512-perBZy0RrmmL0ejiFGUOlBVjMsUceqLut3OBP3zP96LhiJWWbS8u1NqQVgN4/Gyrbziuda66DxiQocXhsvx+Sw==",
|
"integrity": "sha512-perBZy0RrmmL0ejiFGUOlBVjMsUceqLut3OBP3zP96LhiJWWbS8u1NqQVgN4/Gyrbziuda66DxiQocXhsvx+Sw==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -1075,7 +1049,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.1.0.tgz",
|
||||||
"integrity": "sha512-s10crRLZEA0Bgv6FGEl/AKkTw9f+RVUrlWDX1rHnD4ZncPFeiV2AJr4nT7QSUhxJdFPvjyKRDb3nEH27dIqcPQ==",
|
"integrity": "sha512-s10crRLZEA0Bgv6FGEl/AKkTw9f+RVUrlWDX1rHnD4ZncPFeiV2AJr4nT7QSUhxJdFPvjyKRDb3nEH27dIqcPQ==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -1102,7 +1075,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.1.0.tgz",
|
||||||
"integrity": "sha512-isvJrx6qG0nKWfxsGORNjmOq/nh175fStfvRTA2xEKrGqx8JNJY83fswu4GkILowfriEM/eYpretfJnfzi7YhA==",
|
"integrity": "sha512-isvJrx6qG0nKWfxsGORNjmOq/nh175fStfvRTA2xEKrGqx8JNJY83fswu4GkILowfriEM/eYpretfJnfzi7YhA==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -1123,7 +1095,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.1.0.tgz",
|
||||||
"integrity": "sha512-ULmUtiYQLTUS+y3DgkLzRhFEK10zMwmjOthnjiZxee3Q/MVwr3rnmuAnXIUZrPjna6hvUPnyRIdW5XuF0Ld0YQ==",
|
"integrity": "sha512-ULmUtiYQLTUS+y3DgkLzRhFEK10zMwmjOthnjiZxee3Q/MVwr3rnmuAnXIUZrPjna6hvUPnyRIdW5XuF0Ld0YQ==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -1156,7 +1127,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.1.0.tgz",
|
||||||
"integrity": "sha512-LTeluWgTq04+RNqAkVhpydPcRZK/kKxD2Vy7PYGrAD27ABO9kTqTBKwiOuzTyAHKUQHfnvZbXmxBXJAGViSDcA==",
|
"integrity": "sha512-LTeluWgTq04+RNqAkVhpydPcRZK/kKxD2Vy7PYGrAD27ABO9kTqTBKwiOuzTyAHKUQHfnvZbXmxBXJAGViSDcA==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -1179,7 +1149,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.1.0.tgz",
|
||||||
"integrity": "sha512-NsUCi/TpBb+oTFvMSccUkJGtp5o/84eOyqp5q5aBeiNBSLkYyw21znRn9mAmxZgySpxgruVgKbaapnYPgvctPQ==",
|
"integrity": "sha512-NsUCi/TpBb+oTFvMSccUkJGtp5o/84eOyqp5q5aBeiNBSLkYyw21znRn9mAmxZgySpxgruVgKbaapnYPgvctPQ==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -1506,7 +1475,7 @@
|
|||||||
"integrity": "sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g=="
|
"integrity": "sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g=="
|
||||||
},
|
},
|
||||||
"node_modules/@types/node-fetch": {
|
"node_modules/@types/node-fetch": {
|
||||||
"version": "2.5.10",
|
"version": "2.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.10.tgz",
|
||||||
"integrity": "sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==",
|
"integrity": "sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@@ -1629,8 +1598,7 @@
|
|||||||
"node_modules/aes-js": {
|
"node_modules/aes-js": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz",
|
||||||
"integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0=",
|
"integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node_modules/agent-base": {
|
"node_modules/agent-base": {
|
||||||
"version": "6.0.2",
|
"version": "6.0.2",
|
||||||
@@ -1869,8 +1837,7 @@
|
|||||||
"node_modules/bech32": {
|
"node_modules/bech32": {
|
||||||
"version": "1.1.4",
|
"version": "1.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz",
|
||||||
"integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==",
|
"integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node_modules/binary-extensions": {
|
"node_modules/binary-extensions": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
@@ -2773,7 +2740,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/ethers/-/ethers-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/ethers/-/ethers-5.1.0.tgz",
|
||||||
"integrity": "sha512-2L6Ge6wMBw02FlRoCLg4E0Elt3khMNlW6ULawa10mMeeZToYJ5+uCfiuTuB+XZ6om1Y7wuO9ZzezP8FsU2M/+g==",
|
"integrity": "sha512-2L6Ge6wMBw02FlRoCLg4E0Elt3khMNlW6ULawa10mMeeZToYJ5+uCfiuTuB+XZ6om1Y7wuO9ZzezP8FsU2M/+g==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -3093,7 +3059,7 @@
|
|||||||
"integrity": "sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw=="
|
"integrity": "sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw=="
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
"node_modules/follow-redirects": {
|
||||||
"version": "1.13.3",
|
"version": "1.14.7",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
|
||||||
"integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==",
|
"integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==",
|
||||||
"funding": [
|
"funding": [
|
||||||
@@ -12519,7 +12485,7 @@
|
|||||||
"merkle-patricia-tree": "^4.1.0",
|
"merkle-patricia-tree": "^4.1.0",
|
||||||
"mnemonist": "^0.38.0",
|
"mnemonist": "^0.38.0",
|
||||||
"mocha": "^7.1.2",
|
"mocha": "^7.1.2",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.7",
|
||||||
"qs": "^6.7.0",
|
"qs": "^6.7.0",
|
||||||
"raw-body": "^2.4.1",
|
"raw-body": "^2.4.1",
|
||||||
"resolve": "1.17.0",
|
"resolve": "1.17.0",
|
||||||
@@ -13722,7 +13688,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/node-fetch": {
|
"node_modules/node-fetch": {
|
||||||
"version": "2.6.1",
|
"version": "2.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -14696,7 +14662,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"command-exists": "^1.2.8",
|
"command-exists": "^1.2.8",
|
||||||
"commander": "3.0.2",
|
"commander": "3.0.2",
|
||||||
"follow-redirects": "^1.12.1",
|
"follow-redirects": "^1.14.7",
|
||||||
"fs-extra": "^0.30.0",
|
"fs-extra": "^0.30.0",
|
||||||
"js-sha3": "0.8.0",
|
"js-sha3": "0.8.0",
|
||||||
"memorystream": "^0.3.1",
|
"memorystream": "^0.3.1",
|
||||||
@@ -14739,6 +14705,17 @@
|
|||||||
"semver": "bin/semver"
|
"semver": "bin/semver"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/solidity-create2-deployer": {
|
||||||
|
"version": "0.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/solidity-create2-deployer/-/solidity-create2-deployer-0.4.0.tgz",
|
||||||
|
"integrity": "sha512-bB5d8fPt4dWsOoRodrsyfWKcjiv77IFl84+e6EckMMGYlfL2ZFqUoMz6tnqqiUFrM9abF1p6dWFOgJ/3zVc8yQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"ethers": "^5.0.14"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/sonic-boom": {
|
"node_modules/sonic-boom": {
|
||||||
"version": "1.4.1",
|
"version": "1.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-1.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-1.4.1.tgz",
|
||||||
@@ -15856,10 +15833,10 @@
|
|||||||
"@resolver-engine/imports-fs": "^0.3.3",
|
"@resolver-engine/imports-fs": "^0.3.3",
|
||||||
"@typechain/ethers-v5": "^2.0.0",
|
"@typechain/ethers-v5": "^2.0.0",
|
||||||
"@types/mkdirp": "^0.5.2",
|
"@types/mkdirp": "^0.5.2",
|
||||||
"@types/node-fetch": "^2.5.5",
|
"@types/node-fetch": "^2.6.7",
|
||||||
"ethers": "^5.0.1",
|
"ethers": "^5.0.1",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.7",
|
||||||
"solc": "^0.6.3",
|
"solc": "^0.6.3",
|
||||||
"ts-generator": "^0.1.1",
|
"ts-generator": "^0.1.1",
|
||||||
"typechain": "^3.0.0"
|
"typechain": "^3.0.0"
|
||||||
@@ -16055,7 +16032,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.1.0.tgz",
|
||||||
"integrity": "sha512-N/W9Sbn1/C6Kh2kuHRjf/hX6euMK4+9zdJRBB8sDWmihVntjUAfxbusGZKzDQD8i3szAHhTz8K7XADV5iFNfJw==",
|
"integrity": "sha512-N/W9Sbn1/C6Kh2kuHRjf/hX6euMK4+9zdJRBB8sDWmihVntjUAfxbusGZKzDQD8i3szAHhTz8K7XADV5iFNfJw==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/address": "^5.1.0",
|
"@ethersproject/address": "^5.1.0",
|
||||||
"@ethersproject/bignumber": "^5.1.0",
|
"@ethersproject/bignumber": "^5.1.0",
|
||||||
@@ -16072,7 +16048,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.1.0.tgz",
|
||||||
"integrity": "sha512-8dJUnT8VNvPwWhYIau4dwp7qe1g+KgdRm4XTWvjkI9gAT2zZa90WF5ApdZ3vl1r6NDmnn6vUVvyphClRZRteTQ==",
|
"integrity": "sha512-8dJUnT8VNvPwWhYIau4dwp7qe1g+KgdRm4XTWvjkI9gAT2zZa90WF5ApdZ3vl1r6NDmnn6vUVvyphClRZRteTQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bignumber": "^5.1.0",
|
"@ethersproject/bignumber": "^5.1.0",
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
@@ -16087,7 +16062,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.1.0.tgz",
|
||||||
"integrity": "sha512-qQDMkjGZSSJSKl6AnfTgmz9FSnzq3iEoEbHTYwjDlEAv+LNP7zd4ixCcVWlWyk+2siud856M5CRhAmPdupeN9w==",
|
"integrity": "sha512-qQDMkjGZSSJSKl6AnfTgmz9FSnzq3iEoEbHTYwjDlEAv+LNP7zd4ixCcVWlWyk+2siud856M5CRhAmPdupeN9w==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/abstract-provider": "^5.1.0",
|
"@ethersproject/abstract-provider": "^5.1.0",
|
||||||
"@ethersproject/bignumber": "^5.1.0",
|
"@ethersproject/bignumber": "^5.1.0",
|
||||||
@@ -16100,7 +16074,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.1.0.tgz",
|
||||||
"integrity": "sha512-rfWQR12eHn2cpstCFS4RF7oGjfbkZb0oqep+BfrT+gWEGWG2IowJvIsacPOvzyS1jhNF4MQ4BS59B04Mbovteg==",
|
"integrity": "sha512-rfWQR12eHn2cpstCFS4RF7oGjfbkZb0oqep+BfrT+gWEGWG2IowJvIsacPOvzyS1jhNF4MQ4BS59B04Mbovteg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bignumber": "^5.1.0",
|
"@ethersproject/bignumber": "^5.1.0",
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
@@ -16113,7 +16086,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.1.0.tgz",
|
||||||
"integrity": "sha512-npD1bLvK4Bcxz+m4EMkx+F8Rd7CnqS9DYnhNu0/GlQBXhWjvfoAZzk5HJ0f1qeyp8d+A86PTuzLOGOXf4/CN8g==",
|
"integrity": "sha512-npD1bLvK4Bcxz+m4EMkx+F8Rd7CnqS9DYnhNu0/GlQBXhWjvfoAZzk5HJ0f1qeyp8d+A86PTuzLOGOXf4/CN8g==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0"
|
"@ethersproject/bytes": "^5.1.0"
|
||||||
}
|
}
|
||||||
@@ -16122,7 +16094,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.1.0.tgz",
|
||||||
"integrity": "sha512-vBKr39bum7DDbOvkr1Sj19bRMEPA4FnST6Utt6xhDzI7o7L6QNkDn2yrCfP+hnvJGhZFKtLygWwqlTBZoBXYLg==",
|
"integrity": "sha512-vBKr39bum7DDbOvkr1Sj19bRMEPA4FnST6Utt6xhDzI7o7L6QNkDn2yrCfP+hnvJGhZFKtLygWwqlTBZoBXYLg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
"@ethersproject/properties": "^5.1.0"
|
"@ethersproject/properties": "^5.1.0"
|
||||||
@@ -16132,7 +16103,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.1.0.tgz",
|
||||||
"integrity": "sha512-wUvQlhTjPjFXIdLPOuTrFeQmSa6Wvls1bGXQNQWvB/SEn1NsTCE8PmumIEZxmOPjSHl1eV2uyHP5jBm5Cgj92Q==",
|
"integrity": "sha512-wUvQlhTjPjFXIdLPOuTrFeQmSa6Wvls1bGXQNQWvB/SEn1NsTCE8PmumIEZxmOPjSHl1eV2uyHP5jBm5Cgj92Q==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
"@ethersproject/logger": "^5.1.0",
|
"@ethersproject/logger": "^5.1.0",
|
||||||
@@ -16143,7 +16113,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.1.0.tgz",
|
||||||
"integrity": "sha512-sGTxb+LVjFxJcJeUswAIK6ncgOrh3D8c192iEJd7mLr95V6du119rRfYT/b87WPkZ5I3gRBUYIYXtdgCWACe8g==",
|
"integrity": "sha512-sGTxb+LVjFxJcJeUswAIK6ncgOrh3D8c192iEJd7mLr95V6du119rRfYT/b87WPkZ5I3gRBUYIYXtdgCWACe8g==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/logger": "^5.1.0"
|
"@ethersproject/logger": "^5.1.0"
|
||||||
}
|
}
|
||||||
@@ -16152,7 +16121,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.1.0.tgz",
|
||||||
"integrity": "sha512-0/SuHrxc8R8k+JiLmJymxHJbojUDWBQqO+b+XFdwaP0jGzqC09YDy/CAlSZB6qHsBifY8X3I89HcK/oMqxRdBw==",
|
"integrity": "sha512-0/SuHrxc8R8k+JiLmJymxHJbojUDWBQqO+b+XFdwaP0jGzqC09YDy/CAlSZB6qHsBifY8X3I89HcK/oMqxRdBw==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bignumber": "^5.1.0"
|
"@ethersproject/bignumber": "^5.1.0"
|
||||||
}
|
}
|
||||||
@@ -16161,7 +16129,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.1.0.tgz",
|
||||||
"integrity": "sha512-dvTMs/4XGSc57cYOW0KjgX1NdTujUu7mNb6PQdJWg08m9ULzPyGZuBkFJnijBcp6vTOCQ59RwjboWgNWw393og==",
|
"integrity": "sha512-dvTMs/4XGSc57cYOW0KjgX1NdTujUu7mNb6PQdJWg08m9ULzPyGZuBkFJnijBcp6vTOCQ59RwjboWgNWw393og==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/abi": "^5.1.0",
|
"@ethersproject/abi": "^5.1.0",
|
||||||
"@ethersproject/abstract-provider": "^5.1.0",
|
"@ethersproject/abstract-provider": "^5.1.0",
|
||||||
@@ -16179,7 +16146,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.1.0.tgz",
|
||||||
"integrity": "sha512-fNwry20yLLPpnRRwm3fBL+2ksgO+KMadxM44WJmRIoTKzy4269+rbq9KFoe2LTqq2CXJM2CE70beGaNrpuqflQ==",
|
"integrity": "sha512-fNwry20yLLPpnRRwm3fBL+2ksgO+KMadxM44WJmRIoTKzy4269+rbq9KFoe2LTqq2CXJM2CE70beGaNrpuqflQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/abstract-signer": "^5.1.0",
|
"@ethersproject/abstract-signer": "^5.1.0",
|
||||||
"@ethersproject/address": "^5.1.0",
|
"@ethersproject/address": "^5.1.0",
|
||||||
@@ -16195,7 +16161,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.1.0.tgz",
|
||||||
"integrity": "sha512-obIWdlujloExPHWJGmhJO/sETOOo7SEb6qemV4f8kyFoXg+cJK+Ta9SvBrj7hsUK85n3LZeZJZRjjM7oez3Clg==",
|
"integrity": "sha512-obIWdlujloExPHWJGmhJO/sETOOo7SEb6qemV4f8kyFoXg+cJK+Ta9SvBrj7hsUK85n3LZeZJZRjjM7oez3Clg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/abstract-signer": "^5.1.0",
|
"@ethersproject/abstract-signer": "^5.1.0",
|
||||||
"@ethersproject/basex": "^5.1.0",
|
"@ethersproject/basex": "^5.1.0",
|
||||||
@@ -16215,7 +16180,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.1.0.tgz",
|
||||||
"integrity": "sha512-00n2iBy27w8zrGZSiU762UOVuzCQZxUZxopsZC47++js6xUFuI74DHcJ5K/2pddlF1YBskvmMuboEu1geK8mnA==",
|
"integrity": "sha512-00n2iBy27w8zrGZSiU762UOVuzCQZxUZxopsZC47++js6xUFuI74DHcJ5K/2pddlF1YBskvmMuboEu1geK8mnA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/abstract-signer": "^5.1.0",
|
"@ethersproject/abstract-signer": "^5.1.0",
|
||||||
"@ethersproject/address": "^5.1.0",
|
"@ethersproject/address": "^5.1.0",
|
||||||
@@ -16236,7 +16200,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.1.0.tgz",
|
||||||
"integrity": "sha512-vrTB1W6AEYoadww5c9UyVJ2YcSiyIUTNDRccZIgwTmFFoSHwBtcvG1hqy9RzJ1T0bMdATbM9Hfx2mJ6H0i7Hig==",
|
"integrity": "sha512-vrTB1W6AEYoadww5c9UyVJ2YcSiyIUTNDRccZIgwTmFFoSHwBtcvG1hqy9RzJ1T0bMdATbM9Hfx2mJ6H0i7Hig==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
"js-sha3": "0.5.7"
|
"js-sha3": "0.5.7"
|
||||||
@@ -16245,22 +16208,19 @@
|
|||||||
"js-sha3": {
|
"js-sha3": {
|
||||||
"version": "0.5.7",
|
"version": "0.5.7",
|
||||||
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz",
|
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz",
|
||||||
"integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=",
|
"integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc="
|
||||||
"dev": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@ethersproject/logger": {
|
"@ethersproject/logger": {
|
||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.1.0.tgz",
|
||||||
"integrity": "sha512-wtUaD1lBX10HBXjjKV9VHCBnTdUaKQnQ2XSET1ezglqLdPdllNOIlLfhyCRqXm5xwcjExVI5ETokOYfjPtaAlw==",
|
"integrity": "sha512-wtUaD1lBX10HBXjjKV9VHCBnTdUaKQnQ2XSET1ezglqLdPdllNOIlLfhyCRqXm5xwcjExVI5ETokOYfjPtaAlw=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"@ethersproject/networks": {
|
"@ethersproject/networks": {
|
||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.1.0.tgz",
|
||||||
"integrity": "sha512-A/NIrIED/G/IgU1XUukOA3WcFRxn2I4O5GxsYGA5nFlIi+UZWdGojs85I1VXkR1gX9eFnDXzjE6OtbgZHjFhIA==",
|
"integrity": "sha512-A/NIrIED/G/IgU1XUukOA3WcFRxn2I4O5GxsYGA5nFlIi+UZWdGojs85I1VXkR1gX9eFnDXzjE6OtbgZHjFhIA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/logger": "^5.1.0"
|
"@ethersproject/logger": "^5.1.0"
|
||||||
}
|
}
|
||||||
@@ -16269,7 +16229,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.1.0.tgz",
|
||||||
"integrity": "sha512-B8cUbHHTgs8OtgJIafrRcz/YPDobVd5Ru8gTnShOiM9EBuFpYHQpq3+8iQJ6pyczDu6HP/oc/njAsIBhwFZYew==",
|
"integrity": "sha512-B8cUbHHTgs8OtgJIafrRcz/YPDobVd5Ru8gTnShOiM9EBuFpYHQpq3+8iQJ6pyczDu6HP/oc/njAsIBhwFZYew==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
"@ethersproject/sha2": "^5.1.0"
|
"@ethersproject/sha2": "^5.1.0"
|
||||||
@@ -16279,7 +16238,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.1.0.tgz",
|
||||||
"integrity": "sha512-519KKTwgmH42AQL3+GFV3SX6khYEfHsvI6v8HYejlkigSDuqttdgVygFTDsGlofNFchhDwuclrxQnD5B0YLNMg==",
|
"integrity": "sha512-519KKTwgmH42AQL3+GFV3SX6khYEfHsvI6v8HYejlkigSDuqttdgVygFTDsGlofNFchhDwuclrxQnD5B0YLNMg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/logger": "^5.1.0"
|
"@ethersproject/logger": "^5.1.0"
|
||||||
}
|
}
|
||||||
@@ -16288,7 +16246,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.1.0.tgz",
|
||||||
"integrity": "sha512-FjpZL2lSXrYpQDg2fMjugZ0HjQD9a+2fOOoRhhihh+Z+qi/xZ8vIlPoumrEP1DzIG4DBV6liUqLNqnX2C6FIAA==",
|
"integrity": "sha512-FjpZL2lSXrYpQDg2fMjugZ0HjQD9a+2fOOoRhhihh+Z+qi/xZ8vIlPoumrEP1DzIG4DBV6liUqLNqnX2C6FIAA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/abstract-provider": "^5.1.0",
|
"@ethersproject/abstract-provider": "^5.1.0",
|
||||||
"@ethersproject/abstract-signer": "^5.1.0",
|
"@ethersproject/abstract-signer": "^5.1.0",
|
||||||
@@ -16315,7 +16272,6 @@
|
|||||||
"version": "7.2.3",
|
"version": "7.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz",
|
||||||
"integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==",
|
"integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {}
|
"requires": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16324,7 +16280,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.1.0.tgz",
|
||||||
"integrity": "sha512-+uuczLQZ4+no9cP6TCoCktXx0u2YbNaRT7lRkSt12d8263e702f0u+4JnnRO8Qmv5nylWJebnqCHzyxP+6mLqw==",
|
"integrity": "sha512-+uuczLQZ4+no9cP6TCoCktXx0u2YbNaRT7lRkSt12d8263e702f0u+4JnnRO8Qmv5nylWJebnqCHzyxP+6mLqw==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
"@ethersproject/logger": "^5.1.0"
|
"@ethersproject/logger": "^5.1.0"
|
||||||
@@ -16334,7 +16289,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.1.0.tgz",
|
||||||
"integrity": "sha512-vDTyHIwNPrecy55gKGZ47eJZhBm8LLBxihzi5ou+zrSvYTpkSTWRcKUlXFDFQVwfWB+P5PGyERAdiDEI76clxw==",
|
"integrity": "sha512-vDTyHIwNPrecy55gKGZ47eJZhBm8LLBxihzi5ou+zrSvYTpkSTWRcKUlXFDFQVwfWB+P5PGyERAdiDEI76clxw==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
"@ethersproject/logger": "^5.1.0"
|
"@ethersproject/logger": "^5.1.0"
|
||||||
@@ -16344,7 +16298,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.1.0.tgz",
|
||||||
"integrity": "sha512-+fNSeZRstOpdRJpdGUkRONFCaiAqWkc91zXgg76Nlp5ndBQE25Kk5yK8gCPG1aGnCrbariiPr5j9DmrYH78JCA==",
|
"integrity": "sha512-+fNSeZRstOpdRJpdGUkRONFCaiAqWkc91zXgg76Nlp5ndBQE25Kk5yK8gCPG1aGnCrbariiPr5j9DmrYH78JCA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
"@ethersproject/logger": "^5.1.0",
|
"@ethersproject/logger": "^5.1.0",
|
||||||
@@ -16355,7 +16308,6 @@
|
|||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz",
|
||||||
"integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==",
|
"integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"inherits": "^2.0.3",
|
"inherits": "^2.0.3",
|
||||||
"minimalistic-assert": "^1.0.0"
|
"minimalistic-assert": "^1.0.0"
|
||||||
@@ -16367,7 +16319,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.1.0.tgz",
|
||||||
"integrity": "sha512-tE5LFlbmdObG8bY04NpuwPWSRPgEswfxweAI1sH7TbP0ml1elNfqcq7ii/3AvIN05i5U0Pkm3Tf8bramt8MmLw==",
|
"integrity": "sha512-tE5LFlbmdObG8bY04NpuwPWSRPgEswfxweAI1sH7TbP0ml1elNfqcq7ii/3AvIN05i5U0Pkm3Tf8bramt8MmLw==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
"@ethersproject/logger": "^5.1.0",
|
"@ethersproject/logger": "^5.1.0",
|
||||||
@@ -16380,7 +16331,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.1.0.tgz",
|
||||||
"integrity": "sha512-kPodsGyo9zg1g9XSXp1lGhFaezBAUUsAUB1Vf6OkppE5Wksg4Et+x3kG4m7J/uShDMP2upkJtHNsIBK2XkVpKQ==",
|
"integrity": "sha512-kPodsGyo9zg1g9XSXp1lGhFaezBAUUsAUB1Vf6OkppE5Wksg4Et+x3kG4m7J/uShDMP2upkJtHNsIBK2XkVpKQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bignumber": "^5.1.0",
|
"@ethersproject/bignumber": "^5.1.0",
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
@@ -16393,7 +16343,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.1.0.tgz",
|
||||||
"integrity": "sha512-perBZy0RrmmL0ejiFGUOlBVjMsUceqLut3OBP3zP96LhiJWWbS8u1NqQVgN4/Gyrbziuda66DxiQocXhsvx+Sw==",
|
"integrity": "sha512-perBZy0RrmmL0ejiFGUOlBVjMsUceqLut3OBP3zP96LhiJWWbS8u1NqQVgN4/Gyrbziuda66DxiQocXhsvx+Sw==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
"@ethersproject/constants": "^5.1.0",
|
"@ethersproject/constants": "^5.1.0",
|
||||||
@@ -16404,7 +16353,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.1.0.tgz",
|
||||||
"integrity": "sha512-s10crRLZEA0Bgv6FGEl/AKkTw9f+RVUrlWDX1rHnD4ZncPFeiV2AJr4nT7QSUhxJdFPvjyKRDb3nEH27dIqcPQ==",
|
"integrity": "sha512-s10crRLZEA0Bgv6FGEl/AKkTw9f+RVUrlWDX1rHnD4ZncPFeiV2AJr4nT7QSUhxJdFPvjyKRDb3nEH27dIqcPQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/address": "^5.1.0",
|
"@ethersproject/address": "^5.1.0",
|
||||||
"@ethersproject/bignumber": "^5.1.0",
|
"@ethersproject/bignumber": "^5.1.0",
|
||||||
@@ -16421,7 +16369,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.1.0.tgz",
|
||||||
"integrity": "sha512-isvJrx6qG0nKWfxsGORNjmOq/nh175fStfvRTA2xEKrGqx8JNJY83fswu4GkILowfriEM/eYpretfJnfzi7YhA==",
|
"integrity": "sha512-isvJrx6qG0nKWfxsGORNjmOq/nh175fStfvRTA2xEKrGqx8JNJY83fswu4GkILowfriEM/eYpretfJnfzi7YhA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bignumber": "^5.1.0",
|
"@ethersproject/bignumber": "^5.1.0",
|
||||||
"@ethersproject/constants": "^5.1.0",
|
"@ethersproject/constants": "^5.1.0",
|
||||||
@@ -16432,7 +16379,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.1.0.tgz",
|
||||||
"integrity": "sha512-ULmUtiYQLTUS+y3DgkLzRhFEK10zMwmjOthnjiZxee3Q/MVwr3rnmuAnXIUZrPjna6hvUPnyRIdW5XuF0Ld0YQ==",
|
"integrity": "sha512-ULmUtiYQLTUS+y3DgkLzRhFEK10zMwmjOthnjiZxee3Q/MVwr3rnmuAnXIUZrPjna6hvUPnyRIdW5XuF0Ld0YQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/abstract-provider": "^5.1.0",
|
"@ethersproject/abstract-provider": "^5.1.0",
|
||||||
"@ethersproject/abstract-signer": "^5.1.0",
|
"@ethersproject/abstract-signer": "^5.1.0",
|
||||||
@@ -16455,7 +16401,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.1.0.tgz",
|
||||||
"integrity": "sha512-LTeluWgTq04+RNqAkVhpydPcRZK/kKxD2Vy7PYGrAD27ABO9kTqTBKwiOuzTyAHKUQHfnvZbXmxBXJAGViSDcA==",
|
"integrity": "sha512-LTeluWgTq04+RNqAkVhpydPcRZK/kKxD2Vy7PYGrAD27ABO9kTqTBKwiOuzTyAHKUQHfnvZbXmxBXJAGViSDcA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/base64": "^5.1.0",
|
"@ethersproject/base64": "^5.1.0",
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
@@ -16468,7 +16413,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.1.0.tgz",
|
||||||
"integrity": "sha512-NsUCi/TpBb+oTFvMSccUkJGtp5o/84eOyqp5q5aBeiNBSLkYyw21znRn9mAmxZgySpxgruVgKbaapnYPgvctPQ==",
|
"integrity": "sha512-NsUCi/TpBb+oTFvMSccUkJGtp5o/84eOyqp5q5aBeiNBSLkYyw21znRn9mAmxZgySpxgruVgKbaapnYPgvctPQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/bytes": "^5.1.0",
|
"@ethersproject/bytes": "^5.1.0",
|
||||||
"@ethersproject/hash": "^5.1.0",
|
"@ethersproject/hash": "^5.1.0",
|
||||||
@@ -16704,7 +16648,9 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@typechain/ethers-v5/-/ethers-v5-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typechain/ethers-v5/-/ethers-v5-2.0.0.tgz",
|
||||||
"integrity": "sha512-0xdCkyGOzdqh4h5JSf+zoWx85IusEjDcPIwNEHP8mrWSnCae4rvrqB+/gtpdNfX7zjlFlZiMeePn2r63EI3Lrw==",
|
"integrity": "sha512-0xdCkyGOzdqh4h5JSf+zoWx85IusEjDcPIwNEHP8mrWSnCae4rvrqB+/gtpdNfX7zjlFlZiMeePn2r63EI3Lrw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {}
|
"requires": {
|
||||||
|
"ethers": "^5.0.2"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"@types/abstract-leveldown": {
|
"@types/abstract-leveldown": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
@@ -16754,7 +16700,7 @@
|
|||||||
"integrity": "sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g=="
|
"integrity": "sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g=="
|
||||||
},
|
},
|
||||||
"@types/node-fetch": {
|
"@types/node-fetch": {
|
||||||
"version": "2.5.10",
|
"version": "2.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.10.tgz",
|
||||||
"integrity": "sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==",
|
"integrity": "sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@@ -16868,8 +16814,7 @@
|
|||||||
"aes-js": {
|
"aes-js": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz",
|
||||||
"integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0=",
|
"integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"agent-base": {
|
"agent-base": {
|
||||||
"version": "6.0.2",
|
"version": "6.0.2",
|
||||||
@@ -17056,8 +17001,7 @@
|
|||||||
"bech32": {
|
"bech32": {
|
||||||
"version": "1.1.4",
|
"version": "1.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz",
|
||||||
"integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==",
|
"integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"binary-extensions": {
|
"binary-extensions": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
@@ -17804,7 +17748,6 @@
|
|||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/ethers/-/ethers-5.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/ethers/-/ethers-5.1.0.tgz",
|
||||||
"integrity": "sha512-2L6Ge6wMBw02FlRoCLg4E0Elt3khMNlW6ULawa10mMeeZToYJ5+uCfiuTuB+XZ6om1Y7wuO9ZzezP8FsU2M/+g==",
|
"integrity": "sha512-2L6Ge6wMBw02FlRoCLg4E0Elt3khMNlW6ULawa10mMeeZToYJ5+uCfiuTuB+XZ6om1Y7wuO9ZzezP8FsU2M/+g==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethersproject/abi": "5.1.0",
|
"@ethersproject/abi": "5.1.0",
|
||||||
"@ethersproject/abstract-provider": "5.1.0",
|
"@ethersproject/abstract-provider": "5.1.0",
|
||||||
@@ -18067,7 +18010,7 @@
|
|||||||
"integrity": "sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw=="
|
"integrity": "sha512-4zPxDyhCyiN2wIAtSLI6gc82/EjqZc1onI4Mz/l0pWrAlsSfYH/2ZIcU+e3oA2wDwbzIWNKwa23F8rh6+DRWkw=="
|
||||||
},
|
},
|
||||||
"follow-redirects": {
|
"follow-redirects": {
|
||||||
"version": "1.13.3",
|
"version": "1.14.7",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
|
||||||
"integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA=="
|
"integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA=="
|
||||||
},
|
},
|
||||||
@@ -25307,7 +25250,7 @@
|
|||||||
"merkle-patricia-tree": "^4.1.0",
|
"merkle-patricia-tree": "^4.1.0",
|
||||||
"mnemonist": "^0.38.0",
|
"mnemonist": "^0.38.0",
|
||||||
"mocha": "^7.1.2",
|
"mocha": "^7.1.2",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.7",
|
||||||
"qs": "^6.7.0",
|
"qs": "^6.7.0",
|
||||||
"raw-body": "^2.4.1",
|
"raw-body": "^2.4.1",
|
||||||
"resolve": "1.17.0",
|
"resolve": "1.17.0",
|
||||||
@@ -26211,7 +26154,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "2.6.1",
|
"version": "2.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||||
},
|
},
|
||||||
@@ -26930,7 +26873,7 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"command-exists": "^1.2.8",
|
"command-exists": "^1.2.8",
|
||||||
"commander": "3.0.2",
|
"commander": "3.0.2",
|
||||||
"follow-redirects": "^1.12.1",
|
"follow-redirects": "^1.14.7",
|
||||||
"fs-extra": "^0.30.0",
|
"fs-extra": "^0.30.0",
|
||||||
"js-sha3": "0.8.0",
|
"js-sha3": "0.8.0",
|
||||||
"memorystream": "^0.3.1",
|
"memorystream": "^0.3.1",
|
||||||
@@ -26966,6 +26909,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"solidity-create2-deployer": {
|
||||||
|
"version": "0.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/solidity-create2-deployer/-/solidity-create2-deployer-0.4.0.tgz",
|
||||||
|
"integrity": "sha512-bB5d8fPt4dWsOoRodrsyfWKcjiv77IFl84+e6EckMMGYlfL2ZFqUoMz6tnqqiUFrM9abF1p6dWFOgJ/3zVc8yQ==",
|
||||||
|
"requires": {
|
||||||
|
"ethers": "^5.0.14"
|
||||||
|
}
|
||||||
|
},
|
||||||
"sonic-boom": {
|
"sonic-boom": {
|
||||||
"version": "1.4.1",
|
"version": "1.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-1.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-1.4.1.tgz",
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@openzeppelin/contracts": "^4.0.0",
|
"@openzeppelin/contracts": "^4.0.0",
|
||||||
"fastify": "^3.14.2",
|
"fastify": "^3.14.2",
|
||||||
"hardhat": "^2.2.0"
|
"hardhat": "^2.2.0",
|
||||||
|
"solidity-create2-deployer": "^0.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
const fastify = require('fastify')({ logger: true });
|
const fastify = require('fastify')({ logger: true });
|
||||||
const hre = require("hardhat");
|
const hre = require("hardhat");
|
||||||
|
|
||||||
|
const {
|
||||||
|
deployContract,
|
||||||
|
isDeployed
|
||||||
|
} = require("solidity-create2-deployer");
|
||||||
|
|
||||||
|
const { getStorageSlotKey, deployCreate2Factory } = require('./utils');
|
||||||
|
|
||||||
|
const CREATE2_FACTORY_ADDRESS = '0x4a27c059FD7E383854Ea7DE6Be9c390a795f6eE3'
|
||||||
|
|
||||||
// readiness check
|
// readiness check
|
||||||
fastify.get('/v1/healthz', async (req, reply) => {
|
fastify.get('/v1/healthz', async (req, reply) => {
|
||||||
@@ -63,6 +71,109 @@ fastify.get('/v1/sendEth', async (req, reply) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fastify.get('/v1/deploySLVContract', async (req, reply) => {
|
||||||
|
const SLVToken = await hre.ethers.getContractFactory("SLVToken");
|
||||||
|
const token = await SLVToken.deploy();
|
||||||
|
const receipt = await token.deployTransaction.wait();
|
||||||
|
|
||||||
|
return {
|
||||||
|
address: token.address,
|
||||||
|
txHash: token.deployTransaction.hash,
|
||||||
|
blockNumber: receipt.blockNumber,
|
||||||
|
blockHash: receipt.blockHash,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fastify.get('/v1/destroySLVContract', async (req, reply) => {
|
||||||
|
const addr = req.query.addr;
|
||||||
|
|
||||||
|
const SLVToken = await hre.ethers.getContractFactory("SLVToken");
|
||||||
|
const token = SLVToken.attach(addr);
|
||||||
|
|
||||||
|
const tx = await token.destroy();
|
||||||
|
const receipt = await tx.wait();
|
||||||
|
|
||||||
|
return {
|
||||||
|
blockNumber: receipt.blockNumber,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
fastify.get('/v1/incrementCountA', async (req, reply) => {
|
||||||
|
const addr = req.query.addr;
|
||||||
|
|
||||||
|
const SLVToken = await hre.ethers.getContractFactory("SLVToken");
|
||||||
|
const token = await SLVToken.attach(addr);
|
||||||
|
|
||||||
|
const tx = await token.incrementCountA();
|
||||||
|
const receipt = await tx.wait();
|
||||||
|
|
||||||
|
return {
|
||||||
|
blockNumber: receipt.blockNumber,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fastify.get('/v1/incrementCountB', async (req, reply) => {
|
||||||
|
const addr = req.query.addr;
|
||||||
|
|
||||||
|
const SLVToken = await hre.ethers.getContractFactory("SLVToken");
|
||||||
|
const token = await SLVToken.attach(addr);
|
||||||
|
|
||||||
|
const tx = await token.incrementCountB();
|
||||||
|
const receipt = await tx.wait();
|
||||||
|
|
||||||
|
return {
|
||||||
|
blockNumber: receipt.blockNumber,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fastify.get('/v1/getStorageKey', async (req, reply) => {
|
||||||
|
const contract = req.query.contract;
|
||||||
|
const label = req.query.label;
|
||||||
|
|
||||||
|
const key = await getStorageSlotKey(contract, label)
|
||||||
|
|
||||||
|
return {
|
||||||
|
key
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fastify.get('/v1/create2Contract', async (req, reply) => {
|
||||||
|
const contract = req.query.contract;
|
||||||
|
const salt = req.query.salt;
|
||||||
|
|
||||||
|
const provider = hre.ethers.provider;
|
||||||
|
const signer = await hre.ethers.getSigner();
|
||||||
|
const isFactoryDeployed = await isDeployed(CREATE2_FACTORY_ADDRESS, provider);
|
||||||
|
|
||||||
|
if (!isFactoryDeployed) {
|
||||||
|
await deployCreate2Factory(provider, signer)
|
||||||
|
}
|
||||||
|
|
||||||
|
const contractFactory = await hre.ethers.getContractFactory(contract);
|
||||||
|
const bytecode = contractFactory.bytecode;
|
||||||
|
const constructorTypes = [];
|
||||||
|
const constructorArgs = [];
|
||||||
|
|
||||||
|
const { txHash, address, receipt } = await deployContract({
|
||||||
|
salt,
|
||||||
|
contractBytecode: bytecode,
|
||||||
|
constructorTypes: constructorTypes,
|
||||||
|
constructorArgs: constructorArgs,
|
||||||
|
signer
|
||||||
|
});
|
||||||
|
|
||||||
|
const success = await isDeployed(address, provider);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
return {
|
||||||
|
address,
|
||||||
|
txHash,
|
||||||
|
blockNumber: receipt.blockNumber,
|
||||||
|
blockHash: receipt.blockHash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
await fastify.listen(3000, '0.0.0.0');
|
await fastify.listen(3000, '0.0.0.0');
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
const { artifacts } = require("hardhat")
|
||||||
|
const { utils, BigNumber } = require("ethers")
|
||||||
|
const { deployFactory } = require("solidity-create2-deployer");
|
||||||
|
|
||||||
|
const CREATE2_FACTORY_ACCOUNT = '0x2287Fa6efdEc6d8c3E0f4612ce551dEcf89A357A';
|
||||||
|
|
||||||
|
async function getStorageLayout(contractName) {
|
||||||
|
const artifact = await artifacts.readArtifact(contractName);
|
||||||
|
const buildInfo = await artifacts.getBuildInfo(`${artifact.sourceName}:${artifact.contractName}`);
|
||||||
|
|
||||||
|
if (!buildInfo) {
|
||||||
|
throw new Error('storageLayout not present in compiler output.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = buildInfo.output;
|
||||||
|
const { storageLayout } = output.contracts[artifact.sourceName][artifact.contractName];
|
||||||
|
|
||||||
|
if (!storageLayout) {
|
||||||
|
throw new Error('Contract hasn\'t been compiled.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return storageLayout;
|
||||||
|
};
|
||||||
|
|
||||||
|
async function getStorageSlotKey(contractName, variableName) {
|
||||||
|
storageLayout = await getStorageLayout(contractName)
|
||||||
|
|
||||||
|
const { storage } = storageLayout;
|
||||||
|
const targetState = storage.find((state) => state.label === variableName);
|
||||||
|
|
||||||
|
// Throw if state variable could not be found in storage layout.
|
||||||
|
if (!targetState) {
|
||||||
|
throw new Error('Variable not present in storage layout.');
|
||||||
|
}
|
||||||
|
|
||||||
|
key = utils.hexlify(BigNumber.from(targetState.slot));
|
||||||
|
return key
|
||||||
|
};
|
||||||
|
|
||||||
|
async function deployCreate2Factory(provider, signer) {
|
||||||
|
// Send eth to account as required to deploy create2 factory contract.
|
||||||
|
let tx = {
|
||||||
|
to: CREATE2_FACTORY_ACCOUNT,
|
||||||
|
value: utils.parseEther('0.01')
|
||||||
|
}
|
||||||
|
|
||||||
|
const txResponse = await signer.sendTransaction(tx);
|
||||||
|
await txResponse.wait()
|
||||||
|
|
||||||
|
// Deploy create2 factory contract.
|
||||||
|
await deployFactory(provider)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { getStorageSlotKey, deployCreate2Factory }
|
||||||
@@ -13,8 +13,8 @@ import (
|
|||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
integration "github.com/vulcanize/ipld-eth-server/test"
|
integration "github.com/cerc-io/ipld-eth-server/v4/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Integration test", func() {
|
var _ = Describe("Integration test", func() {
|
||||||
@@ -38,11 +38,14 @@ var _ = Describe("Integration test", func() {
|
|||||||
var txErr error
|
var txErr error
|
||||||
sleepInterval := 2 * time.Second
|
sleepInterval := 2 * time.Second
|
||||||
|
|
||||||
Describe("get Block", func() {
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if !directProxyEthCalls {
|
if !directProxyEthCalls {
|
||||||
Skip("skipping direct-proxy-forwarding integration tests")
|
Skip("skipping direct-proxy-forwarding integration tests")
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
Describe("get Block", func() {
|
||||||
|
BeforeEach(func() {
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -94,9 +97,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("Transaction", func() {
|
Describe("Transaction", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if !directProxyEthCalls {
|
|
||||||
Skip("skipping direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -122,9 +122,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("Receipt", func() {
|
Describe("Receipt", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if !directProxyEthCalls {
|
|
||||||
Skip("skipping direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -142,9 +139,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("FilterLogs", func() {
|
Describe("FilterLogs", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if !directProxyEthCalls {
|
|
||||||
Skip("skipping direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -174,9 +168,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("CodeAt", func() {
|
Describe("CodeAt", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if !directProxyEthCalls {
|
|
||||||
Skip("skipping direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -224,9 +215,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
Describe("Get balance", func() {
|
Describe("Get balance", func() {
|
||||||
address := "0x1111111111111111111111111111111111111112"
|
address := "0x1111111111111111111111111111111111111112"
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if !directProxyEthCalls {
|
|
||||||
Skip("skipping direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
tx, txErr = integration.SendEth(address, "0.01")
|
tx, txErr = integration.SendEth(address, "0.01")
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -286,9 +274,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("Get Storage", func() {
|
Describe("Get Storage", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if !directProxyEthCalls {
|
|
||||||
Skip("skipping direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
erc20TotalSupply, bigIntResult = new(big.Int).SetString("1000000000000000000000", 10)
|
erc20TotalSupply, bigIntResult = new(big.Int).SetString("1000000000000000000000", 10)
|
||||||
|
|
||||||
@@ -392,9 +377,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("eth call", func() {
|
Describe("eth call", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if !directProxyEthCalls {
|
|
||||||
Skip("skipping direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
erc20TotalSupply, bigIntResult = new(big.Int).SetString("1000000000000000000000", 10)
|
erc20TotalSupply, bigIntResult = new(big.Int).SetString("1000000000000000000000", 10)
|
||||||
|
|
||||||
@@ -445,14 +427,11 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("Chain ID", func() {
|
Describe("Chain ID", func() {
|
||||||
It("Check chain id", func() {
|
It("Check chain id", func() {
|
||||||
if !directProxyEthCalls {
|
|
||||||
Skip("skipping direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
_, err := gethClient.ChainID(ctx)
|
_, err := gethClient.ChainID(ctx)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
_, err = ipldClient.ChainID(ctx)
|
_, err = ipldClient.ChainID(ctx)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
+108
@@ -5,6 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"github.com/ethereum/go-ethereum/statediff/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ContractDeployed struct {
|
type ContractDeployed struct {
|
||||||
@@ -27,6 +30,14 @@ type Tx struct {
|
|||||||
BlockHash string `json:"blockHash"`
|
BlockHash string `json:"blockHash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StorageKey struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CountIncremented struct {
|
||||||
|
BlockNumber int64 `json:"blockNumber"`
|
||||||
|
}
|
||||||
|
|
||||||
const srvUrl = "http://localhost:3000"
|
const srvUrl = "http://localhost:3000"
|
||||||
|
|
||||||
func DeployContract() (*ContractDeployed, error) {
|
func DeployContract() (*ContractDeployed, error) {
|
||||||
@@ -77,3 +88,100 @@ func SendEth(to string, value string) (*Tx, error) {
|
|||||||
|
|
||||||
return &tx, nil
|
return &tx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeploySLVContract() (*ContractDeployed, error) {
|
||||||
|
res, err := http.Get(fmt.Sprintf("%s/v1/deploySLVContract", srvUrl))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
var contract ContractDeployed
|
||||||
|
|
||||||
|
decoder := json.NewDecoder(res.Body)
|
||||||
|
err = decoder.Decode(&contract)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &contract, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DestroySLVContract(addr string) (*ContractDestroyed, error) {
|
||||||
|
res, err := http.Get(fmt.Sprintf("%s/v1/destroySLVContract?addr=%s", srvUrl, addr))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
var data ContractDestroyed
|
||||||
|
decoder := json.NewDecoder(res.Body)
|
||||||
|
|
||||||
|
return &data, decoder.Decode(&data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func IncrementCount(addr string, count string) (*CountIncremented, error) {
|
||||||
|
res, err := http.Get(fmt.Sprintf("%s/v1/incrementCount%s?addr=%s", srvUrl, count, addr))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var blockNumber CountIncremented
|
||||||
|
|
||||||
|
decoder := json.NewDecoder(res.Body)
|
||||||
|
err = decoder.Decode(&blockNumber)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &blockNumber, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStorageSlotKey(contract string, label string) (*StorageKey, error) {
|
||||||
|
res, err := http.Get(fmt.Sprintf("%s/v1/getStorageKey?contract=%s&label=%s", srvUrl, contract, label))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
var key StorageKey
|
||||||
|
|
||||||
|
decoder := json.NewDecoder(res.Body)
|
||||||
|
err = decoder.Decode(&key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &key, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ClearWatchedAddresses(gethRPCClient *rpc.Client) error {
|
||||||
|
gethMethod := "statediff_watchAddress"
|
||||||
|
args := []types.WatchAddressArg{}
|
||||||
|
|
||||||
|
// Clear watched addresses
|
||||||
|
gethErr := gethRPCClient.Call(nil, gethMethod, types.Clear, args)
|
||||||
|
if gethErr != nil {
|
||||||
|
return gethErr
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Create2Contract(contractName string, salt string) (*ContractDeployed, error) {
|
||||||
|
res, err := http.Get(fmt.Sprintf("%s/v1/create2Contract?contract=%s&salt=%s", srvUrl, contractName, salt))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
var contract ContractDeployed
|
||||||
|
|
||||||
|
decoder := json.NewDecoder(res.Body)
|
||||||
|
err = decoder.Decode(&contract)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &contract, nil
|
||||||
|
}
|
||||||
|
|||||||
+81
-28
@@ -16,8 +16,8 @@ import (
|
|||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/vulcanize/ipld-eth-server/pkg/eth"
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
||||||
integration "github.com/vulcanize/ipld-eth-server/test"
|
integration "github.com/cerc-io/ipld-eth-server/v4/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
const nonExistingBlockHash = "0x111111111111111111111111111111111111111111111111111111111111111"
|
const nonExistingBlockHash = "0x111111111111111111111111111111111111111111111111111111111111111"
|
||||||
@@ -49,11 +49,14 @@ var _ = Describe("Integration test", func() {
|
|||||||
var txErr error
|
var txErr error
|
||||||
sleepInterval := 2 * time.Second
|
sleepInterval := 2 * time.Second
|
||||||
|
|
||||||
Describe("get Block", func() {
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if directProxyEthCalls {
|
if directProxyEthCalls {
|
||||||
Skip("skipping no-direct-proxy-forwarding integration tests")
|
Skip("skipping no-direct-proxy-forwarding integration tests")
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
Describe("get Block", func() {
|
||||||
|
BeforeEach(func() {
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -123,9 +126,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("Transaction", func() {
|
Describe("Transaction", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if directProxyEthCalls {
|
|
||||||
Skip("skipping no-direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -157,9 +157,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("Receipt", func() {
|
Describe("Receipt", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if directProxyEthCalls {
|
|
||||||
Skip("skipping no-direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -187,9 +184,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("FilterLogs", func() {
|
Describe("FilterLogs", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if directProxyEthCalls {
|
|
||||||
Skip("skipping no-direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -220,9 +214,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("CodeAt", func() {
|
Describe("CodeAt", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if directProxyEthCalls {
|
|
||||||
Skip("skipping no-direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -270,9 +261,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
Describe("Get balance", func() {
|
Describe("Get balance", func() {
|
||||||
address := "0x1111111111111111111111111111111111111112"
|
address := "0x1111111111111111111111111111111111111112"
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if directProxyEthCalls {
|
|
||||||
Skip("skipping no-direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
tx, txErr = integration.SendEth(address, "0.01")
|
tx, txErr = integration.SendEth(address, "0.01")
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@@ -335,10 +323,12 @@ var _ = Describe("Integration test", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Describe("Get Storage", func() {
|
Describe("Get Storage", func() {
|
||||||
|
var slvContract *integration.ContractDeployed
|
||||||
|
var slvCountA *big.Int
|
||||||
|
|
||||||
|
contractSalt := "SLVContractSalt"
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if directProxyEthCalls {
|
|
||||||
Skip("skipping no-direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
erc20TotalSupply, bigIntResult = new(big.Int).SetString("1000000000000000000000", 10)
|
erc20TotalSupply, bigIntResult = new(big.Int).SetString("1000000000000000000000", 10)
|
||||||
|
|
||||||
@@ -418,12 +408,48 @@ var _ = Describe("Integration test", func() {
|
|||||||
Expect(gethStorage).To(Equal(ipldStorage))
|
Expect(gethStorage).To(Equal(ipldStorage))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("get storage for SLV countA after tx", func() {
|
||||||
|
slvContract, contractErr = integration.Create2Contract("SLVToken", contractSalt)
|
||||||
|
Expect(contractErr).ToNot(HaveOccurred())
|
||||||
|
countAIndex := "0x5"
|
||||||
|
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
|
||||||
|
gethStorage, err := gethClient.StorageAt(ctx, common.HexToAddress(slvContract.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
gethCountA := new(big.Int).SetBytes(gethStorage)
|
||||||
|
slvCountA = gethCountA
|
||||||
|
|
||||||
|
ipldStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(slvContract.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
ipldCountA := new(big.Int).SetBytes(ipldStorage)
|
||||||
|
Expect(ipldCountA.String()).To(Equal(slvCountA.String()))
|
||||||
|
|
||||||
|
_, txErr = integration.IncrementCount(slvContract.Address, "A")
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
slvCountA.Add(slvCountA, big.NewInt(1))
|
||||||
|
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
|
||||||
|
ipldStorage, err = ipldClient.StorageAt(ctx, common.HexToAddress(slvContract.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
ipldCountA = new(big.Int).SetBytes(ipldStorage)
|
||||||
|
Expect(ipldCountA.String()).To(Equal(slvCountA.String()))
|
||||||
|
})
|
||||||
|
|
||||||
It("get storage after self destruct", func() {
|
It("get storage after self destruct", func() {
|
||||||
totalSupplyIndex := "0x2"
|
totalSupplyIndex := "0x2"
|
||||||
|
countAIndex := "0x5"
|
||||||
|
|
||||||
tx, err := integration.DestroyContract(contract.Address)
|
tx, err := integration.DestroyContract(contract.Address)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
slvTx, err := integration.DestroyContract(slvContract.Address)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
|
|
||||||
gethStorage1, err := gethClient.StorageAt(ctx, common.HexToAddress(contract.Address), common.HexToHash(totalSupplyIndex), big.NewInt(tx.BlockNumber-1))
|
gethStorage1, err := gethClient.StorageAt(ctx, common.HexToAddress(contract.Address), common.HexToHash(totalSupplyIndex), big.NewInt(tx.BlockNumber-1))
|
||||||
@@ -447,14 +473,44 @@ var _ = Describe("Integration test", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
Expect(ipldStorage2).To(Equal(ipldStorage3))
|
Expect(ipldStorage2).To(Equal(ipldStorage3))
|
||||||
|
|
||||||
|
// Check for SLV contract
|
||||||
|
gethStorage, err := gethClient.StorageAt(ctx, common.HexToAddress(slvContract.Address), common.HexToHash(countAIndex), big.NewInt(slvTx.BlockNumber))
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(gethStorage).To(Equal(eth.EmptyNodeValue))
|
||||||
|
|
||||||
|
ipldStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(slvContract.Address), common.HexToHash(countAIndex), big.NewInt(slvTx.BlockNumber))
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(ipldStorage).To(Equal(gethStorage))
|
||||||
|
|
||||||
|
slvCountA.Set(big.NewInt(0))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("get storage after redeploying", func() {
|
||||||
|
slvContract, contractErr = integration.Create2Contract("SLVToken", contractSalt)
|
||||||
|
Expect(contractErr).ToNot(HaveOccurred())
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
|
||||||
|
countAIndex := "0x5"
|
||||||
|
|
||||||
|
gethStorage, err := gethClient.StorageAt(ctx, common.HexToAddress(slvContract.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
gethCountA := new(big.Int).SetBytes(gethStorage)
|
||||||
|
Expect(gethCountA.String()).To(Equal(slvCountA.String()))
|
||||||
|
|
||||||
|
ipldStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(slvContract.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
ipldCountA := new(big.Int).SetBytes(ipldStorage)
|
||||||
|
Expect(ipldCountA.String()).To(Equal(slvCountA.String()))
|
||||||
|
|
||||||
|
Expect(gethStorage).To(Equal(ipldStorage))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("eth call", func() {
|
Describe("eth call", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if directProxyEthCalls {
|
|
||||||
Skip("skipping no-direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
erc20TotalSupply, bigIntResult = new(big.Int).SetString("1000000000000000000000", 10)
|
erc20TotalSupply, bigIntResult = new(big.Int).SetString("1000000000000000000000", 10)
|
||||||
|
|
||||||
@@ -505,9 +561,6 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("Chain ID", func() {
|
Describe("Chain ID", func() {
|
||||||
It("Check chain id", func() {
|
It("Check chain id", func() {
|
||||||
if directProxyEthCalls {
|
|
||||||
Skip("skipping no-direct-proxy-forwarding integration tests")
|
|
||||||
}
|
|
||||||
gethChainId, err := gethClient.ChainID(ctx)
|
gethChainId, err := gethClient.ChainID(ctx)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
@@ -537,7 +590,7 @@ func compareTxs(tx1 *types.Transaction, tx2 *types.Transaction) {
|
|||||||
Expect(tx1.Hash()).To(Equal(tx2.Hash()))
|
Expect(tx1.Hash()).To(Equal(tx2.Hash()))
|
||||||
Expect(tx1.Size()).To(Equal(tx2.Size()))
|
Expect(tx1.Size()).To(Equal(tx2.Size()))
|
||||||
|
|
||||||
signer := types.NewEIP155Signer(big.NewInt(4))
|
signer := types.NewEIP155Signer(big.NewInt(99))
|
||||||
|
|
||||||
gethSender, err := types.Sender(signer, tx1)
|
gethSender, err := types.Sender(signer, tx1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|||||||
@@ -0,0 +1,670 @@
|
|||||||
|
package integration_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"math/big"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/ethclient"
|
||||||
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
sdtypes "github.com/ethereum/go-ethereum/statediff/types"
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
integration "github.com/cerc-io/ipld-eth-server/v4/test"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
gethMethod = "statediff_watchAddress"
|
||||||
|
ipldMethod = "vdb_watchAddress"
|
||||||
|
|
||||||
|
sleepInterval = 2 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("WatchAddress integration test", func() {
|
||||||
|
dbWrite, err := strconv.ParseBool(os.Getenv("DB_WRITE"))
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
|
gethHttpPath := "http://127.0.0.1:8545"
|
||||||
|
gethRPCClient, err := rpc.Dial(gethHttpPath)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
ipldEthHttpPath := "http://127.0.0.1:8081"
|
||||||
|
ipldClient, err := ethclient.Dial(ipldEthHttpPath)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
ipldRPCClient, err := rpc.Dial(ipldEthHttpPath)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
var (
|
||||||
|
ctx = context.Background()
|
||||||
|
|
||||||
|
txErr error
|
||||||
|
contractErr error
|
||||||
|
incErr error
|
||||||
|
|
||||||
|
contract1 *integration.ContractDeployed
|
||||||
|
contract2 *integration.ContractDeployed
|
||||||
|
contract3 *integration.ContractDeployed
|
||||||
|
|
||||||
|
countAIndex string
|
||||||
|
|
||||||
|
prevBalance1 *big.Int
|
||||||
|
prevBalance2 *big.Int
|
||||||
|
prevBalance3 *big.Int
|
||||||
|
|
||||||
|
actualBalance1 *big.Int
|
||||||
|
actualBalance2 *big.Int
|
||||||
|
actualBalance3 *big.Int
|
||||||
|
|
||||||
|
prevCountA1 *big.Int
|
||||||
|
prevCountA2 *big.Int
|
||||||
|
prevCountA3 *big.Int
|
||||||
|
|
||||||
|
actualCountA1 *big.Int
|
||||||
|
actualCountA2 *big.Int
|
||||||
|
actualCountA3 *big.Int
|
||||||
|
)
|
||||||
|
|
||||||
|
BeforeEach(func() {
|
||||||
|
if !dbWrite {
|
||||||
|
Skip("skipping WatchAddress API integration tests")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
It("test init", func() {
|
||||||
|
// Deploy three contracts
|
||||||
|
contract1, contractErr = integration.DeploySLVContract()
|
||||||
|
Expect(contractErr).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
contract2, contractErr = integration.DeploySLVContract()
|
||||||
|
Expect(contractErr).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
contract3, contractErr = integration.DeploySLVContract()
|
||||||
|
Expect(contractErr).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
// Get the storage slot key
|
||||||
|
storageSlotAKey, err := integration.GetStorageSlotKey("SLVToken", "countA")
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countAIndex = storageSlotAKey.Key
|
||||||
|
|
||||||
|
// Clear out watched addresses
|
||||||
|
err = integration.ClearWatchedAddresses(gethRPCClient)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
// Get initial balances for all the contracts
|
||||||
|
// Contract 1
|
||||||
|
actualBalance1 = big.NewInt(0)
|
||||||
|
initBalance1, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract1.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(initBalance1.String()).To(Equal(actualBalance1.String()))
|
||||||
|
prevBalance1 = big.NewInt(0)
|
||||||
|
|
||||||
|
// Contract 2
|
||||||
|
actualBalance2 = big.NewInt(0)
|
||||||
|
initBalance2, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract2.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(initBalance2.String()).To(Equal(actualBalance2.String()))
|
||||||
|
prevBalance2 = big.NewInt(0)
|
||||||
|
|
||||||
|
// Contract 3
|
||||||
|
actualBalance3 = big.NewInt(0)
|
||||||
|
initBalance3, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract3.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(initBalance3.String()).To(Equal(actualBalance3.String()))
|
||||||
|
prevBalance3 = big.NewInt(0)
|
||||||
|
|
||||||
|
// Get initial storage values for the contracts
|
||||||
|
// Contract 1, countA
|
||||||
|
actualCountA1 = big.NewInt(0)
|
||||||
|
ipldCountA1Storage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract1.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
ipldCountA1 := new(big.Int).SetBytes(ipldCountA1Storage)
|
||||||
|
Expect(ipldCountA1.String()).To(Equal(actualCountA1.String()))
|
||||||
|
prevCountA1 = big.NewInt(0)
|
||||||
|
|
||||||
|
// Contract 2, countA
|
||||||
|
actualCountA2 = big.NewInt(0)
|
||||||
|
ipldCountA2Storage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract2.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
ipldCountA2 := new(big.Int).SetBytes(ipldCountA2Storage)
|
||||||
|
Expect(ipldCountA2.String()).To(Equal(actualCountA2.String()))
|
||||||
|
prevCountA2 = big.NewInt(0)
|
||||||
|
|
||||||
|
// Contract 3, countA
|
||||||
|
actualCountA3 = big.NewInt(0)
|
||||||
|
ipldCountA3Storage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract3.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
ipldCountA3 := new(big.Int).SetBytes(ipldCountA3Storage)
|
||||||
|
Expect(ipldCountA3.String()).To(Equal(actualCountA2.String()))
|
||||||
|
prevCountA3 = big.NewInt(0)
|
||||||
|
})
|
||||||
|
|
||||||
|
defer It("test cleanup", func() {
|
||||||
|
// Clear out watched addresses
|
||||||
|
err := integration.ClearWatchedAddresses(gethRPCClient)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("no contracts being watched", func() {
|
||||||
|
It("indexes state for all the contracts", func() {
|
||||||
|
// WatchedAddresses = []
|
||||||
|
// Send eth to all three contract accounts
|
||||||
|
// Contract 1
|
||||||
|
_, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract1.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance1AfterTransfer.String()).To(Equal(actualBalance1.String()))
|
||||||
|
prevBalance1.Set(actualBalance1)
|
||||||
|
|
||||||
|
// Contract 2
|
||||||
|
_, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract2.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance2AfterTransfer.String()).To(Equal(actualBalance2.String()))
|
||||||
|
prevBalance2.Set(actualBalance2)
|
||||||
|
|
||||||
|
// Contract 3
|
||||||
|
_, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract3.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance3AfterTransfer.String()).To(Equal(actualBalance3.String()))
|
||||||
|
prevBalance3.Set(actualBalance3)
|
||||||
|
|
||||||
|
// Increment counts
|
||||||
|
// Contract 1, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract1.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||||
|
|
||||||
|
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract1.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA1AfterIncrement := new(big.Int).SetBytes(countA1AfterIncrementStorage)
|
||||||
|
Expect(countA1AfterIncrement.String()).To(Equal(actualCountA1.String()))
|
||||||
|
prevCountA1.Set(actualCountA1)
|
||||||
|
|
||||||
|
// Contract 2, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract2.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||||
|
|
||||||
|
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract2.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA2AfterIncrement := new(big.Int).SetBytes(countA2AfterIncrementStorage)
|
||||||
|
Expect(countA2AfterIncrement.String()).To(Equal(actualCountA2.String()))
|
||||||
|
prevCountA2.Set(actualCountA2)
|
||||||
|
|
||||||
|
// Contract 3, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract3.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||||
|
|
||||||
|
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract3.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA3AfterIncrement := new(big.Int).SetBytes(countA3AfterIncrementStorage)
|
||||||
|
Expect(countA3AfterIncrement.String()).To(Equal(actualCountA3.String()))
|
||||||
|
prevCountA3.Set(actualCountA3)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("one contract being watched", func() {
|
||||||
|
It("indexes state only for the watched contract", func() {
|
||||||
|
operation := sdtypes.Add
|
||||||
|
args := []sdtypes.WatchAddressArg{
|
||||||
|
{
|
||||||
|
Address: contract1.Address,
|
||||||
|
CreatedAt: uint64(contract1.BlockNumber),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
ipldErr := ipldRPCClient.Call(nil, ipldMethod, operation, args)
|
||||||
|
Expect(ipldErr).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
// WatchedAddresses = [Contract1]
|
||||||
|
// Send eth to all three contract accounts
|
||||||
|
// Contract 1
|
||||||
|
_, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract1.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance1AfterTransfer.String()).To(Equal(actualBalance1.String()))
|
||||||
|
prevBalance1.Set(actualBalance1)
|
||||||
|
|
||||||
|
// Contract 2
|
||||||
|
_, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract2.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance2AfterTransfer.String()).To(Equal(prevBalance2.String()))
|
||||||
|
|
||||||
|
// Contract 3
|
||||||
|
_, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract3.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance3AfterTransfer.String()).To(Equal(prevBalance3.String()))
|
||||||
|
|
||||||
|
// Increment counts
|
||||||
|
// Contract 1, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract1.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||||
|
|
||||||
|
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract1.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA1AfterIncrement := new(big.Int).SetBytes(countA1AfterIncrementStorage)
|
||||||
|
Expect(countA1AfterIncrement.String()).To(Equal(actualCountA1.String()))
|
||||||
|
prevCountA1.Set(actualCountA1)
|
||||||
|
|
||||||
|
// Contract 2, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract2.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||||
|
|
||||||
|
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract2.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA2AfterIncrement := new(big.Int).SetBytes(countA2AfterIncrementStorage)
|
||||||
|
Expect(countA2AfterIncrement.String()).To(Equal(prevCountA2.String()))
|
||||||
|
|
||||||
|
// Contract 3, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract3.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||||
|
|
||||||
|
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract3.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA3AfterIncrement := new(big.Int).SetBytes(countA3AfterIncrementStorage)
|
||||||
|
Expect(countA3AfterIncrement.String()).To(Equal(prevCountA3.String()))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("contract added to a non-empty watch-list", func() {
|
||||||
|
It("indexes state only for the watched contracts", func() {
|
||||||
|
operation := sdtypes.Add
|
||||||
|
args := []sdtypes.WatchAddressArg{
|
||||||
|
{
|
||||||
|
Address: contract2.Address,
|
||||||
|
CreatedAt: uint64(contract2.BlockNumber),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
ipldErr := ipldRPCClient.Call(nil, ipldMethod, operation, args)
|
||||||
|
Expect(ipldErr).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
// WatchedAddresses = [Contract1, Contract2]
|
||||||
|
// Send eth to all three contract accounts
|
||||||
|
// Contract 1
|
||||||
|
_, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract1.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance1AfterTransfer.String()).To(Equal(actualBalance1.String()))
|
||||||
|
prevBalance1.Set(actualBalance1)
|
||||||
|
|
||||||
|
// Contract 2
|
||||||
|
_, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract2.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance2AfterTransfer.String()).To(Equal(actualBalance2.String()))
|
||||||
|
prevBalance2.Set(actualBalance2)
|
||||||
|
|
||||||
|
// Contract 3
|
||||||
|
_, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract3.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance3AfterTransfer.String()).To(Equal(prevBalance3.String()))
|
||||||
|
|
||||||
|
// Increment counts
|
||||||
|
// Contract 1, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract1.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||||
|
|
||||||
|
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract1.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA1AfterIncrement := new(big.Int).SetBytes(countA1AfterIncrementStorage)
|
||||||
|
Expect(countA1AfterIncrement.String()).To(Equal(actualCountA1.String()))
|
||||||
|
prevCountA1.Set(actualCountA1)
|
||||||
|
|
||||||
|
// Contract 2, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract2.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||||
|
|
||||||
|
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract2.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA2AfterIncrement := new(big.Int).SetBytes(countA2AfterIncrementStorage)
|
||||||
|
Expect(countA2AfterIncrement.String()).To(Equal(actualCountA2.String()))
|
||||||
|
prevCountA2.Set(actualCountA2)
|
||||||
|
|
||||||
|
// Contract 3, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract3.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||||
|
|
||||||
|
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract3.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA3AfterIncrement := new(big.Int).SetBytes(countA3AfterIncrementStorage)
|
||||||
|
Expect(countA3AfterIncrement.String()).To(Equal(prevCountA3.String()))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("contract removed from the watch-list", func() {
|
||||||
|
It("indexes state only for the watched contract", func() {
|
||||||
|
operation := sdtypes.Remove
|
||||||
|
args := []sdtypes.WatchAddressArg{
|
||||||
|
{
|
||||||
|
Address: contract1.Address,
|
||||||
|
CreatedAt: uint64(contract1.BlockNumber),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
ipldErr := ipldRPCClient.Call(nil, ipldMethod, operation, args)
|
||||||
|
Expect(ipldErr).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
// WatchedAddresses = [Contract2]
|
||||||
|
// Send eth to all three contract accounts
|
||||||
|
// Contract 1
|
||||||
|
_, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract1.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance1AfterTransfer.String()).To(Equal(prevBalance1.String()))
|
||||||
|
|
||||||
|
// Contract 2
|
||||||
|
_, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract2.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance2AfterTransfer.String()).To(Equal(actualBalance2.String()))
|
||||||
|
prevBalance2.Set(actualBalance2)
|
||||||
|
|
||||||
|
// Contract 3
|
||||||
|
_, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract3.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance3AfterTransfer.String()).To(Equal(prevBalance3.String()))
|
||||||
|
|
||||||
|
// Increment counts
|
||||||
|
// Contract 1, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract1.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||||
|
|
||||||
|
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract1.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA1AfterIncrement := new(big.Int).SetBytes(countA1AfterIncrementStorage)
|
||||||
|
Expect(countA1AfterIncrement.String()).To(Equal(prevCountA1.String()))
|
||||||
|
|
||||||
|
// Contract 2, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract2.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||||
|
|
||||||
|
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract2.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA2AfterIncrement := new(big.Int).SetBytes(countA2AfterIncrementStorage)
|
||||||
|
Expect(countA2AfterIncrement.String()).To(Equal(actualCountA2.String()))
|
||||||
|
prevCountA2.Set(actualCountA2)
|
||||||
|
|
||||||
|
// Contract 3, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract3.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||||
|
|
||||||
|
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract3.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA3AfterIncrement := new(big.Int).SetBytes(countA3AfterIncrementStorage)
|
||||||
|
Expect(countA3AfterIncrement.String()).To(Equal(prevCountA3.String()))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("list of watched addresses set", func() {
|
||||||
|
It("indexes state only for the watched contracts", func() {
|
||||||
|
operation := sdtypes.Set
|
||||||
|
args := []sdtypes.WatchAddressArg{
|
||||||
|
{
|
||||||
|
Address: contract1.Address,
|
||||||
|
CreatedAt: uint64(contract1.BlockNumber),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Address: contract3.Address,
|
||||||
|
CreatedAt: uint64(contract3.BlockNumber),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
ipldErr := ipldRPCClient.Call(nil, ipldMethod, operation, args)
|
||||||
|
Expect(ipldErr).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
// WatchedAddresses = [Contract1, Contract3]
|
||||||
|
// Send eth to all three contract accounts
|
||||||
|
// Contract 1
|
||||||
|
_, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract1.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance1AfterTransfer.String()).To(Equal(actualBalance1.String()))
|
||||||
|
prevBalance1.Set(actualBalance1)
|
||||||
|
|
||||||
|
// Contract 2
|
||||||
|
_, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract2.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance2AfterTransfer.String()).To(Equal(prevBalance2.String()))
|
||||||
|
|
||||||
|
// Contract 3
|
||||||
|
_, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract3.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance3AfterTransfer.String()).To(Equal(actualBalance3.String()))
|
||||||
|
prevBalance3.Set(actualBalance3)
|
||||||
|
|
||||||
|
// Increment counts
|
||||||
|
// Contract 1, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract1.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||||
|
|
||||||
|
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract1.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA1AfterIncrement := new(big.Int).SetBytes(countA1AfterIncrementStorage)
|
||||||
|
Expect(countA1AfterIncrement.String()).To(Equal(actualCountA1.String()))
|
||||||
|
prevCountA1.Set(actualCountA1)
|
||||||
|
|
||||||
|
// Contract 2, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract2.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||||
|
|
||||||
|
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract2.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA2AfterIncrement := new(big.Int).SetBytes(countA2AfterIncrementStorage)
|
||||||
|
Expect(countA2AfterIncrement.String()).To(Equal(prevCountA2.String()))
|
||||||
|
|
||||||
|
// Contract 3, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract3.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||||
|
|
||||||
|
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract3.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA3AfterIncrement := new(big.Int).SetBytes(countA3AfterIncrementStorage)
|
||||||
|
Expect(countA3AfterIncrement.String()).To(Equal(actualCountA3.String()))
|
||||||
|
prevCountA3.Set(actualCountA3)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("list of watched addresses cleared", func() {
|
||||||
|
It("indexes state for all the contracts", func() {
|
||||||
|
operation := sdtypes.Clear
|
||||||
|
args := []sdtypes.WatchAddressArg{}
|
||||||
|
ipldErr := ipldRPCClient.Call(nil, ipldMethod, operation, args)
|
||||||
|
Expect(ipldErr).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
// WatchedAddresses = []
|
||||||
|
// Send eth to all three contract accounts
|
||||||
|
// Contract 1
|
||||||
|
_, txErr = integration.SendEth(contract1.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance1.Add(actualBalance1, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance1AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract1.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance1AfterTransfer.String()).To(Equal(actualBalance1.String()))
|
||||||
|
prevBalance1.Set(actualBalance1)
|
||||||
|
|
||||||
|
// Contract 2
|
||||||
|
_, txErr = integration.SendEth(contract2.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance2.Add(actualBalance2, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance2AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract2.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance2AfterTransfer.String()).To(Equal(actualBalance2.String()))
|
||||||
|
prevBalance2.Set(actualBalance2)
|
||||||
|
|
||||||
|
// Contract 3
|
||||||
|
_, txErr = integration.SendEth(contract3.Address, "0.01")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(txErr).ToNot(HaveOccurred())
|
||||||
|
actualBalance3.Add(actualBalance3, big.NewInt(10000000000000000))
|
||||||
|
|
||||||
|
balance3AfterTransfer, err := ipldClient.BalanceAt(ctx, common.HexToAddress(contract3.Address), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(balance3AfterTransfer.String()).To(Equal(actualBalance3.String()))
|
||||||
|
prevBalance3.Set(actualBalance3)
|
||||||
|
|
||||||
|
// Increment counts
|
||||||
|
// Contract 1, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract1.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA1.Add(actualCountA1, big.NewInt(1))
|
||||||
|
|
||||||
|
countA1AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract1.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA1AfterIncrement := new(big.Int).SetBytes(countA1AfterIncrementStorage)
|
||||||
|
Expect(countA1AfterIncrement.String()).To(Equal(actualCountA1.String()))
|
||||||
|
prevCountA1.Set(actualCountA1)
|
||||||
|
|
||||||
|
// Contract 2, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract2.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA2.Add(actualCountA2, big.NewInt(1))
|
||||||
|
|
||||||
|
countA2AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract2.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA2AfterIncrement := new(big.Int).SetBytes(countA2AfterIncrementStorage)
|
||||||
|
Expect(countA2AfterIncrement.String()).To(Equal(actualCountA2.String()))
|
||||||
|
prevCountA2.Set(actualCountA2)
|
||||||
|
|
||||||
|
// Contract 3, countA
|
||||||
|
_, incErr = integration.IncrementCount(contract3.Address, "A")
|
||||||
|
time.Sleep(sleepInterval)
|
||||||
|
Expect(incErr).ToNot(HaveOccurred())
|
||||||
|
actualCountA3.Add(actualCountA3, big.NewInt(1))
|
||||||
|
|
||||||
|
countA3AfterIncrementStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract3.Address), common.HexToHash(countAIndex), nil)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
countA3AfterIncrement := new(big.Int).SetBytes(countA3AfterIncrementStorage)
|
||||||
|
Expect(countA3AfterIncrement.String()).To(Equal(actualCountA3.String()))
|
||||||
|
prevCountA3.Set(actualCountA3)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("with invalid args", func() {
|
||||||
|
It("returns an error on invalid operation arg", func() {
|
||||||
|
operation := "WrongOp"
|
||||||
|
args := []sdtypes.WatchAddressArg{}
|
||||||
|
|
||||||
|
gethErr := gethRPCClient.Call(nil, gethMethod, operation, args)
|
||||||
|
Expect(gethErr).To(HaveOccurred())
|
||||||
|
|
||||||
|
ipldErr := ipldRPCClient.Call(nil, ipldMethod, operation, args)
|
||||||
|
Expect(ipldErr).To(HaveOccurred())
|
||||||
|
|
||||||
|
Expect(ipldErr).To(Equal(gethErr))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("returns an error on args of invalid type", func() {
|
||||||
|
operation := sdtypes.Add
|
||||||
|
args := []string{"WrongArg"}
|
||||||
|
|
||||||
|
gethErr := gethRPCClient.Call(nil, gethMethod, operation, args)
|
||||||
|
Expect(gethErr).To(HaveOccurred())
|
||||||
|
|
||||||
|
ipldErr := ipldRPCClient.Call(nil, ipldMethod, operation, args)
|
||||||
|
Expect(ipldErr).To(HaveOccurred())
|
||||||
|
|
||||||
|
Expect(ipldErr).To(Equal(gethErr))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -19,12 +19,12 @@ package test_config
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres"
|
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var DBConfig postgres.ConnectionParams
|
var DBConfig postgres.Config
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setTestConfig()
|
setTestConfig()
|
||||||
@@ -33,7 +33,7 @@ func init() {
|
|||||||
func setTestConfig() {
|
func setTestConfig() {
|
||||||
vip := viper.New()
|
vip := viper.New()
|
||||||
vip.SetConfigName("testing")
|
vip.SetConfigName("testing")
|
||||||
vip.AddConfigPath("$GOPATH/src/github.com/vulcanize/ipld-eth-server/environments/")
|
vip.AddConfigPath("$GOPATH/src/github.com/cerc-io/ipld-eth-server/environments/")
|
||||||
if err := vip.ReadInConfig(); err != nil {
|
if err := vip.ReadInConfig(); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -52,9 +52,9 @@ func setTestConfig() {
|
|||||||
port := vip.GetInt("database.port")
|
port := vip.GetInt("database.port")
|
||||||
name := vip.GetString("database.name")
|
name := vip.GetString("database.name")
|
||||||
|
|
||||||
DBConfig = postgres.ConnectionParams{
|
DBConfig = postgres.Config{
|
||||||
Hostname: hn,
|
Hostname: hn,
|
||||||
Name: name,
|
DatabaseName: name,
|
||||||
Port: port,
|
Port: port,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -19,10 +19,10 @@ package version
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Major = 0 // Major version component of the current release
|
Major = 4 // Major version component of the current release
|
||||||
Minor = 3 // Minor version component of the current release
|
Minor = 1 // Minor version component of the current release
|
||||||
Patch = 9 // Patch version component of the current release
|
Patch = 5 // Patch version component of the current release
|
||||||
Meta = "" // Version metadata to append to the version string
|
Meta = "alpha" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version holds the textual version string.
|
// Version holds the textual version string.
|
||||||
|
|||||||
Reference in New Issue
Block a user