Skip to content

Commit

Permalink
[pallet-revive-eth-rpc] persist eth transaction hash (#6836)
Browse files Browse the repository at this point in the history
Add an option to persist EVM transaction hash to a SQL db.
This should make it possible to run a full archive ETH RPC node
(assuming the substrate node is also a full archive node)

Some queries such as eth_getTransactionByHash,
eth_getBlockTransactionCountByHash, and other need to work with a
transaction hash indexes, which are not stored in Substrate and need to
be stored by the eth-rpc proxy.

The refactoring break down the Client into a `BlockInfoProvider` and
`ReceiptProvider`
- BlockInfoProvider does not need any persistence data, as we can fetch
all block info from the source substrate chain
- ReceiptProvider comes in two flavor, 
  - An in memory cache implementation - This is the one we had so far.
- A DB implementation - This one persist rows with the block_hash, the
transaction_index and the transaction_hash, so that we can later fetch
the block and extrinsic for that receipt and reconstruct the ReceiptInfo
object.

This PR also adds a new binary eth-indexer, that iterate past and new
blocks and write the receipt hashes to the DB using the new
ReceiptProvider.

---------

Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: command-bot <>
  • Loading branch information
pgherveou and actions-user authored Jan 14, 2025
1 parent 105c5b9 commit 023763d
Show file tree
Hide file tree
Showing 33 changed files with 2,090 additions and 472 deletions.
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rustdocflags = [
CC_x86_64_unknown_linux_musl = { value = ".cargo/musl-gcc", force = true, relative = true }
CXX_x86_64_unknown_linux_musl = { value = ".cargo/musl-g++", force = true, relative = true }
CARGO_WORKSPACE_ROOT_DIR = { value = "", relative = true }
SQLX_OFFLINE = "true"

[net]
retry = 5
Expand Down
37 changes: 28 additions & 9 deletions .github/workflows/build-publish-eth-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ concurrency:
cancel-in-progress: true

env:
IMAGE_NAME: "docker.io/paritypr/eth-rpc"
ETH_RPC_IMAGE_NAME: "docker.io/paritypr/eth-rpc"
ETH_INDEXER_IMAGE_NAME: "docker.io/paritypr/eth-indexer"

jobs:
set-variables:
Expand All @@ -34,7 +35,7 @@ jobs:
echo "set VERSION=${VERSION}"
build_docker:
name: Build docker image
name: Build docker images
runs-on: parity-large
needs: [set-variables]
env:
Expand All @@ -43,17 +44,26 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4

- name: Build Docker image
- name: Build eth-rpc Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./substrate/frame/revive/rpc/Dockerfile
file: ./substrate/frame/revive/rpc/dockerfiles/eth-rpc/Dockerfile
push: false
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.ETH_RPC_IMAGE_NAME }}:${{ env.VERSION }}
- name: Build eth-indexer Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./substrate/frame/revive/rpc/dockerfiles/eth-indexer/Dockerfile
push: false
tags: |
${{ env.ETH_INDEXER_IMAGE_NAME }}:${{ env.VERSION }}
build_push_docker:
name: Build and push docker image
name: Build and push docker images
runs-on: parity-large
if: github.ref == 'refs/heads/master'
needs: [set-variables]
Expand All @@ -69,11 +79,20 @@ jobs:
username: ${{ secrets.PARITYPR_DOCKERHUB_USERNAME }}
password: ${{ secrets.PARITYPR_DOCKERHUB_PASSWORD }}

- name: Build Docker image
- name: Build eth-rpc Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./substrate/frame/revive/rpc/dockerfiles/eth-rpc/Dockerfile
push: true
tags: |
${{ env.ETH_RPC_IMAGE_NAME }}:${{ env.VERSION }}
- name: Build eth-indexer Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./substrate/frame/revive/rpc/Dockerfile
file: ./substrate/frame/revive/rpc/dockerfiles/eth-indexer/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.ETH_INDEXER_IMAGE_NAME }}:${{ env.VERSION }}
Loading

0 comments on commit 023763d

Please sign in to comment.