mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Compare commits
39 Commits
nb-2025082
...
491e902904
| Author | SHA1 | Date | |
|---|---|---|---|
| 491e902904 | |||
| 45648a7a98 | |||
| c87c5a055a | |||
| c9416a3948 | |||
| db10c23c56 | |||
| fc395123f3 | |||
| 84ea1af682 | |||
| bd3e0626ed | |||
| 7d223a464e | |||
| afcc551f67 | |||
| 0dfd7a4c7f | |||
| 8faac526b7 | |||
| acfabf969c | |||
| fccf877a3a | |||
| 9e3f0c722e | |||
| cd5bcc4cb0 | |||
| d831a459bb | |||
| 66c2ee654c | |||
| 701e6a25e6 | |||
| ab11ce513f | |||
| 37b852e810 | |||
| 51c43d6dbd | |||
| 3f08b0a4e6 | |||
| d7992ab8ff | |||
| b37a30fb37 | |||
| f6432498d8 | |||
| 772ff250ce | |||
| 5ee9053286 | |||
| 29e6972d58 | |||
| e87b9232cc | |||
| b004263f82 | |||
| 74e27b5ee2 | |||
| 09fcf0751f | |||
| 8f2eca4754 | |||
| 707b4fb709 | |||
| 62dd5a71b5 | |||
| 412c38a8cd | |||
| 796ea518bd | |||
| dd2c925af2 |
127
.github/ISSUE_TEMPLATE/bug.yml
vendored
Normal file
127
.github/ISSUE_TEMPLATE/bug.yml
vendored
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
name: Bug Report
|
||||||
|
description: Create a bug report
|
||||||
|
labels: ["C-bug", "S-needs-triage"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thanks for taking the time to fill out this bug report! Please provide as much detail as possible.
|
||||||
|
|
||||||
|
If you believe you have found a vulnerability, please provide details [here](mailto:georgios@paradigm.xyz) instead.
|
||||||
|
- type: textarea
|
||||||
|
id: what-happened
|
||||||
|
attributes:
|
||||||
|
label: Describe the bug
|
||||||
|
description: |
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
If the bug is in a crate you are using (i.e. you are not running the standard `reth` binary) please mention that as well.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: reproduction-steps
|
||||||
|
attributes:
|
||||||
|
label: Steps to reproduce
|
||||||
|
description: Please provide any steps you think might be relevant to reproduce the bug.
|
||||||
|
placeholder: |
|
||||||
|
Steps to reproduce:
|
||||||
|
|
||||||
|
1. Start '...'
|
||||||
|
2. Then '...'
|
||||||
|
3. Check '...'
|
||||||
|
4. See error
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: logs
|
||||||
|
attributes:
|
||||||
|
label: Node logs
|
||||||
|
description: |
|
||||||
|
If applicable, please provide the node logs leading up to the bug.
|
||||||
|
|
||||||
|
**Please also provide debug logs.** By default, these can be found in:
|
||||||
|
|
||||||
|
- `~/.cache/reth/logs` on Linux
|
||||||
|
- `~/Library/Caches/reth/logs` on macOS
|
||||||
|
- `%localAppData%/reth/logs` on Windows
|
||||||
|
render: text
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: dropdown
|
||||||
|
id: platform
|
||||||
|
attributes:
|
||||||
|
label: Platform(s)
|
||||||
|
description: What platform(s) did this occur on?
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Linux (x86)
|
||||||
|
- Linux (ARM)
|
||||||
|
- Mac (Intel)
|
||||||
|
- Mac (Apple Silicon)
|
||||||
|
- Windows (x86)
|
||||||
|
- Windows (ARM)
|
||||||
|
- type: dropdown
|
||||||
|
id: container_type
|
||||||
|
attributes:
|
||||||
|
label: Container Type
|
||||||
|
description: Were you running it in a container?
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- Not running in a container
|
||||||
|
- Docker
|
||||||
|
- Kubernetes
|
||||||
|
- LXC/LXD
|
||||||
|
- Other
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: client-version
|
||||||
|
attributes:
|
||||||
|
label: What version/commit are you on?
|
||||||
|
description: This can be obtained with `reth --version`
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: database-version
|
||||||
|
attributes:
|
||||||
|
label: What database version are you on?
|
||||||
|
description: This can be obtained with `reth db version`
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: network
|
||||||
|
attributes:
|
||||||
|
label: Which chain / network are you on?
|
||||||
|
description: This is the argument you pass to `reth --chain`. If you are using `--dev`, type in 'dev' here. If you are not running with `--chain` or `--dev` then it is mainnet.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: node-type
|
||||||
|
attributes:
|
||||||
|
label: What type of node are you running?
|
||||||
|
options:
|
||||||
|
- Archive (default)
|
||||||
|
- Full via --full flag
|
||||||
|
- Pruned with custom reth.toml config
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: prune-config
|
||||||
|
attributes:
|
||||||
|
label: What prune config do you use, if any?
|
||||||
|
description: The `[prune]` section in `reth.toml` file
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: If you've built Reth from source, provide the full command you used
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: checkboxes
|
||||||
|
id: terms
|
||||||
|
attributes:
|
||||||
|
label: Code of Conduct
|
||||||
|
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/paradigmxyz/reth/blob/main/CONTRIBUTING.md#code-of-conduct)
|
||||||
|
options:
|
||||||
|
- label: I agree to follow the Code of Conduct
|
||||||
|
required: true
|
||||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: GitHub Discussions
|
||||||
|
url: https://github.com/paradigmxyz/reth/discussions
|
||||||
|
about: Please ask and answer questions here to keep the issue tracker clean.
|
||||||
19
.github/ISSUE_TEMPLATE/docs.yml
vendored
Normal file
19
.github/ISSUE_TEMPLATE/docs.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Documentation
|
||||||
|
description: Suggest a change to our documentation
|
||||||
|
labels: ["C-docs", "S-needs-triage"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
If you are unsure if the docs are relevant or needed, please open up a discussion first.
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Describe the change
|
||||||
|
description: |
|
||||||
|
Please describe the documentation you want to change or add, and if it is for end-users or contributors.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any other context to the feature (like screenshots, resources)
|
||||||
21
.github/ISSUE_TEMPLATE/feature.yml
vendored
Normal file
21
.github/ISSUE_TEMPLATE/feature.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: Feature request
|
||||||
|
description: Suggest a feature
|
||||||
|
labels: ["C-enhancement", "S-needs-triage"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Please ensure that the feature has not already been requested in the issue tracker.
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Describe the feature
|
||||||
|
description: |
|
||||||
|
Please describe the feature and what it is aiming to solve, if relevant.
|
||||||
|
|
||||||
|
If the feature is for a crate, please include a proposed API surface.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any other context to the feature (like screenshots, resources)
|
||||||
38
.github/workflows/docker.yml
vendored
Normal file
38
.github/workflows/docker.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Publishes the Docker image.
|
||||||
|
|
||||||
|
name: docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
- nb-*
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: ${{ github.repository_owner }}/nanoreth
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/nanoreth
|
||||||
|
DOCKER_USERNAME: ${{ github.actor }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: build and push as latest
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- uses: rui314/setup-mold@v1
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
cache-on-failure: true
|
||||||
|
- name: Log in to Docker
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin
|
||||||
|
- name: Set up Docker builder
|
||||||
|
run: |
|
||||||
|
docker buildx create --use --name builder
|
||||||
|
- name: Build and push nanoreth image
|
||||||
|
run: make IMAGE_NAME=$IMAGE_NAME DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME PROFILE=maxperf docker-build-push-latest
|
||||||
781
Cargo.lock
generated
781
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
113
Cargo.toml
113
Cargo.toml
@ -2,6 +2,7 @@
|
|||||||
name = "reth_hl"
|
name = "reth_hl"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "reth_hl"
|
name = "reth_hl"
|
||||||
@ -25,67 +26,73 @@ lto = "fat"
|
|||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
reth = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-cli = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-cli = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-cli-commands = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-cli-commands = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-basic-payload-builder = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-basic-payload-builder = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-db = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-db = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-db-api = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-db-api = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-chainspec = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-chainspec = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-cli-util = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-cli-util = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-discv4 = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-discv4 = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-engine-primitives = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-engine-primitives = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-ethereum-forks = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-ethereum-forks = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-ethereum-payload-builder = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-ethereum-payload-builder = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-ethereum-primitives = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-ethereum-primitives = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-eth-wire = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-eth-wire = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-eth-wire-types = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-eth-wire-types = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-evm = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-evm = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-evm-ethereum = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-evm-ethereum = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-node-core = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-node-core = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-revm = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-revm = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-network = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-network = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-network-p2p = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-network-p2p = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-network-api = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-network-api = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-node-ethereum = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-node-ethereum = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-network-peers = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-network-peers = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-payload-primitives = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-payload-primitives = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-primitives = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-primitives = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-primitives-traits = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-primitives-traits = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-provider = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb", features = ["test-utils"] }
|
reth-provider = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505", features = ["test-utils"] }
|
||||||
reth-rpc = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-rpc = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-rpc-eth-api = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-rpc-eth-api = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-rpc-engine-api = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-rpc-engine-api = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-tracing = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-tracing = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-trie-common = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-trie-common = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-trie-db = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-trie-db = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-codecs = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-codecs = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-transaction-pool = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-transaction-pool = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
reth-stages-types = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
reth-stages-types = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
revm = { version = "28.0.1", default-features = false }
|
reth-storage-api = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
|
reth-errors = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
|
reth-rpc-convert = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
|
reth-rpc-eth-types = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
|
reth-rpc-server-types = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
|
reth-metrics = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||||
|
revm = { version = "29.0.0", default-features = false }
|
||||||
|
|
||||||
# alloy dependencies
|
# alloy dependencies
|
||||||
alloy-genesis = { version = "1.0.23", default-features = false }
|
alloy-genesis = { version = "1.0.30", default-features = false }
|
||||||
alloy-consensus = { version = "1.0.23", default-features = false }
|
alloy-consensus = { version = "1.0.30", default-features = false }
|
||||||
alloy-chains = { version = "0.2.5", default-features = false }
|
alloy-chains = { version = "0.2.5", default-features = false }
|
||||||
alloy-eips = { version = "1.0.23", default-features = false }
|
alloy-eips = { version = "1.0.30", default-features = false }
|
||||||
alloy-evm = { version = "0.18.2", default-features = false }
|
alloy-evm = { version = "0.20.1", default-features = false }
|
||||||
alloy-json-abi = { version = "1.3.1", default-features = false }
|
alloy-json-abi = { version = "1.3.1", default-features = false }
|
||||||
alloy-json-rpc = { version = "1.0.23", default-features = false }
|
alloy-json-rpc = { version = "1.0.30", default-features = false }
|
||||||
alloy-dyn-abi = "1.3.1"
|
alloy-dyn-abi = "1.3.1"
|
||||||
alloy-network = { version = "1.0.23", default-features = false }
|
alloy-network = { version = "1.0.30", default-features = false }
|
||||||
alloy-primitives = { version = "1.3.1", default-features = false, features = ["map-foldhash"] }
|
alloy-primitives = { version = "1.3.1", default-features = false, features = ["map-foldhash"] }
|
||||||
alloy-rlp = { version = "0.3.10", default-features = false, features = ["core-net"] }
|
alloy-rlp = { version = "0.3.10", default-features = false, features = ["core-net"] }
|
||||||
alloy-rpc-types = { version = "1.0.23", features = ["eth"], default-features = false }
|
alloy-rpc-types = { version = "1.0.30", features = ["eth"], default-features = false }
|
||||||
alloy-rpc-types-eth = { version = "1.0.23", default-features = false }
|
alloy-rpc-types-eth = { version = "1.0.30", default-features = false }
|
||||||
alloy-rpc-types-engine = { version = "1.0.23", default-features = false }
|
alloy-rpc-types-engine = { version = "1.0.30", default-features = false }
|
||||||
alloy-signer = { version = "1.0.23", default-features = false }
|
alloy-signer = { version = "1.0.30", default-features = false }
|
||||||
alloy-sol-macro = "1.3.1"
|
alloy-sol-macro = "1.3.1"
|
||||||
alloy-sol-types = { version = "1.3.1", default-features = false }
|
alloy-sol-types = { version = "1.3.1", default-features = false }
|
||||||
|
|
||||||
jsonrpsee = "0.25.1"
|
jsonrpsee = "0.26.0"
|
||||||
jsonrpsee-core = "0.25.1"
|
jsonrpsee-core = "0.26.0"
|
||||||
jsonrpsee-types = "0.25.1"
|
jsonrpsee-types = "0.26.0"
|
||||||
|
|
||||||
# misc dependencies
|
# misc dependencies
|
||||||
auto_impl = "1"
|
auto_impl = "1"
|
||||||
@ -166,3 +173,7 @@ client = [
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3.20.0"
|
tempfile = "3.20.0"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
vergen = { version = "9.0.4", features = ["build", "cargo", "emit_and_set"] }
|
||||||
|
vergen-git2 = "1.0.5"
|
||||||
51
Makefile
51
Makefile
@ -1,6 +1,8 @@
|
|||||||
# Modifed from reth Makefile
|
# Modifed from reth Makefile
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
|
GIT_SHA ?= $(shell git rev-parse HEAD)
|
||||||
|
GIT_TAG ?= $(shell git describe --tags --abbrev=0 2>/dev/null)
|
||||||
BIN_DIR = "dist/bin"
|
BIN_DIR = "dist/bin"
|
||||||
|
|
||||||
# List of features to use when building. Can be overridden via the environment.
|
# List of features to use when building. Can be overridden via the environment.
|
||||||
@ -17,6 +19,9 @@ PROFILE ?= release
|
|||||||
# Extra flags for Cargo
|
# Extra flags for Cargo
|
||||||
CARGO_INSTALL_EXTRA_FLAGS ?=
|
CARGO_INSTALL_EXTRA_FLAGS ?=
|
||||||
|
|
||||||
|
# The docker image name
|
||||||
|
DOCKER_IMAGE_NAME ?= ghcr.io/hl-archive-node/nanoreth
|
||||||
|
|
||||||
##@ Help
|
##@ Help
|
||||||
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
@ -207,3 +212,49 @@ check-features:
|
|||||||
--package reth-primitives-traits \
|
--package reth-primitives-traits \
|
||||||
--package reth-primitives \
|
--package reth-primitives \
|
||||||
--feature-powerset
|
--feature-powerset
|
||||||
|
|
||||||
|
##@ Docker
|
||||||
|
|
||||||
|
# Note: This requires a buildx builder with emulation support. For example:
|
||||||
|
#
|
||||||
|
# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64`
|
||||||
|
# `docker buildx create --use --driver docker-container --name cross-builder`
|
||||||
|
.PHONY: docker-build-push
|
||||||
|
docker-build-push: ## Build and push a cross-arch Docker image tagged with the latest git tag.
|
||||||
|
$(call docker_build_push,$(GIT_TAG),$(GIT_TAG))
|
||||||
|
|
||||||
|
# Note: This requires a buildx builder with emulation support. For example:
|
||||||
|
#
|
||||||
|
# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64`
|
||||||
|
# `docker buildx create --use --driver docker-container --name cross-builder`
|
||||||
|
.PHONY: docker-build-push-git-sha
|
||||||
|
docker-build-push-git-sha: ## Build and push a cross-arch Docker image tagged with the latest git sha.
|
||||||
|
$(call docker_build_push,$(GIT_SHA),$(GIT_SHA))
|
||||||
|
|
||||||
|
# Note: This requires a buildx builder with emulation support. For example:
|
||||||
|
#
|
||||||
|
# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64`
|
||||||
|
# `docker buildx create --use --driver docker-container --name cross-builder`
|
||||||
|
.PHONY: docker-build-push-latest
|
||||||
|
docker-build-push-latest: ## Build and push a cross-arch Docker image tagged with the latest git tag and `latest`.
|
||||||
|
$(call docker_build_push,$(GIT_TAG),latest)
|
||||||
|
|
||||||
|
# Note: This requires a buildx builder with emulation support. For example:
|
||||||
|
#
|
||||||
|
# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64`
|
||||||
|
# `docker buildx create --use --name cross-builder`
|
||||||
|
.PHONY: docker-build-push-nightly
|
||||||
|
docker-build-push-nightly: ## Build and push cross-arch Docker image tagged with the latest git tag with a `-nightly` suffix, and `latest-nightly`.
|
||||||
|
$(call docker_build_push,nightly,nightly)
|
||||||
|
|
||||||
|
# Create a Docker image using the main Dockerfile
|
||||||
|
define docker_build_push
|
||||||
|
docker buildx build --file ./Dockerfile . \
|
||||||
|
--platform linux/amd64 \
|
||||||
|
--tag $(DOCKER_IMAGE_NAME):$(1) \
|
||||||
|
--tag $(DOCKER_IMAGE_NAME):$(2) \
|
||||||
|
--build-arg BUILD_PROFILE="$(PROFILE)" \
|
||||||
|
--build-arg FEATURES="jemalloc,asm-keccak" \
|
||||||
|
--provenance=false \
|
||||||
|
--push
|
||||||
|
endef
|
||||||
|
|||||||
12
README.md
12
README.md
@ -3,6 +3,8 @@
|
|||||||
HyperEVM archive node implementation based on [reth](https://github.com/paradigmxyz/reth).
|
HyperEVM archive node implementation based on [reth](https://github.com/paradigmxyz/reth).
|
||||||
NodeBuilder API version is heavily inspired by [reth-bsc](https://github.com/loocapro/reth-bsc).
|
NodeBuilder API version is heavily inspired by [reth-bsc](https://github.com/loocapro/reth-bsc).
|
||||||
|
|
||||||
|
Got questions? Drop by the [Hyperliquid Discord](https://discord.gg/hyperliquid) #node-operators channel.
|
||||||
|
|
||||||
## ⚠️ IMPORTANT: System Transactions Appear as Pseudo Transactions
|
## ⚠️ IMPORTANT: System Transactions Appear as Pseudo Transactions
|
||||||
|
|
||||||
Deposit transactions from [System Addresses](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/hypercore-less-than-greater-than-hyperevm-transfers#system-addresses) like `0x222..22` / `0x200..xx` to user addresses are intentionally recorded as pseudo transactions.
|
Deposit transactions from [System Addresses](https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/hypercore-less-than-greater-than-hyperevm-transfers#system-addresses) like `0x222..22` / `0x200..xx` to user addresses are intentionally recorded as pseudo transactions.
|
||||||
@ -58,19 +60,19 @@ $ reth-hl node --http --http.addr 0.0.0.0 --http.api eth,ots,net,web3 \
|
|||||||
|
|
||||||
## How to run (testnet)
|
## How to run (testnet)
|
||||||
|
|
||||||
Testnet is supported since block 21304281.
|
Testnet is supported since block 30281484.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Get testnet genesis at block 21304281
|
# Get testnet genesis at block 30281484
|
||||||
$ cd ~
|
$ cd ~
|
||||||
$ git clone https://github.com/sprites0/hl-testnet-genesis
|
$ git clone https://github.com/sprites0/hl-testnet-genesis
|
||||||
$ zstd --rm -d ~/hl-testnet-genesis/*.zst
|
$ zstd --rm -d ~/hl-testnet-genesis/*.zst
|
||||||
|
|
||||||
# Init node
|
# Init node
|
||||||
$ make install
|
$ make install
|
||||||
$ reth-hl init-state --without-evm --chain testnet --header ~/hl-testnet-genesis/21304281.rlp \
|
$ reth-hl init-state --without-evm --chain testnet --header ~/hl-testnet-genesis/30281484.rlp \
|
||||||
--header-hash 0x5b10856d2b1ad241c9bd6136bcc60ef7e8553560ca53995a590db65f809269b4 \
|
--header-hash 0x147cc3c09e9ddbb11799c826758db284f77099478ab5f528d3a57a6105516c21 \
|
||||||
~/hl-testnet-genesis/21304281.jsonl --total-difficulty 0
|
~/hl-testnet-genesis/30281484.jsonl --total-difficulty 0
|
||||||
|
|
||||||
# Run node
|
# Run node
|
||||||
$ reth-hl node --chain testnet --http --http.addr 0.0.0.0 --http.api eth,ots,net,web3 \
|
$ reth-hl node --chain testnet --http --http.addr 0.0.0.0 --http.api eth,ots,net,web3 \
|
||||||
|
|||||||
91
build.rs
Normal file
91
build.rs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
use std::{env, error::Error};
|
||||||
|
use vergen::{BuildBuilder, CargoBuilder, Emitter};
|
||||||
|
use vergen_git2::Git2Builder;
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
let mut emitter = Emitter::default();
|
||||||
|
|
||||||
|
let build_builder = BuildBuilder::default().build_timestamp(true).build()?;
|
||||||
|
|
||||||
|
emitter.add_instructions(&build_builder)?;
|
||||||
|
|
||||||
|
let cargo_builder = CargoBuilder::default().features(true).target_triple(true).build()?;
|
||||||
|
|
||||||
|
emitter.add_instructions(&cargo_builder)?;
|
||||||
|
|
||||||
|
let git_builder =
|
||||||
|
Git2Builder::default().describe(false, true, None).dirty(true).sha(false).build()?;
|
||||||
|
|
||||||
|
emitter.add_instructions(&git_builder)?;
|
||||||
|
|
||||||
|
emitter.emit_and_set()?;
|
||||||
|
let sha = env::var("VERGEN_GIT_SHA")?;
|
||||||
|
let sha_short = &sha[0..7];
|
||||||
|
|
||||||
|
let is_dirty = env::var("VERGEN_GIT_DIRTY")? == "true";
|
||||||
|
// > git describe --always --tags
|
||||||
|
// if not on a tag: v0.2.0-beta.3-82-g1939939b
|
||||||
|
// if on a tag: v0.2.0-beta.3
|
||||||
|
let not_on_tag = env::var("VERGEN_GIT_DESCRIBE")?.ends_with(&format!("-g{sha_short}"));
|
||||||
|
let version_suffix = if is_dirty || not_on_tag { "-dev" } else { "" };
|
||||||
|
println!("cargo:rustc-env=RETH_HL_VERSION_SUFFIX={version_suffix}");
|
||||||
|
|
||||||
|
// Set short SHA
|
||||||
|
println!("cargo:rustc-env=VERGEN_GIT_SHA_SHORT={}", &sha[..8]);
|
||||||
|
|
||||||
|
// Set the build profile
|
||||||
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
|
let profile = out_dir.rsplit(std::path::MAIN_SEPARATOR).nth(3).unwrap();
|
||||||
|
println!("cargo:rustc-env=RETH_HL_BUILD_PROFILE={profile}");
|
||||||
|
|
||||||
|
// Set formatted version strings
|
||||||
|
let pkg_version = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
|
// The short version information for reth.
|
||||||
|
// - The latest version from Cargo.toml
|
||||||
|
// - The short SHA of the latest commit.
|
||||||
|
// Example: 0.1.0 (defa64b2)
|
||||||
|
println!("cargo:rustc-env=RETH_HL_SHORT_VERSION={pkg_version}{version_suffix} ({sha_short})");
|
||||||
|
|
||||||
|
// LONG_VERSION
|
||||||
|
// The long version information for reth.
|
||||||
|
//
|
||||||
|
// - The latest version from Cargo.toml + version suffix (if any)
|
||||||
|
// - The full SHA of the latest commit
|
||||||
|
// - The build datetime
|
||||||
|
// - The build features
|
||||||
|
// - The build profile
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// ```text
|
||||||
|
// Version: 0.1.0
|
||||||
|
// Commit SHA: defa64b2
|
||||||
|
// Build Timestamp: 2023-05-19T01:47:19.815651705Z
|
||||||
|
// Build Features: jemalloc
|
||||||
|
// Build Profile: maxperf
|
||||||
|
// ```
|
||||||
|
println!("cargo:rustc-env=RETH_HL_LONG_VERSION_0=Version: {pkg_version}{version_suffix}");
|
||||||
|
println!("cargo:rustc-env=RETH_HL_LONG_VERSION_1=Commit SHA: {sha}");
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-env=RETH_HL_LONG_VERSION_2=Build Timestamp: {}",
|
||||||
|
env::var("VERGEN_BUILD_TIMESTAMP")?
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-env=RETH_HL_LONG_VERSION_3=Build Features: {}",
|
||||||
|
env::var("VERGEN_CARGO_FEATURES")?
|
||||||
|
);
|
||||||
|
println!("cargo:rustc-env=RETH_HL_LONG_VERSION_4=Build Profile: {profile}");
|
||||||
|
|
||||||
|
// The version information for reth formatted for P2P (devp2p).
|
||||||
|
// - The latest version from Cargo.toml
|
||||||
|
// - The target triple
|
||||||
|
//
|
||||||
|
// Example: reth/v0.1.0-alpha.1-428a6dc2f/aarch64-apple-darwin
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-env=RETH_HL_P2P_CLIENT_VERSION={}",
|
||||||
|
format_args!("reth/v{pkg_version}-{sha_short}/{}", env::var("VERGEN_CARGO_TARGET_TRIPLE")?)
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@ -7,17 +7,18 @@
|
|||||||
//! For non-system transactions, we can just return the log as is, and the client will
|
//! For non-system transactions, we can just return the log as is, and the client will
|
||||||
//! adjust the transaction index accordingly.
|
//! adjust the transaction index accordingly.
|
||||||
|
|
||||||
use alloy_consensus::{transaction::TransactionMeta, TxReceipt};
|
use alloy_consensus::{transaction::TransactionMeta, BlockHeader, TxReceipt};
|
||||||
use alloy_eips::{BlockId, BlockNumberOrTag};
|
use alloy_eips::{BlockId, BlockNumberOrTag};
|
||||||
use alloy_json_rpc::RpcObject;
|
use alloy_json_rpc::RpcObject;
|
||||||
use alloy_primitives::{B256, U256};
|
use alloy_primitives::{B256, U256};
|
||||||
use alloy_rpc_types::{
|
use alloy_rpc_types::{
|
||||||
pubsub::{Params, SubscriptionKind},
|
pubsub::{Params, SubscriptionKind},
|
||||||
BlockTransactions, Filter, FilterChanges, FilterId, Log, PendingTransactionFilterKind,
|
BlockTransactions, Filter, FilterChanges, FilterId, Log, PendingTransactionFilterKind,
|
||||||
|
TransactionInfo,
|
||||||
};
|
};
|
||||||
use jsonrpsee::{proc_macros::rpc, PendingSubscriptionSink, SubscriptionMessage, SubscriptionSink};
|
use jsonrpsee::{proc_macros::rpc, PendingSubscriptionSink, SubscriptionMessage, SubscriptionSink};
|
||||||
use jsonrpsee_core::{async_trait, RpcResult};
|
use jsonrpsee_core::{async_trait, RpcResult};
|
||||||
use jsonrpsee_types::ErrorObject;
|
use jsonrpsee_types::{error::INTERNAL_ERROR_CODE, ErrorObject};
|
||||||
use reth::{api::FullNodeComponents, builder::rpc::RpcContext, tasks::TaskSpawner};
|
use reth::{api::FullNodeComponents, builder::rpc::RpcContext, tasks::TaskSpawner};
|
||||||
use reth_primitives_traits::{BlockBody as _, SignedTransaction};
|
use reth_primitives_traits::{BlockBody as _, SignedTransaction};
|
||||||
use reth_provider::{BlockIdReader, BlockReader, BlockReaderIdExt, ReceiptProvider};
|
use reth_provider::{BlockIdReader, BlockReader, BlockReaderIdExt, ReceiptProvider};
|
||||||
@ -71,6 +72,217 @@ impl<T> EthWrapper for T where
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rpc(server, namespace = "eth")]
|
||||||
|
#[async_trait]
|
||||||
|
pub trait EthSystemTransactionApi<T: RpcObject, R: RpcObject> {
|
||||||
|
#[method(name = "getEvmSystemTxsByBlockHash")]
|
||||||
|
async fn get_evm_system_txs_by_block_hash(&self, hash: B256) -> RpcResult<Option<Vec<T>>>;
|
||||||
|
|
||||||
|
#[method(name = "getEvmSystemTxsByBlockNumber")]
|
||||||
|
async fn get_evm_system_txs_by_block_number(
|
||||||
|
&self,
|
||||||
|
block_id: Option<BlockId>,
|
||||||
|
) -> RpcResult<Option<Vec<T>>>;
|
||||||
|
|
||||||
|
#[method(name = "getEvmSystemTxsReceiptsByBlockHash")]
|
||||||
|
async fn get_evm_system_txs_receipts_by_block_hash(
|
||||||
|
&self,
|
||||||
|
hash: B256,
|
||||||
|
) -> RpcResult<Option<Vec<R>>>;
|
||||||
|
|
||||||
|
#[method(name = "getEvmSystemTxsReceiptsByBlockNumber")]
|
||||||
|
async fn get_evm_system_txs_receipts_by_block_number(
|
||||||
|
&self,
|
||||||
|
block_id: Option<BlockId>,
|
||||||
|
) -> RpcResult<Option<Vec<R>>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct HlSystemTransactionExt<Eth: EthWrapper> {
|
||||||
|
eth_api: Eth,
|
||||||
|
_marker: PhantomData<Eth>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Eth: EthWrapper> HlSystemTransactionExt<Eth> {
|
||||||
|
pub fn new(eth_api: Eth) -> Self {
|
||||||
|
Self { eth_api, _marker: PhantomData }
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_system_txs_by_block_id(
|
||||||
|
&self,
|
||||||
|
block_id: BlockId,
|
||||||
|
) -> RpcResult<Option<Vec<RpcTransaction<Eth::NetworkTypes>>>>
|
||||||
|
where
|
||||||
|
jsonrpsee_types::ErrorObject<'static>: From<<Eth as EthApiTypes>::Error>,
|
||||||
|
{
|
||||||
|
if let Some(block) = self.eth_api.recovered_block(block_id).await? {
|
||||||
|
let block_hash = block.hash();
|
||||||
|
let block_number = block.number();
|
||||||
|
let base_fee_per_gas = block.base_fee_per_gas();
|
||||||
|
let system_txs = block
|
||||||
|
.transactions_with_sender()
|
||||||
|
.enumerate()
|
||||||
|
.filter_map(|(index, (signer, tx))| {
|
||||||
|
if tx.is_system_transaction() {
|
||||||
|
let tx_info = TransactionInfo {
|
||||||
|
hash: Some(*tx.tx_hash()),
|
||||||
|
block_hash: Some(block_hash),
|
||||||
|
block_number: Some(block_number),
|
||||||
|
base_fee: base_fee_per_gas,
|
||||||
|
index: Some(index as u64),
|
||||||
|
};
|
||||||
|
self.eth_api
|
||||||
|
.tx_resp_builder()
|
||||||
|
.fill(tx.clone().with_signer(*signer), tx_info)
|
||||||
|
.ok()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
Ok(Some(system_txs))
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_system_txs_receipts_by_block_id(
|
||||||
|
&self,
|
||||||
|
block_id: BlockId,
|
||||||
|
) -> RpcResult<Option<Vec<RpcReceipt<Eth::NetworkTypes>>>>
|
||||||
|
where
|
||||||
|
jsonrpsee_types::ErrorObject<'static>: From<<Eth as EthApiTypes>::Error>,
|
||||||
|
{
|
||||||
|
if let Some((block, receipts)) =
|
||||||
|
EthBlocks::load_block_and_receipts(&self.eth_api, block_id).await?
|
||||||
|
{
|
||||||
|
let block_number = block.number;
|
||||||
|
let base_fee = block.base_fee_per_gas;
|
||||||
|
let block_hash = block.hash();
|
||||||
|
let excess_blob_gas = block.excess_blob_gas;
|
||||||
|
let timestamp = block.timestamp;
|
||||||
|
let mut gas_used = 0;
|
||||||
|
let mut next_log_index = 0;
|
||||||
|
|
||||||
|
let mut inputs = Vec::new();
|
||||||
|
for (idx, (tx, receipt)) in
|
||||||
|
block.transactions_recovered().zip(receipts.iter()).enumerate()
|
||||||
|
{
|
||||||
|
if receipt.cumulative_gas_used() != 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let meta = TransactionMeta {
|
||||||
|
tx_hash: *tx.tx_hash(),
|
||||||
|
index: idx as u64,
|
||||||
|
block_hash,
|
||||||
|
block_number,
|
||||||
|
base_fee,
|
||||||
|
excess_blob_gas,
|
||||||
|
timestamp,
|
||||||
|
};
|
||||||
|
|
||||||
|
let input = ConvertReceiptInput {
|
||||||
|
receipt: Cow::Borrowed(receipt),
|
||||||
|
tx,
|
||||||
|
gas_used: receipt.cumulative_gas_used() - gas_used,
|
||||||
|
next_log_index,
|
||||||
|
meta,
|
||||||
|
};
|
||||||
|
|
||||||
|
gas_used = receipt.cumulative_gas_used();
|
||||||
|
next_log_index += receipt.logs().len();
|
||||||
|
|
||||||
|
inputs.push(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
let receipts = self.eth_api.tx_resp_builder().convert_receipts(inputs)?;
|
||||||
|
Ok(Some(receipts))
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl<Eth: EthWrapper>
|
||||||
|
EthSystemTransactionApiServer<RpcTransaction<Eth::NetworkTypes>, RpcReceipt<Eth::NetworkTypes>>
|
||||||
|
for HlSystemTransactionExt<Eth>
|
||||||
|
where
|
||||||
|
jsonrpsee_types::ErrorObject<'static>: From<<Eth as EthApiTypes>::Error>,
|
||||||
|
{
|
||||||
|
/// Returns the system transactions for a given block hash.
|
||||||
|
/// Semi-compliance with the `eth_getSystemTxsByBlockHash` RPC method introduced by hl-node.
|
||||||
|
/// https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/json-rpc
|
||||||
|
///
|
||||||
|
/// NOTE: Method name differs from hl-node because we retrieve transaction data from EVM
|
||||||
|
/// (signature recovery for 'from' address, EVM hash calculation) rather than HyperCore.
|
||||||
|
async fn get_evm_system_txs_by_block_hash(
|
||||||
|
&self,
|
||||||
|
hash: B256,
|
||||||
|
) -> RpcResult<Option<Vec<RpcTransaction<Eth::NetworkTypes>>>> {
|
||||||
|
trace!(target: "rpc::eth", ?hash, "Serving eth_getEvmSystemTxsByBlockHash");
|
||||||
|
match self.get_system_txs_by_block_id(BlockId::Hash(hash.into())).await {
|
||||||
|
Ok(txs) => Ok(txs),
|
||||||
|
// hl-node returns none if the block is not found
|
||||||
|
Err(_) => Ok(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the system transactions for a given block number, or the latest block if no block
|
||||||
|
/// number is provided. Semi-compliance with the `eth_getSystemTxsByBlockNumber` RPC method
|
||||||
|
/// introduced by hl-node. https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/json-rpc
|
||||||
|
///
|
||||||
|
/// NOTE: Method name differs from hl-node because we retrieve transaction data from EVM
|
||||||
|
/// (signature recovery for 'from' address, EVM hash calculation) rather than HyperCore.
|
||||||
|
async fn get_evm_system_txs_by_block_number(
|
||||||
|
&self,
|
||||||
|
id: Option<BlockId>,
|
||||||
|
) -> RpcResult<Option<Vec<RpcTransaction<Eth::NetworkTypes>>>> {
|
||||||
|
trace!(target: "rpc::eth", ?id, "Serving eth_getEvmSystemTxsByBlockNumber");
|
||||||
|
match self.get_system_txs_by_block_id(id.unwrap_or_default()).await? {
|
||||||
|
Some(txs) => Ok(Some(txs)),
|
||||||
|
None => {
|
||||||
|
// hl-node returns an error if the block is not found
|
||||||
|
Err(ErrorObject::owned(
|
||||||
|
INTERNAL_ERROR_CODE,
|
||||||
|
format!("invalid block height: {id:?}"),
|
||||||
|
Some(()),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the receipts for the system transactions for a given block hash.
|
||||||
|
async fn get_evm_system_txs_receipts_by_block_hash(
|
||||||
|
&self,
|
||||||
|
hash: B256,
|
||||||
|
) -> RpcResult<Option<Vec<RpcReceipt<Eth::NetworkTypes>>>> {
|
||||||
|
trace!(target: "rpc::eth", ?hash, "Serving eth_getEvmSystemTxsReceiptsByBlockHash");
|
||||||
|
match self.get_system_txs_receipts_by_block_id(BlockId::Hash(hash.into())).await {
|
||||||
|
Ok(receipts) => Ok(receipts),
|
||||||
|
// hl-node returns none if the block is not found
|
||||||
|
Err(_) => Ok(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the receipts for the system transactions for a given block number, or the latest
|
||||||
|
/// block if no block
|
||||||
|
async fn get_evm_system_txs_receipts_by_block_number(
|
||||||
|
&self,
|
||||||
|
block_id: Option<BlockId>,
|
||||||
|
) -> RpcResult<Option<Vec<RpcReceipt<Eth::NetworkTypes>>>> {
|
||||||
|
trace!(target: "rpc::eth", ?block_id, "Serving eth_getEvmSystemTxsReceiptsByBlockNumber");
|
||||||
|
match self.get_system_txs_receipts_by_block_id(block_id.unwrap_or_default()).await? {
|
||||||
|
Some(receipts) => Ok(Some(receipts)),
|
||||||
|
None => Err(ErrorObject::owned(
|
||||||
|
INTERNAL_ERROR_CODE,
|
||||||
|
format!("invalid block height: {block_id:?}"),
|
||||||
|
Some(()),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct HlNodeFilterHttp<Eth: EthWrapper> {
|
pub struct HlNodeFilterHttp<Eth: EthWrapper> {
|
||||||
filter: Arc<EthFilter<Eth>>,
|
filter: Arc<EthFilter<Eth>>,
|
||||||
provider: Arc<Eth::Provider>,
|
provider: Arc<Eth::Provider>,
|
||||||
@ -146,8 +358,9 @@ impl<Eth: EthWrapper> HlNodeFilterWs<Eth> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<Eth: EthWrapper> EthPubSubApiServer<RpcTransaction<Eth::NetworkTypes>>
|
impl<Eth: EthWrapper> EthPubSubApiServer<RpcTransaction<Eth::NetworkTypes>> for HlNodeFilterWs<Eth>
|
||||||
for HlNodeFilterWs<Eth>
|
where
|
||||||
|
jsonrpsee_types::error::ErrorObject<'static>: From<<Eth as EthApiTypes>::Error>,
|
||||||
{
|
{
|
||||||
async fn subscribe(
|
async fn subscribe(
|
||||||
&self,
|
&self,
|
||||||
@ -446,7 +659,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn install_hl_node_compliance<Node, EthApi>(
|
pub fn install_hl_node_compliance<Node, EthApi>(
|
||||||
ctx: RpcContext<Node, EthApi>,
|
ctx: &mut RpcContext<Node, EthApi>,
|
||||||
) -> Result<(), eyre::Error>
|
) -> Result<(), eyre::Error>
|
||||||
where
|
where
|
||||||
Node: FullNodeComponents,
|
Node: FullNodeComponents,
|
||||||
@ -473,5 +686,9 @@ where
|
|||||||
ctx.modules.replace_configured(
|
ctx.modules.replace_configured(
|
||||||
HlNodeBlockFilterHttp::new(Arc::new(ctx.registry.eth_api().clone())).into_rpc(),
|
HlNodeBlockFilterHttp::new(Arc::new(ctx.registry.eth_api().clone())).into_rpc(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
ctx.modules
|
||||||
|
.merge_configured(HlSystemTransactionExt::new(ctx.registry.eth_api().clone()).into_rpc())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,10 +37,6 @@ impl EthChainSpec for HlChainSpec {
|
|||||||
self.inner.chain()
|
self.inner.chain()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_fee_params_at_block(&self, block_number: u64) -> BaseFeeParams {
|
|
||||||
self.inner.base_fee_params_at_block(block_number)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn base_fee_params_at_timestamp(&self, timestamp: u64) -> BaseFeeParams {
|
fn base_fee_params_at_timestamp(&self, timestamp: u64) -> BaseFeeParams {
|
||||||
self.inner.base_fee_params_at_timestamp(timestamp)
|
self.inner.base_fee_params_at_timestamp(timestamp)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,5 +5,6 @@ mod evm;
|
|||||||
mod hardforks;
|
mod hardforks;
|
||||||
pub mod node;
|
pub mod node;
|
||||||
pub mod pseudo_peer;
|
pub mod pseudo_peer;
|
||||||
|
pub mod version;
|
||||||
|
|
||||||
pub use node::primitives::{HlBlock, HlBlockBody, HlPrimitives};
|
pub use node::primitives::{HlBlock, HlBlockBody, HlPrimitives};
|
||||||
|
|||||||
12
src/main.rs
12
src/main.rs
@ -31,6 +31,9 @@ fn main() -> eyre::Result<()> {
|
|||||||
std::env::set_var("RUST_BACKTRACE", "1");
|
std::env::set_var("RUST_BACKTRACE", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize custom version metadata before parsing CLI so --version uses reth-hl values
|
||||||
|
reth_hl::version::init_reth_hl_version();
|
||||||
|
|
||||||
Cli::<HlChainSpecParser, HlNodeArgs>::parse().run(
|
Cli::<HlChainSpecParser, HlNodeArgs>::parse().run(
|
||||||
|builder: WithLaunchContext<NodeBuilder<Arc<DatabaseEnv>, HlChainSpec>>,
|
|builder: WithLaunchContext<NodeBuilder<Arc<DatabaseEnv>, HlChainSpec>>,
|
||||||
ext: HlNodeArgs| async move {
|
ext: HlNodeArgs| async move {
|
||||||
@ -39,7 +42,7 @@ fn main() -> eyre::Result<()> {
|
|||||||
let (node, engine_handle_tx) = HlNode::new(ext.block_source_args.parse().await?);
|
let (node, engine_handle_tx) = HlNode::new(ext.block_source_args.parse().await?);
|
||||||
let NodeHandle { node, node_exit_future: exit_future } = builder
|
let NodeHandle { node, node_exit_future: exit_future } = builder
|
||||||
.node(node)
|
.node(node)
|
||||||
.extend_rpc_modules(move |ctx| {
|
.extend_rpc_modules(move |mut ctx| {
|
||||||
let upstream_rpc_url =
|
let upstream_rpc_url =
|
||||||
ext.upstream_rpc_url.unwrap_or_else(|| default_upstream_rpc_url.to_owned());
|
ext.upstream_rpc_url.unwrap_or_else(|| default_upstream_rpc_url.to_owned());
|
||||||
|
|
||||||
@ -60,10 +63,15 @@ fn main() -> eyre::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ext.hl_node_compliant {
|
if ext.hl_node_compliant {
|
||||||
install_hl_node_compliance(ctx)?;
|
install_hl_node_compliance(&mut ctx)?;
|
||||||
info!("hl-node compliant mode enabled");
|
info!("hl-node compliant mode enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !ext.experimental_eth_get_proof {
|
||||||
|
ctx.modules.remove_method_from_configured("eth_getProof");
|
||||||
|
info!("eth_getProof is disabled by default");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.apply(|builder| {
|
.apply(|builder| {
|
||||||
|
|||||||
@ -55,6 +55,24 @@ pub struct HlNodeArgs {
|
|||||||
/// This is useful when read precompile is needed for gas estimation.
|
/// This is useful when read precompile is needed for gas estimation.
|
||||||
#[arg(long, env = "FORWARD_CALL")]
|
#[arg(long, env = "FORWARD_CALL")]
|
||||||
pub forward_call: bool,
|
pub forward_call: bool,
|
||||||
|
|
||||||
|
/// Experimental: enables the eth_getProof RPC method.
|
||||||
|
///
|
||||||
|
/// Note: Due to the state root difference, trie updates* may not function correctly in all
|
||||||
|
/// scenarios. For example, incremental root updates are not possible, which can cause
|
||||||
|
/// eth_getProof to malfunction in some cases.
|
||||||
|
///
|
||||||
|
/// This limitation does not impact normal node functionality, except for state root (which is
|
||||||
|
/// unused) and eth_getProof. The archival state is maintained by block order, not by trie
|
||||||
|
/// updates. As a precaution, nanoreth disables eth_getProof by default to prevent
|
||||||
|
/// potential issues.
|
||||||
|
///
|
||||||
|
/// Use --experimental-eth-get-proof to forcibly enable eth_getProof, assuming trie updates are
|
||||||
|
/// working as intended. Enabling this by default will be tracked in #15.
|
||||||
|
///
|
||||||
|
/// * Refers to the Merkle trie used for eth_getProof and state root, not actual state values.
|
||||||
|
#[arg(long, env = "EXPERIMENTAL_ETH_GET_PROOF")]
|
||||||
|
pub experimental_eth_get_proof: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The main reth_hl cli interface.
|
/// The main reth_hl cli interface.
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use crate::{
|
|||||||
hardforks::HlHardforks,
|
hardforks::HlHardforks,
|
||||||
node::{
|
node::{
|
||||||
primitives::TransactionSigned,
|
primitives::TransactionSigned,
|
||||||
types::{ReadPrecompileInput, ReadPrecompileResult},
|
types::{HlExtras, ReadPrecompileInput, ReadPrecompileResult},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use alloy_consensus::{Transaction, TxReceipt};
|
use alloy_consensus::{Transaction, TxReceipt};
|
||||||
@ -102,7 +102,7 @@ where
|
|||||||
{
|
{
|
||||||
/// Creates a new HlBlockExecutor.
|
/// Creates a new HlBlockExecutor.
|
||||||
pub fn new(mut evm: EVM, ctx: HlBlockExecutionCtx<'a>, spec: Spec, receipt_builder: R) -> Self {
|
pub fn new(mut evm: EVM, ctx: HlBlockExecutionCtx<'a>, spec: Spec, receipt_builder: R) -> Self {
|
||||||
apply_precompiles(&mut evm, &ctx);
|
apply_precompiles(&mut evm, &ctx.extras);
|
||||||
Self { spec, evm, gas_used: 0, receipts: vec![], receipt_builder, ctx }
|
Self { spec, evm, gas_used: 0, receipts: vec![], receipt_builder, ctx }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ where
|
|||||||
type Evm = E;
|
type Evm = E;
|
||||||
|
|
||||||
fn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError> {
|
fn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError> {
|
||||||
apply_precompiles(&mut self.evm, &self.ctx);
|
apply_precompiles(&mut self.evm, &self.ctx.extras);
|
||||||
self.deploy_corewriter_contract()?;
|
self.deploy_corewriter_contract()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -240,10 +240,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_precompiles<'a, DB, EVM>(evm: &mut EVM, ctx: &HlBlockExecutionCtx<'a>)
|
pub fn apply_precompiles<EVM>(evm: &mut EVM, extras: &HlExtras)
|
||||||
where
|
where
|
||||||
EVM: Evm<DB = &'a mut State<DB>, Precompiles = PrecompilesMap>,
|
EVM: Evm<Precompiles = PrecompilesMap>,
|
||||||
DB: Database + 'a,
|
|
||||||
{
|
{
|
||||||
let block_number = evm.block().number;
|
let block_number = evm.block().number;
|
||||||
let precompiles_mut = evm.precompiles_mut();
|
let precompiles_mut = evm.precompiles_mut();
|
||||||
@ -255,9 +254,7 @@ where
|
|||||||
precompiles_mut.apply_precompile(&address, |_| None);
|
precompiles_mut.apply_precompile(&address, |_| None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (address, precompile) in
|
for (address, precompile) in extras.read_precompile_calls.clone().unwrap_or_default().0.iter() {
|
||||||
ctx.extras.read_precompile_calls.clone().unwrap_or_default().0.iter()
|
|
||||||
{
|
|
||||||
let precompile = precompile.clone();
|
let precompile = precompile.clone();
|
||||||
precompiles_mut.apply_precompile(address, |_| {
|
precompiles_mut.apply_precompile(address, |_| {
|
||||||
let precompiles_map: HashMap<ReadPrecompileInput, ReadPrecompileResult> =
|
let precompiles_map: HashMap<ReadPrecompileInput, ReadPrecompileResult> =
|
||||||
@ -271,7 +268,7 @@ where
|
|||||||
// NOTE: This is adapted from hyperliquid-dex/hyper-evm-sync#5
|
// NOTE: This is adapted from hyperliquid-dex/hyper-evm-sync#5
|
||||||
const WARM_PRECOMPILES_BLOCK_NUMBER: u64 = 8_197_684;
|
const WARM_PRECOMPILES_BLOCK_NUMBER: u64 = 8_197_684;
|
||||||
if block_number >= U256::from(WARM_PRECOMPILES_BLOCK_NUMBER) {
|
if block_number >= U256::from(WARM_PRECOMPILES_BLOCK_NUMBER) {
|
||||||
fill_all_precompiles(ctx, precompiles_mut);
|
fill_all_precompiles(extras, precompiles_mut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,9 +276,9 @@ fn address_to_u64(address: Address) -> u64 {
|
|||||||
address.into_u256().try_into().unwrap()
|
address.into_u256().try_into().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill_all_precompiles<'a>(ctx: &HlBlockExecutionCtx<'a>, precompiles_mut: &mut PrecompilesMap) {
|
fn fill_all_precompiles(extras: &HlExtras, precompiles_mut: &mut PrecompilesMap) {
|
||||||
let lowest_address = 0x800;
|
let lowest_address = 0x800;
|
||||||
let highest_address = ctx.extras.highest_precompile_address.map_or(0x80D, address_to_u64);
|
let highest_address = extras.highest_precompile_address.map_or(0x80D, address_to_u64);
|
||||||
for address in lowest_address..=highest_address {
|
for address in lowest_address..=highest_address {
|
||||||
let address = Address::from(U160::from(address));
|
let address = Address::from(U160::from(address));
|
||||||
precompiles_mut.apply_precompile(&address, |f| {
|
precompiles_mut.apply_precompile(&address, |f| {
|
||||||
|
|||||||
@ -32,6 +32,8 @@ mod factory;
|
|||||||
mod patch;
|
mod patch;
|
||||||
pub mod receipt_builder;
|
pub mod receipt_builder;
|
||||||
|
|
||||||
|
pub use executor::apply_precompiles;
|
||||||
|
|
||||||
/// HL EVM implementation.
|
/// HL EVM implementation.
|
||||||
///
|
///
|
||||||
/// This is a wrapper type around the `revm` evm with optional [`Inspector`] (tracing)
|
/// This is a wrapper type around the `revm` evm with optional [`Inspector`] (tracing)
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
use crate::node::primitives::TransactionSigned;
|
use crate::node::primitives::TransactionSigned;
|
||||||
use alloy_evm::eth::receipt_builder::{ReceiptBuilder, ReceiptBuilderCtx};
|
use alloy_evm::eth::receipt_builder::{ReceiptBuilder, ReceiptBuilderCtx};
|
||||||
|
use reth_codecs::alloy::transaction::Envelope;
|
||||||
use reth_evm::Evm;
|
use reth_evm::Evm;
|
||||||
use reth_primitives::Receipt;
|
use reth_primitives::Receipt;
|
||||||
|
|
||||||
|
|||||||
@ -1,20 +1,22 @@
|
|||||||
//! HlNodePrimitives::TransactionSigned; it's the same as ethereum transaction type,
|
//! HlNodePrimitives::TransactionSigned; it's the same as ethereum transaction type,
|
||||||
//! except that it supports pseudo signer for system transactions.
|
//! except that it supports pseudo signer for system transactions.
|
||||||
|
use crate::evm::transaction::HlTxEnv;
|
||||||
use alloy_consensus::{
|
use alloy_consensus::{
|
||||||
crypto::RecoveryError, error::ValueError, EthereumTxEnvelope, EthereumTypedTransaction,
|
crypto::RecoveryError, error::ValueError, SignableTransaction, Signed,
|
||||||
SignableTransaction, Signed, Transaction as TransactionTrait, TransactionEnvelope, TxEip1559,
|
Transaction as TransactionTrait, TransactionEnvelope, TxEip1559, TxEip2930, TxEip4844,
|
||||||
TxEip2930, TxEip4844, TxEip4844WithSidecar, TxEip7702, TxLegacy, TxType, TypedTransaction,
|
TxEip7702, TxLegacy, TxType, TypedTransaction,
|
||||||
};
|
};
|
||||||
use alloy_eips::{eip7594::BlobTransactionSidecarVariant, Encodable2718};
|
use alloy_eips::Encodable2718;
|
||||||
use alloy_network::TxSigner;
|
use alloy_network::TxSigner;
|
||||||
use alloy_primitives::{address, Address, TxHash, U256};
|
use alloy_primitives::{address, Address, TxHash, U256};
|
||||||
use alloy_rpc_types::{Transaction, TransactionInfo, TransactionRequest};
|
use alloy_rpc_types::{Transaction, TransactionInfo, TransactionRequest};
|
||||||
use alloy_signer::Signature;
|
use alloy_signer::Signature;
|
||||||
use reth_codecs::alloy::transaction::FromTxCompact;
|
use reth_codecs::alloy::transaction::{Envelope, FromTxCompact};
|
||||||
use reth_db::{
|
use reth_db::{
|
||||||
table::{Compress, Decompress},
|
table::{Compress, Decompress},
|
||||||
DatabaseError,
|
DatabaseError,
|
||||||
};
|
};
|
||||||
|
use reth_ethereum_primitives::PooledTransactionVariant;
|
||||||
use reth_evm::FromRecoveredTx;
|
use reth_evm::FromRecoveredTx;
|
||||||
use reth_primitives::Recovered;
|
use reth_primitives::Recovered;
|
||||||
use reth_primitives_traits::{
|
use reth_primitives_traits::{
|
||||||
@ -26,8 +28,6 @@ use reth_rpc_eth_api::{
|
|||||||
};
|
};
|
||||||
use revm::context::{BlockEnv, CfgEnv, TxEnv};
|
use revm::context::{BlockEnv, CfgEnv, TxEnv};
|
||||||
|
|
||||||
use crate::evm::transaction::HlTxEnv;
|
|
||||||
|
|
||||||
type InnerType = alloy_consensus::EthereumTxEnvelope<TxEip4844>;
|
type InnerType = alloy_consensus::EthereumTxEnvelope<TxEip4844>;
|
||||||
|
|
||||||
#[derive(Debug, Clone, TransactionEnvelope)]
|
#[derive(Debug, Clone, TransactionEnvelope)]
|
||||||
@ -157,16 +157,8 @@ impl TransactionSigned {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn signature(&self) -> &Signature {
|
|
||||||
self.inner().signature()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn tx_type(&self) -> TxType {
|
|
||||||
self.inner().tx_type()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_system_transaction(&self) -> bool {
|
pub fn is_system_transaction(&self) -> bool {
|
||||||
self.gas_price().is_some() && self.gas_price().unwrap() == 0
|
matches!(self.gas_price(), Some(0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,24 +179,16 @@ impl SerdeBincodeCompat for TransactionSigned {
|
|||||||
|
|
||||||
pub type BlockBody = alloy_consensus::BlockBody<TransactionSigned>;
|
pub type BlockBody = alloy_consensus::BlockBody<TransactionSigned>;
|
||||||
|
|
||||||
impl TryFrom<TransactionSigned>
|
impl TryFrom<TransactionSigned> for PooledTransactionVariant {
|
||||||
for EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>>
|
type Error = <InnerType as TryInto<PooledTransactionVariant>>::Error;
|
||||||
{
|
|
||||||
type Error = <InnerType as TryInto<
|
|
||||||
EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>>,
|
|
||||||
>>::Error;
|
|
||||||
|
|
||||||
fn try_from(value: TransactionSigned) -> Result<Self, Self::Error> {
|
fn try_from(value: TransactionSigned) -> Result<Self, Self::Error> {
|
||||||
value.into_inner().try_into()
|
value.into_inner().try_into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>>>
|
impl From<PooledTransactionVariant> for TransactionSigned {
|
||||||
for TransactionSigned
|
fn from(value: PooledTransactionVariant) -> Self {
|
||||||
{
|
|
||||||
fn from(
|
|
||||||
value: EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>>,
|
|
||||||
) -> Self {
|
|
||||||
Self::Default(value.into())
|
Self::Default(value.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,10 +196,6 @@ impl From<EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>
|
|||||||
impl Compress for TransactionSigned {
|
impl Compress for TransactionSigned {
|
||||||
type Compressed = Vec<u8>;
|
type Compressed = Vec<u8>;
|
||||||
|
|
||||||
fn compress(self) -> Self::Compressed {
|
|
||||||
self.into_inner().compress()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn compress_to_buf<B: bytes::BufMut + AsMut<[u8]>>(&self, buf: &mut B) {
|
fn compress_to_buf<B: bytes::BufMut + AsMut<[u8]>>(&self, buf: &mut B) {
|
||||||
self.inner().compress_to_buf(buf);
|
self.inner().compress_to_buf(buf);
|
||||||
}
|
}
|
||||||
@ -281,26 +261,7 @@ impl SignableTxRequest<TransactionSigned> for TransactionRequest {
|
|||||||
self,
|
self,
|
||||||
signer: impl TxSigner<Signature> + Send,
|
signer: impl TxSigner<Signature> + Send,
|
||||||
) -> Result<TransactionSigned, SignTxRequestError> {
|
) -> Result<TransactionSigned, SignTxRequestError> {
|
||||||
let mut tx =
|
let signed = SignableTxRequest::<InnerType>::try_build_and_sign(self, signer).await?;
|
||||||
self.build_typed_tx().map_err(|_| SignTxRequestError::InvalidTransactionRequest)?;
|
|
||||||
let signature = signer.sign_transaction(&mut tx).await?;
|
|
||||||
let signed = match tx {
|
|
||||||
EthereumTypedTransaction::Legacy(tx) => {
|
|
||||||
EthereumTxEnvelope::Legacy(tx.into_signed(signature))
|
|
||||||
}
|
|
||||||
EthereumTypedTransaction::Eip2930(tx) => {
|
|
||||||
EthereumTxEnvelope::Eip2930(tx.into_signed(signature))
|
|
||||||
}
|
|
||||||
EthereumTypedTransaction::Eip1559(tx) => {
|
|
||||||
EthereumTxEnvelope::Eip1559(tx.into_signed(signature))
|
|
||||||
}
|
|
||||||
EthereumTypedTransaction::Eip4844(tx) => {
|
|
||||||
EthereumTxEnvelope::Eip4844(TxEip4844::from(tx).into_signed(signature))
|
|
||||||
}
|
|
||||||
EthereumTypedTransaction::Eip7702(tx) => {
|
|
||||||
EthereumTxEnvelope::Eip7702(tx.into_signed(signature))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Ok(TransactionSigned::Default(signed))
|
Ok(TransactionSigned::Default(signed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::node::rpc::HlEthApi;
|
use crate::node::rpc::{HlEthApi, HlRpcNodeCore};
|
||||||
use reth::rpc::server_types::eth::{
|
use reth::rpc::server_types::eth::{
|
||||||
builder::config::PendingBlockKind, error::FromEvmError, EthApiError, PendingBlock,
|
builder::config::PendingBlockKind, error::FromEvmError, EthApiError, PendingBlock,
|
||||||
};
|
};
|
||||||
@ -6,12 +6,12 @@ use reth_rpc_eth_api::{
|
|||||||
helpers::{
|
helpers::{
|
||||||
pending_block::PendingEnvBuilder, EthBlocks, LoadBlock, LoadPendingBlock, LoadReceipt,
|
pending_block::PendingEnvBuilder, EthBlocks, LoadBlock, LoadPendingBlock, LoadReceipt,
|
||||||
},
|
},
|
||||||
RpcConvert, RpcNodeCore,
|
RpcConvert,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<N, Rpc> EthBlocks for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthBlocks for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
@ -19,7 +19,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> LoadBlock for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadBlock for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
@ -27,7 +27,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> LoadPendingBlock for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadPendingBlock for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
@ -49,7 +49,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> LoadReceipt for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadReceipt for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,32 +1,45 @@
|
|||||||
use super::HlEthApi;
|
use core::fmt;
|
||||||
|
|
||||||
|
use super::{HlEthApi, HlRpcNodeCore};
|
||||||
|
use crate::{node::evm::apply_precompiles, HlBlock};
|
||||||
|
use alloy_evm::Evm;
|
||||||
|
use alloy_primitives::B256;
|
||||||
use reth::rpc::server_types::eth::EthApiError;
|
use reth::rpc::server_types::eth::EthApiError;
|
||||||
use reth_evm::TxEnvFor;
|
use reth_evm::{ConfigureEvm, Database, EvmEnvFor, HaltReasonFor, InspectorFor, SpecFor, TxEnvFor};
|
||||||
|
use reth_primitives::{NodePrimitives, Recovered};
|
||||||
|
use reth_primitives_traits::SignedTransaction;
|
||||||
|
use reth_provider::{ProviderError, ProviderTx};
|
||||||
use reth_rpc_eth_api::{
|
use reth_rpc_eth_api::{
|
||||||
helpers::{estimate::EstimateCall, Call, EthCall},
|
helpers::{Call, EthCall},
|
||||||
FromEvmError, RpcConvert, RpcNodeCore,
|
FromEvmError, RpcConvert, RpcNodeCore,
|
||||||
};
|
};
|
||||||
|
use revm::{context::result::ResultAndState, DatabaseCommit};
|
||||||
|
|
||||||
|
impl<N> HlRpcNodeCore for N where N: RpcNodeCore<Primitives: NodePrimitives<Block = HlBlock>> {}
|
||||||
|
|
||||||
impl<N, Rpc> EthCall for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthCall for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, TxEnv = TxEnvFor<N::Evm>>,
|
Rpc: RpcConvert<
|
||||||
{
|
Primitives = N::Primitives,
|
||||||
}
|
Error = EthApiError,
|
||||||
|
TxEnv = TxEnvFor<N::Evm>,
|
||||||
impl<N, Rpc> EstimateCall for HlEthApi<N, Rpc>
|
Spec = SpecFor<N::Evm>,
|
||||||
where
|
>,
|
||||||
N: RpcNodeCore,
|
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, TxEnv = TxEnvFor<N::Evm>>,
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N, Rpc> Call for HlEthApi<N, Rpc>
|
impl<N, Rpc> Call for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, TxEnv = TxEnvFor<N::Evm>>,
|
Rpc: RpcConvert<
|
||||||
|
Primitives = N::Primitives,
|
||||||
|
Error = EthApiError,
|
||||||
|
TxEnv = TxEnvFor<N::Evm>,
|
||||||
|
Spec = SpecFor<N::Evm>,
|
||||||
|
>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn call_gas_limit(&self) -> u64 {
|
fn call_gas_limit(&self) -> u64 {
|
||||||
@ -37,4 +50,75 @@ where
|
|||||||
fn max_simulate_blocks(&self) -> u64 {
|
fn max_simulate_blocks(&self) -> u64 {
|
||||||
self.inner.eth_api.max_simulate_blocks()
|
self.inner.eth_api.max_simulate_blocks()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn transact<DB>(
|
||||||
|
&self,
|
||||||
|
db: DB,
|
||||||
|
evm_env: EvmEnvFor<Self::Evm>,
|
||||||
|
tx_env: TxEnvFor<Self::Evm>,
|
||||||
|
) -> Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>
|
||||||
|
where
|
||||||
|
DB: Database<Error = ProviderError> + fmt::Debug,
|
||||||
|
{
|
||||||
|
let block_number = evm_env.block_env().number;
|
||||||
|
let hl_extras = self.get_hl_extras(block_number.try_into().unwrap())?;
|
||||||
|
|
||||||
|
let mut evm = self.evm_config().evm_with_env(db, evm_env);
|
||||||
|
apply_precompiles(&mut evm, &hl_extras);
|
||||||
|
let res = evm.transact(tx_env).map_err(Self::Error::from_evm_err)?;
|
||||||
|
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn transact_with_inspector<DB, I>(
|
||||||
|
&self,
|
||||||
|
db: DB,
|
||||||
|
evm_env: EvmEnvFor<Self::Evm>,
|
||||||
|
tx_env: TxEnvFor<Self::Evm>,
|
||||||
|
inspector: I,
|
||||||
|
) -> Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>
|
||||||
|
where
|
||||||
|
DB: Database<Error = ProviderError> + fmt::Debug,
|
||||||
|
I: InspectorFor<Self::Evm, DB>,
|
||||||
|
{
|
||||||
|
let block_number = evm_env.block_env().number;
|
||||||
|
let hl_extras = self.get_hl_extras(block_number.try_into().unwrap())?;
|
||||||
|
|
||||||
|
let mut evm = self.evm_config().evm_with_env_and_inspector(db, evm_env, inspector);
|
||||||
|
apply_precompiles(&mut evm, &hl_extras);
|
||||||
|
let res = evm.transact(tx_env).map_err(Self::Error::from_evm_err)?;
|
||||||
|
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn replay_transactions_until<'a, DB, I>(
|
||||||
|
&self,
|
||||||
|
db: &mut DB,
|
||||||
|
evm_env: EvmEnvFor<Self::Evm>,
|
||||||
|
transactions: I,
|
||||||
|
target_tx_hash: B256,
|
||||||
|
) -> Result<usize, Self::Error>
|
||||||
|
where
|
||||||
|
DB: Database<Error = ProviderError> + DatabaseCommit + core::fmt::Debug,
|
||||||
|
I: IntoIterator<Item = Recovered<&'a ProviderTx<Self::Provider>>>,
|
||||||
|
{
|
||||||
|
let block_number = evm_env.block_env().number;
|
||||||
|
let hl_extras = self.get_hl_extras(block_number.try_into().unwrap())?;
|
||||||
|
|
||||||
|
let mut evm = self.evm_config().evm_with_env(db, evm_env);
|
||||||
|
apply_precompiles(&mut evm, &hl_extras);
|
||||||
|
|
||||||
|
let mut index = 0;
|
||||||
|
for tx in transactions {
|
||||||
|
if *tx.tx_hash() == target_tx_hash {
|
||||||
|
// reached the target transaction
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let tx_env = self.evm_config().tx_env(tx);
|
||||||
|
evm.transact_commit(tx_env).map_err(Self::Error::from_evm_err)?;
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
Ok(index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
215
src/node/rpc/estimate.rs
Normal file
215
src/node/rpc/estimate.rs
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
use super::{apply_precompiles, HlEthApi, HlRpcNodeCore};
|
||||||
|
use alloy_evm::overrides::{apply_state_overrides, StateOverrideError};
|
||||||
|
use alloy_network::TransactionBuilder;
|
||||||
|
use alloy_primitives::{TxKind, U256};
|
||||||
|
use alloy_rpc_types_eth::state::StateOverride;
|
||||||
|
use reth_chainspec::MIN_TRANSACTION_GAS;
|
||||||
|
use reth_errors::ProviderError;
|
||||||
|
use reth_evm::{ConfigureEvm, Evm, EvmEnvFor, SpecFor, TransactionEnv, TxEnvFor};
|
||||||
|
use reth_revm::{database::StateProviderDatabase, db::CacheDB};
|
||||||
|
use reth_rpc_convert::{RpcConvert, RpcTxReq};
|
||||||
|
use reth_rpc_eth_api::{
|
||||||
|
helpers::{
|
||||||
|
estimate::{update_estimated_gas_range, EstimateCall},
|
||||||
|
Call,
|
||||||
|
},
|
||||||
|
AsEthApiError, IntoEthApiError, RpcNodeCore,
|
||||||
|
};
|
||||||
|
use reth_rpc_eth_types::{
|
||||||
|
error::{api::FromEvmHalt, FromEvmError},
|
||||||
|
EthApiError, RevertError, RpcInvalidTransactionError,
|
||||||
|
};
|
||||||
|
use reth_rpc_server_types::constants::gas_oracle::{CALL_STIPEND_GAS, ESTIMATE_GAS_ERROR_RATIO};
|
||||||
|
use reth_storage_api::StateProvider;
|
||||||
|
use revm::context_interface::{result::ExecutionResult, Transaction};
|
||||||
|
use tracing::trace;
|
||||||
|
|
||||||
|
impl<N, Rpc> EstimateCall for HlEthApi<N, Rpc>
|
||||||
|
where
|
||||||
|
Self: Call,
|
||||||
|
N: HlRpcNodeCore,
|
||||||
|
EthApiError: FromEvmError<N::Evm> + From<StateOverrideError<ProviderError>>,
|
||||||
|
Rpc: RpcConvert<
|
||||||
|
Primitives = N::Primitives,
|
||||||
|
Error = EthApiError,
|
||||||
|
TxEnv = TxEnvFor<N::Evm>,
|
||||||
|
Spec = SpecFor<N::Evm>,
|
||||||
|
>,
|
||||||
|
{
|
||||||
|
// Modified version that adds `apply_precompiles`; comments are stripped out.
|
||||||
|
fn estimate_gas_with<S>(
|
||||||
|
&self,
|
||||||
|
mut evm_env: EvmEnvFor<Self::Evm>,
|
||||||
|
mut request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>,
|
||||||
|
state: S,
|
||||||
|
state_override: Option<StateOverride>,
|
||||||
|
) -> Result<U256, Self::Error>
|
||||||
|
where
|
||||||
|
S: StateProvider,
|
||||||
|
{
|
||||||
|
evm_env.cfg_env.disable_eip3607 = true;
|
||||||
|
evm_env.cfg_env.disable_base_fee = true;
|
||||||
|
|
||||||
|
request.as_mut().take_nonce();
|
||||||
|
|
||||||
|
let tx_request_gas_limit = request.as_ref().gas_limit();
|
||||||
|
let tx_request_gas_price = request.as_ref().gas_price();
|
||||||
|
let max_gas_limit = evm_env
|
||||||
|
.cfg_env
|
||||||
|
.tx_gas_limit_cap
|
||||||
|
.map_or(evm_env.block_env.gas_limit, |cap| cap.min(evm_env.block_env.gas_limit));
|
||||||
|
|
||||||
|
let mut highest_gas_limit = tx_request_gas_limit
|
||||||
|
.map(|mut tx_gas_limit| {
|
||||||
|
if max_gas_limit < tx_gas_limit {
|
||||||
|
tx_gas_limit = max_gas_limit;
|
||||||
|
}
|
||||||
|
tx_gas_limit
|
||||||
|
})
|
||||||
|
.unwrap_or(max_gas_limit);
|
||||||
|
|
||||||
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
|
if let Some(state_override) = state_override {
|
||||||
|
apply_state_overrides(state_override, &mut db).map_err(
|
||||||
|
|err: StateOverrideError<ProviderError>| {
|
||||||
|
let eth_api_error: EthApiError = EthApiError::from(err);
|
||||||
|
Self::Error::from(eth_api_error)
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut tx_env = self.create_txn_env(&evm_env, request, &mut db)?;
|
||||||
|
|
||||||
|
let mut is_basic_transfer = false;
|
||||||
|
if tx_env.input().is_empty() {
|
||||||
|
if let TxKind::Call(to) = tx_env.kind() {
|
||||||
|
if let Ok(code) = db.db.account_code(&to) {
|
||||||
|
is_basic_transfer = code.map(|code| code.is_empty()).unwrap_or(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if tx_env.gas_price() > 0 {
|
||||||
|
highest_gas_limit =
|
||||||
|
highest_gas_limit.min(self.caller_gas_allowance(&mut db, &evm_env, &tx_env)?);
|
||||||
|
}
|
||||||
|
|
||||||
|
tx_env.set_gas_limit(tx_env.gas_limit().min(highest_gas_limit));
|
||||||
|
|
||||||
|
let block_number = evm_env.block_env().number;
|
||||||
|
let hl_extras = self.get_hl_extras(block_number.try_into().unwrap())?;
|
||||||
|
|
||||||
|
let mut evm = self.evm_config().evm_with_env(&mut db, evm_env);
|
||||||
|
apply_precompiles(&mut evm, &hl_extras);
|
||||||
|
|
||||||
|
if is_basic_transfer {
|
||||||
|
let mut min_tx_env = tx_env.clone();
|
||||||
|
min_tx_env.set_gas_limit(MIN_TRANSACTION_GAS);
|
||||||
|
|
||||||
|
if let Ok(res) = evm.transact(min_tx_env).map_err(Self::Error::from_evm_err) {
|
||||||
|
if res.result.is_success() {
|
||||||
|
return Ok(U256::from(MIN_TRANSACTION_GAS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trace!(target: "rpc::eth::estimate", ?tx_env, gas_limit = tx_env.gas_limit(), is_basic_transfer, "Starting gas estimation");
|
||||||
|
|
||||||
|
let mut res = match evm.transact(tx_env.clone()).map_err(Self::Error::from_evm_err) {
|
||||||
|
Err(err)
|
||||||
|
if err.is_gas_too_high() &&
|
||||||
|
(tx_request_gas_limit.is_some() || tx_request_gas_price.is_some()) =>
|
||||||
|
{
|
||||||
|
return Self::map_out_of_gas_err(&mut evm, tx_env, max_gas_limit);
|
||||||
|
}
|
||||||
|
Err(err) if err.is_gas_too_low() => {
|
||||||
|
return Err(RpcInvalidTransactionError::GasRequiredExceedsAllowance {
|
||||||
|
gas_limit: tx_env.gas_limit(),
|
||||||
|
}
|
||||||
|
.into_eth_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
ethres => ethres?,
|
||||||
|
};
|
||||||
|
|
||||||
|
let gas_refund = match res.result {
|
||||||
|
ExecutionResult::Success { gas_refunded, .. } => gas_refunded,
|
||||||
|
ExecutionResult::Halt { reason, .. } => {
|
||||||
|
return Err(Self::Error::from_evm_halt(reason, tx_env.gas_limit()));
|
||||||
|
}
|
||||||
|
ExecutionResult::Revert { output, .. } => {
|
||||||
|
return if tx_request_gas_limit.is_some() || tx_request_gas_price.is_some() {
|
||||||
|
Self::map_out_of_gas_err(&mut evm, tx_env, max_gas_limit)
|
||||||
|
} else {
|
||||||
|
Err(RpcInvalidTransactionError::Revert(RevertError::new(output)).into_eth_err())
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
highest_gas_limit = tx_env.gas_limit();
|
||||||
|
|
||||||
|
let mut gas_used = res.result.gas_used();
|
||||||
|
|
||||||
|
let mut lowest_gas_limit = gas_used.saturating_sub(1);
|
||||||
|
|
||||||
|
let optimistic_gas_limit = (gas_used + gas_refund + CALL_STIPEND_GAS) * 64 / 63;
|
||||||
|
if optimistic_gas_limit < highest_gas_limit {
|
||||||
|
let mut optimistic_tx_env = tx_env.clone();
|
||||||
|
optimistic_tx_env.set_gas_limit(optimistic_gas_limit);
|
||||||
|
|
||||||
|
res = evm.transact(optimistic_tx_env).map_err(Self::Error::from_evm_err)?;
|
||||||
|
|
||||||
|
gas_used = res.result.gas_used();
|
||||||
|
|
||||||
|
update_estimated_gas_range(
|
||||||
|
res.result,
|
||||||
|
optimistic_gas_limit,
|
||||||
|
&mut highest_gas_limit,
|
||||||
|
&mut lowest_gas_limit,
|
||||||
|
)?;
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut mid_gas_limit = std::cmp::min(
|
||||||
|
gas_used * 3,
|
||||||
|
((highest_gas_limit as u128 + lowest_gas_limit as u128) / 2) as u64,
|
||||||
|
);
|
||||||
|
|
||||||
|
trace!(target: "rpc::eth::estimate", ?highest_gas_limit, ?lowest_gas_limit, ?mid_gas_limit, "Starting binary search for gas");
|
||||||
|
|
||||||
|
while lowest_gas_limit + 1 < highest_gas_limit {
|
||||||
|
if (highest_gas_limit - lowest_gas_limit) as f64 / (highest_gas_limit as f64) <
|
||||||
|
ESTIMATE_GAS_ERROR_RATIO
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut mid_tx_env = tx_env.clone();
|
||||||
|
mid_tx_env.set_gas_limit(mid_gas_limit);
|
||||||
|
|
||||||
|
match evm.transact(mid_tx_env).map_err(Self::Error::from_evm_err) {
|
||||||
|
Err(err) if err.is_gas_too_high() => {
|
||||||
|
highest_gas_limit = mid_gas_limit;
|
||||||
|
}
|
||||||
|
Err(err) if err.is_gas_too_low() => {
|
||||||
|
lowest_gas_limit = mid_gas_limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
ethres => {
|
||||||
|
res = ethres?;
|
||||||
|
|
||||||
|
update_estimated_gas_range(
|
||||||
|
res.result,
|
||||||
|
mid_gas_limit,
|
||||||
|
&mut highest_gas_limit,
|
||||||
|
&mut lowest_gas_limit,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mid_gas_limit = ((highest_gas_limit as u128 + lowest_gas_limit as u128) / 2) as u64;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(U256::from(highest_gas_limit))
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,3 +1,9 @@
|
|||||||
|
use crate::{
|
||||||
|
chainspec::HlChainSpec,
|
||||||
|
node::{evm::apply_precompiles, types::HlExtras},
|
||||||
|
HlBlock, HlPrimitives,
|
||||||
|
};
|
||||||
|
use alloy_evm::Evm;
|
||||||
use alloy_network::Ethereum;
|
use alloy_network::Ethereum;
|
||||||
use alloy_primitives::U256;
|
use alloy_primitives::U256;
|
||||||
use reth::{
|
use reth::{
|
||||||
@ -18,28 +24,31 @@ use reth::{
|
|||||||
TaskSpawner,
|
TaskSpawner,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use reth_evm::ConfigureEvm;
|
use reth_evm::{ConfigureEvm, Database, EvmEnvFor, HaltReasonFor, InspectorFor, TxEnvFor};
|
||||||
use reth_provider::{ChainSpecProvider, ProviderHeader, ProviderTx};
|
use reth_primitives::NodePrimitives;
|
||||||
|
use reth_provider::{BlockReader, ChainSpecProvider, ProviderError, ProviderHeader, ProviderTx};
|
||||||
use reth_rpc::RpcTypes;
|
use reth_rpc::RpcTypes;
|
||||||
use reth_rpc_eth_api::{
|
use reth_rpc_eth_api::{
|
||||||
helpers::{
|
helpers::{
|
||||||
pending_block::BuildPendingEnv, spec::SignersForApi, AddDevSigners, EthApiSpec, EthFees,
|
pending_block::BuildPendingEnv, spec::SignersForApi, AddDevSigners, EthApiSpec, EthFees,
|
||||||
EthState, LoadFee, LoadState, SpawnBlocking, Trace,
|
EthState, LoadFee, LoadPendingBlock, LoadState, SpawnBlocking, Trace,
|
||||||
},
|
},
|
||||||
EthApiTypes, FromEvmError, RpcConvert, RpcConverter, RpcNodeCore, RpcNodeCoreExt,
|
EthApiTypes, FromEvmError, RpcConvert, RpcConverter, RpcNodeCore, RpcNodeCoreExt,
|
||||||
SignableTxRequest,
|
SignableTxRequest,
|
||||||
};
|
};
|
||||||
|
use revm::context::result::ResultAndState;
|
||||||
use std::{fmt, marker::PhantomData, sync::Arc};
|
use std::{fmt, marker::PhantomData, sync::Arc};
|
||||||
|
|
||||||
use crate::chainspec::HlChainSpec;
|
|
||||||
|
|
||||||
mod block;
|
mod block;
|
||||||
mod call;
|
mod call;
|
||||||
pub mod engine_api;
|
pub mod engine_api;
|
||||||
|
mod estimate;
|
||||||
mod transaction;
|
mod transaction;
|
||||||
|
|
||||||
|
pub trait HlRpcNodeCore: RpcNodeCore<Primitives: NodePrimitives<Block = HlBlock>> {}
|
||||||
|
|
||||||
/// Container type `HlEthApi`
|
/// Container type `HlEthApi`
|
||||||
pub(crate) struct HlEthApiInner<N: RpcNodeCore, Rpc: RpcConvert> {
|
pub(crate) struct HlEthApiInner<N: HlRpcNodeCore, Rpc: RpcConvert> {
|
||||||
/// Gateway to node's core components.
|
/// Gateway to node's core components.
|
||||||
pub(crate) eth_api: EthApiInner<N, Rpc>,
|
pub(crate) eth_api: EthApiInner<N, Rpc>,
|
||||||
}
|
}
|
||||||
@ -48,14 +57,14 @@ type HlRpcConvert<N, NetworkT> =
|
|||||||
RpcConverter<NetworkT, <N as FullNodeComponents>::Evm, EthReceiptConverter<HlChainSpec>>;
|
RpcConverter<NetworkT, <N as FullNodeComponents>::Evm, EthReceiptConverter<HlChainSpec>>;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct HlEthApi<N: RpcNodeCore, Rpc: RpcConvert> {
|
pub struct HlEthApi<N: HlRpcNodeCore, Rpc: RpcConvert> {
|
||||||
/// Gateway to node's core components.
|
/// Gateway to node's core components.
|
||||||
pub(crate) inner: Arc<HlEthApiInner<N, Rpc>>,
|
pub(crate) inner: Arc<HlEthApiInner<N, Rpc>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N, Rpc> fmt::Debug for HlEthApi<N, Rpc>
|
impl<N, Rpc> fmt::Debug for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
@ -65,7 +74,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> EthApiTypes for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthApiTypes for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
type Error = EthApiError;
|
type Error = EthApiError;
|
||||||
@ -79,7 +88,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> RpcNodeCore for HlEthApi<N, Rpc>
|
impl<N, Rpc> RpcNodeCore for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives>,
|
Rpc: RpcConvert<Primitives = N::Primitives>,
|
||||||
{
|
{
|
||||||
type Primitives = N::Primitives;
|
type Primitives = N::Primitives;
|
||||||
@ -111,7 +120,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> RpcNodeCoreExt for HlEthApi<N, Rpc>
|
impl<N, Rpc> RpcNodeCoreExt for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -122,7 +131,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> EthApiSpec for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthApiSpec for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
type Transaction = ProviderTx<Self::Provider>;
|
type Transaction = ProviderTx<Self::Provider>;
|
||||||
@ -141,7 +150,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> SpawnBlocking for HlEthApi<N, Rpc>
|
impl<N, Rpc> SpawnBlocking for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -162,7 +171,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> LoadFee for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadFee for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
@ -179,15 +188,17 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> LoadState for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadState for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
|
Self: LoadPendingBlock,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N, Rpc> EthState for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthState for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
|
Self: LoadPendingBlock,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn max_proof_window(&self) -> u64 {
|
fn max_proof_window(&self) -> u64 {
|
||||||
@ -197,7 +208,7 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> EthFees for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthFees for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
@ -205,15 +216,50 @@ where
|
|||||||
|
|
||||||
impl<N, Rpc> Trace for HlEthApi<N, Rpc>
|
impl<N, Rpc> Trace for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
EthApiError: FromEvmError<N::Evm>,
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
|
fn inspect<DB, I>(
|
||||||
|
&self,
|
||||||
|
db: DB,
|
||||||
|
evm_env: EvmEnvFor<Self::Evm>,
|
||||||
|
tx_env: TxEnvFor<Self::Evm>,
|
||||||
|
inspector: I,
|
||||||
|
) -> Result<ResultAndState<HaltReasonFor<Self::Evm>>, Self::Error>
|
||||||
|
where
|
||||||
|
DB: Database<Error = ProviderError>,
|
||||||
|
I: InspectorFor<Self::Evm, DB>,
|
||||||
|
{
|
||||||
|
let block_number = evm_env.block_env().number;
|
||||||
|
let hl_extras = self.get_hl_extras(block_number.try_into().unwrap())?;
|
||||||
|
|
||||||
|
let mut evm = self.evm_config().evm_with_env_and_inspector(db, evm_env, inspector);
|
||||||
|
apply_precompiles(&mut evm, &hl_extras);
|
||||||
|
evm.transact(tx_env).map_err(Self::Error::from_evm_err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N, Rpc> HlEthApi<N, Rpc>
|
||||||
|
where
|
||||||
|
N: HlRpcNodeCore,
|
||||||
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
|
{
|
||||||
|
fn get_hl_extras(&self, block_number: u64) -> Result<HlExtras, ProviderError> {
|
||||||
|
Ok(self
|
||||||
|
.provider()
|
||||||
|
.block_by_number(block_number)?
|
||||||
|
.map(|block| HlExtras {
|
||||||
|
read_precompile_calls: block.body.read_precompile_calls.clone(),
|
||||||
|
highest_precompile_address: block.body.highest_precompile_address,
|
||||||
|
})
|
||||||
|
.unwrap_or_default())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N, Rpc> AddDevSigners for HlEthApi<N, Rpc>
|
impl<N, Rpc> AddDevSigners for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<
|
Rpc: RpcConvert<
|
||||||
Network: RpcTypes<TransactionRequest: SignableTxRequest<ProviderTx<N::Provider>>>,
|
Network: RpcTypes<TransactionRequest: SignableTxRequest<ProviderTx<N::Provider>>>,
|
||||||
>,
|
>,
|
||||||
@ -239,7 +285,7 @@ impl<NetworkT> Default for HlEthApiBuilder<NetworkT> {
|
|||||||
|
|
||||||
impl<N, NetworkT> EthApiBuilder<N> for HlEthApiBuilder<NetworkT>
|
impl<N, NetworkT> EthApiBuilder<N> for HlEthApiBuilder<NetworkT>
|
||||||
where
|
where
|
||||||
N: FullNodeComponents<Types: NodeTypes<ChainSpec = HlChainSpec>>
|
N: FullNodeComponents<Types: NodeTypes<ChainSpec = HlChainSpec, Primitives = HlPrimitives>>
|
||||||
+ RpcNodeCore<
|
+ RpcNodeCore<
|
||||||
Primitives = PrimitivesTy<N::Types>,
|
Primitives = PrimitivesTy<N::Types>,
|
||||||
Evm: ConfigureEvm<NextBlockEnvCtx: BuildPendingEnv<HeaderTy<N::Types>>>,
|
Evm: ConfigureEvm<NextBlockEnvCtx: BuildPendingEnv<HeaderTy<N::Types>>>,
|
||||||
|
|||||||
@ -1,21 +1,21 @@
|
|||||||
use crate::node::rpc::HlEthApi;
|
use crate::node::rpc::{HlEthApi, HlRpcNodeCore};
|
||||||
use alloy_primitives::{Bytes, B256};
|
use alloy_primitives::{Bytes, B256};
|
||||||
use reth::rpc::server_types::eth::EthApiError;
|
use reth::rpc::server_types::eth::EthApiError;
|
||||||
use reth_rpc_eth_api::{
|
use reth_rpc_eth_api::{
|
||||||
helpers::{spec::SignersForRpc, EthTransactions, LoadTransaction},
|
helpers::{spec::SignersForRpc, EthTransactions, LoadTransaction},
|
||||||
RpcConvert, RpcNodeCore,
|
RpcConvert,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<N, Rpc> LoadTransaction for HlEthApi<N, Rpc>
|
impl<N, Rpc> LoadTransaction for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N, Rpc> EthTransactions for HlEthApi<N, Rpc>
|
impl<N, Rpc> EthTransactions for HlEthApi<N, Rpc>
|
||||||
where
|
where
|
||||||
N: RpcNodeCore,
|
N: HlRpcNodeCore,
|
||||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||||
{
|
{
|
||||||
fn signers(&self) -> &SignersForRpc<Self::Provider, Self::NetworkTypes> {
|
fn signers(&self) -> &SignersForRpc<Self::Provider, Self::NetworkTypes> {
|
||||||
|
|||||||
@ -5,6 +5,8 @@ use std::collections::BTreeMap;
|
|||||||
|
|
||||||
use crate::chainspec::{MAINNET_CHAIN_ID, TESTNET_CHAIN_ID};
|
use crate::chainspec::{MAINNET_CHAIN_ID, TESTNET_CHAIN_ID};
|
||||||
|
|
||||||
|
mod patch;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
struct EvmContract {
|
struct EvmContract {
|
||||||
address: Address,
|
address: Address,
|
||||||
@ -58,5 +60,10 @@ pub(crate) fn erc20_contract_to_spot_token(chain_id: u64) -> Result<BTreeMap<Add
|
|||||||
map.insert(evm_contract.address, SpotId { index: token.index });
|
map.insert(evm_contract.address, SpotId { index: token.index });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if chain_id == TESTNET_CHAIN_ID {
|
||||||
|
patch::patch_testnet_spot_meta(&mut map);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(map)
|
Ok(map)
|
||||||
}
|
}
|
||||||
8
src/node/spot_meta/patch.rs
Normal file
8
src/node/spot_meta/patch.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
use crate::node::spot_meta::SpotId;
|
||||||
|
use alloy_primitives::{address, Address};
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
/// Testnet-specific fix for #67
|
||||||
|
pub(super) fn patch_testnet_spot_meta(map: &mut BTreeMap<Address, SpotId>) {
|
||||||
|
map.insert(address!("0xd9cbec81df392a88aeff575e962d149d57f4d6bc"), SpotId { index: 0 });
|
||||||
|
}
|
||||||
@ -12,7 +12,7 @@ pub mod utils;
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tracing::info;
|
use tracing::{error, info};
|
||||||
|
|
||||||
pub use cli::*;
|
pub use cli::*;
|
||||||
pub use config::*;
|
pub use config::*;
|
||||||
@ -78,8 +78,11 @@ pub async fn start_pseudo_peer(
|
|||||||
_ = transaction_rx.recv() => {}
|
_ = transaction_rx.recv() => {}
|
||||||
|
|
||||||
Some(eth_req) = eth_rx.recv() => {
|
Some(eth_req) = eth_rx.recv() => {
|
||||||
service.process_eth_request(eth_req).await?;
|
if let Err(e) = service.process_eth_request(eth_req).await {
|
||||||
info!("Processed eth request");
|
error!("Error processing eth request: {e:?}");
|
||||||
|
} else {
|
||||||
|
info!("Processed eth request");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,13 +152,14 @@ impl<BS: BlockSource> PseudoPeer<BS> {
|
|||||||
async fn collect_blocks(
|
async fn collect_blocks(
|
||||||
&self,
|
&self,
|
||||||
block_numbers: impl IntoIterator<Item = u64>,
|
block_numbers: impl IntoIterator<Item = u64>,
|
||||||
) -> Vec<BlockAndReceipts> {
|
) -> eyre::Result<Vec<BlockAndReceipts>> {
|
||||||
let block_numbers = block_numbers.into_iter().collect::<Vec<_>>();
|
let block_numbers = block_numbers.into_iter().collect::<Vec<_>>();
|
||||||
futures::stream::iter(block_numbers)
|
let res = futures::stream::iter(block_numbers)
|
||||||
.map(async |number| self.collect_block(number).await.unwrap())
|
.map(async |number| self.collect_block(number).await)
|
||||||
.buffered(self.block_source.recommended_chunk_size() as usize)
|
.buffered(self.block_source.recommended_chunk_size() as usize)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.await
|
.await;
|
||||||
|
res.into_iter().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn process_eth_request(
|
pub async fn process_eth_request(
|
||||||
@ -185,7 +186,7 @@ impl<BS: BlockSource> PseudoPeer<BS> {
|
|||||||
HeadersDirection::Falling => {
|
HeadersDirection::Falling => {
|
||||||
self.collect_blocks((number + 1 - limit..number + 1).rev()).await
|
self.collect_blocks((number + 1 - limit..number + 1).rev()).await
|
||||||
}
|
}
|
||||||
}
|
}?
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.map(|block| block.to_reth_block(chain_id).header.clone())
|
.map(|block| block.to_reth_block(chain_id).header.clone())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
@ -203,7 +204,7 @@ impl<BS: BlockSource> PseudoPeer<BS> {
|
|||||||
|
|
||||||
let block_bodies = self
|
let block_bodies = self
|
||||||
.collect_blocks(numbers)
|
.collect_blocks(numbers)
|
||||||
.await
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|block| block.to_reth_block(chain_id).body)
|
.map(|block| block.to_reth_block(chain_id).body)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
@ -340,7 +341,7 @@ impl<BS: BlockSource> PseudoPeer<BS> {
|
|||||||
|
|
||||||
debug!("Backfilling from {start_number} to {end_number}");
|
debug!("Backfilling from {start_number} to {end_number}");
|
||||||
// Collect blocks and cache them
|
// Collect blocks and cache them
|
||||||
let blocks = self.collect_blocks(uncached_block_numbers).await;
|
let blocks = self.collect_blocks(uncached_block_numbers).await?;
|
||||||
let block_map: HashMap<B256, u64> =
|
let block_map: HashMap<B256, u64> =
|
||||||
blocks.into_iter().map(|block| (block.hash(), block.number())).collect();
|
blocks.into_iter().map(|block| (block.hash(), block.number())).collect();
|
||||||
let maybe_block_number = block_map.get(&target_hash).copied();
|
let maybe_block_number = block_map.get(&target_hash).copied();
|
||||||
|
|||||||
@ -17,12 +17,12 @@ impl FileOperations {
|
|||||||
files.extend(
|
files.extend(
|
||||||
subentries
|
subentries
|
||||||
.filter_map(|f| f.ok().map(|f| f.path()))
|
.filter_map(|f| f.ok().map(|f| f.path()))
|
||||||
.filter(|p| TimeUtils::datetime_from_path(p).is_some()),
|
.filter_map(|p| TimeUtils::datetime_from_path(&p).map(|dt| (dt, p))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
files.sort();
|
files.sort();
|
||||||
Some(files)
|
Some(files.into_iter().map(|(_, p)| p).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_latest_hourly_file(root: &Path) -> Option<PathBuf> {
|
pub fn find_latest_hourly_file(root: &Path) -> Option<PathBuf> {
|
||||||
|
|||||||
@ -14,6 +14,7 @@ use self::{
|
|||||||
use super::{BlockSource, BlockSourceBoxed};
|
use super::{BlockSource, BlockSourceBoxed};
|
||||||
use crate::node::types::BlockAndReceipts;
|
use crate::node::types::BlockAndReceipts;
|
||||||
use futures::future::BoxFuture;
|
use futures::future::BoxFuture;
|
||||||
|
use reth_metrics::{metrics, metrics::Counter, Metrics};
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
@ -41,6 +42,16 @@ pub struct HlNodeBlockSource {
|
|||||||
pub local_blocks_cache: Arc<Mutex<LocalBlocksCache>>,
|
pub local_blocks_cache: Arc<Mutex<LocalBlocksCache>>,
|
||||||
pub last_local_fetch: Arc<Mutex<Option<(u64, OffsetDateTime)>>>,
|
pub last_local_fetch: Arc<Mutex<Option<(u64, OffsetDateTime)>>>,
|
||||||
pub args: HlNodeBlockSourceArgs,
|
pub args: HlNodeBlockSourceArgs,
|
||||||
|
pub metrics: HlNodeBlockSourceMetrics,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Metrics, Clone)]
|
||||||
|
#[metrics(scope = "block_source.hl_node")]
|
||||||
|
pub struct HlNodeBlockSourceMetrics {
|
||||||
|
/// How many times the HL node block source is polling for a block
|
||||||
|
pub fetched_from_hl_node: Counter,
|
||||||
|
/// How many times the HL node block source is fetched from the fallback
|
||||||
|
pub fetched_from_fallback: Counter,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BlockSource for HlNodeBlockSource {
|
impl BlockSource for HlNodeBlockSource {
|
||||||
@ -49,11 +60,13 @@ impl BlockSource for HlNodeBlockSource {
|
|||||||
let args = self.args.clone();
|
let args = self.args.clone();
|
||||||
let local_blocks_cache = self.local_blocks_cache.clone();
|
let local_blocks_cache = self.local_blocks_cache.clone();
|
||||||
let last_local_fetch = self.last_local_fetch.clone();
|
let last_local_fetch = self.last_local_fetch.clone();
|
||||||
|
let metrics = self.metrics.clone();
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let now = OffsetDateTime::now_utc();
|
let now = OffsetDateTime::now_utc();
|
||||||
|
|
||||||
if let Some(block) = Self::try_collect_local_block(local_blocks_cache, height).await {
|
if let Some(block) = Self::try_collect_local_block(local_blocks_cache, height).await {
|
||||||
Self::update_last_fetch(last_local_fetch, height, now).await;
|
Self::update_last_fetch(last_local_fetch, height, now).await;
|
||||||
|
metrics.fetched_from_hl_node.increment(1);
|
||||||
return Ok(block);
|
return Ok(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +81,7 @@ impl BlockSource for HlNodeBlockSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let block = fallback.collect_block(height).await?;
|
let block = fallback.collect_block(height).await?;
|
||||||
|
metrics.fetched_from_fallback.increment(1);
|
||||||
Self::update_last_fetch(last_local_fetch, height, now).await;
|
Self::update_last_fetch(last_local_fetch, height, now).await;
|
||||||
Ok(block)
|
Ok(block)
|
||||||
})
|
})
|
||||||
@ -224,6 +238,7 @@ impl HlNodeBlockSource {
|
|||||||
args,
|
args,
|
||||||
local_blocks_cache: Arc::new(Mutex::new(LocalBlocksCache::new(CACHE_SIZE))),
|
local_blocks_cache: Arc::new(Mutex::new(LocalBlocksCache::new(CACHE_SIZE))),
|
||||||
last_local_fetch: Arc::new(Mutex::new(None)),
|
last_local_fetch: Arc::new(Mutex::new(None)),
|
||||||
|
metrics: HlNodeBlockSourceMetrics::default(),
|
||||||
};
|
};
|
||||||
block_source.run(next_block_number).await.unwrap();
|
block_source.run(next_block_number).await.unwrap();
|
||||||
block_source
|
block_source
|
||||||
|
|||||||
@ -193,3 +193,22 @@ async fn test_update_last_fetch_fallback() -> eyre::Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_hourly_files_sort() -> eyre::Result<()> {
|
||||||
|
let temp_dir = tempfile::tempdir()?;
|
||||||
|
// create 20250826/9, 20250826/14
|
||||||
|
let targets = [("20250826", "9"), ("20250826", "14")];
|
||||||
|
for (date, hour) in targets {
|
||||||
|
let hourly_file = temp_dir.path().join(HOURLY_SUBDIR).join(date).join(hour);
|
||||||
|
let parent = hourly_file.parent().unwrap();
|
||||||
|
std::fs::create_dir_all(parent)?;
|
||||||
|
std::fs::File::create(hourly_file)?;
|
||||||
|
}
|
||||||
|
let files = FileOperations::all_hourly_files(temp_dir.path()).unwrap();
|
||||||
|
let file_names: Vec<_> =
|
||||||
|
files.into_iter().map(|p| p.file_name().unwrap().to_string_lossy().into_owned()).collect();
|
||||||
|
|
||||||
|
assert_eq!(file_names, ["9", "14"]);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ use super::{utils, BlockSource};
|
|||||||
use crate::node::types::BlockAndReceipts;
|
use crate::node::types::BlockAndReceipts;
|
||||||
use eyre::Context;
|
use eyre::Context;
|
||||||
use futures::{future::BoxFuture, FutureExt};
|
use futures::{future::BoxFuture, FutureExt};
|
||||||
|
use reth_metrics::{metrics, metrics::Counter, Metrics};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
@ -9,11 +10,21 @@ use tracing::info;
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct LocalBlockSource {
|
pub struct LocalBlockSource {
|
||||||
dir: PathBuf,
|
dir: PathBuf,
|
||||||
|
metrics: LocalBlockSourceMetrics,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Metrics, Clone)]
|
||||||
|
#[metrics(scope = "block_source.local")]
|
||||||
|
pub struct LocalBlockSourceMetrics {
|
||||||
|
/// How many times the local block source is polling for a block
|
||||||
|
pub polling_attempt: Counter,
|
||||||
|
/// How many times the local block source is fetched from the local filesystem
|
||||||
|
pub fetched: Counter,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LocalBlockSource {
|
impl LocalBlockSource {
|
||||||
pub fn new(dir: impl Into<PathBuf>) -> Self {
|
pub fn new(dir: impl Into<PathBuf>) -> Self {
|
||||||
Self { dir: dir.into() }
|
Self { dir: dir.into(), metrics: LocalBlockSourceMetrics::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn pick_path_with_highest_number(dir: PathBuf, is_dir: bool) -> Option<(u64, String)> {
|
async fn pick_path_with_highest_number(dir: PathBuf, is_dir: bool) -> Option<(u64, String)> {
|
||||||
@ -31,13 +42,17 @@ impl LocalBlockSource {
|
|||||||
impl BlockSource for LocalBlockSource {
|
impl BlockSource for LocalBlockSource {
|
||||||
fn collect_block(&self, height: u64) -> BoxFuture<'static, eyre::Result<BlockAndReceipts>> {
|
fn collect_block(&self, height: u64) -> BoxFuture<'static, eyre::Result<BlockAndReceipts>> {
|
||||||
let dir = self.dir.clone();
|
let dir = self.dir.clone();
|
||||||
|
let metrics = self.metrics.clone();
|
||||||
async move {
|
async move {
|
||||||
let path = dir.join(utils::rmp_path(height));
|
let path = dir.join(utils::rmp_path(height));
|
||||||
|
metrics.polling_attempt.increment(1);
|
||||||
|
|
||||||
let file = tokio::fs::read(&path)
|
let file = tokio::fs::read(&path)
|
||||||
.await
|
.await
|
||||||
.wrap_err_with(|| format!("Failed to read block from {path:?}"))?;
|
.wrap_err_with(|| format!("Failed to read block from {path:?}"))?;
|
||||||
let mut decoder = lz4_flex::frame::FrameDecoder::new(&file[..]);
|
let mut decoder = lz4_flex::frame::FrameDecoder::new(&file[..]);
|
||||||
let blocks: Vec<BlockAndReceipts> = rmp_serde::from_read(&mut decoder)?;
|
let blocks: Vec<BlockAndReceipts> = rmp_serde::from_read(&mut decoder)?;
|
||||||
|
metrics.fetched.increment(1);
|
||||||
Ok(blocks[0].clone())
|
Ok(blocks[0].clone())
|
||||||
}
|
}
|
||||||
.boxed()
|
.boxed()
|
||||||
|
|||||||
@ -2,6 +2,7 @@ use super::{utils, BlockSource};
|
|||||||
use crate::node::types::BlockAndReceipts;
|
use crate::node::types::BlockAndReceipts;
|
||||||
use aws_sdk_s3::types::RequestPayer;
|
use aws_sdk_s3::types::RequestPayer;
|
||||||
use futures::{future::BoxFuture, FutureExt};
|
use futures::{future::BoxFuture, FutureExt};
|
||||||
|
use reth_metrics::{metrics, metrics::Counter, Metrics};
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
@ -11,11 +12,26 @@ pub struct S3BlockSource {
|
|||||||
client: Arc<aws_sdk_s3::Client>,
|
client: Arc<aws_sdk_s3::Client>,
|
||||||
bucket: String,
|
bucket: String,
|
||||||
polling_interval: Duration,
|
polling_interval: Duration,
|
||||||
|
metrics: S3BlockSourceMetrics,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Metrics, Clone)]
|
||||||
|
#[metrics(scope = "block_source.s3")]
|
||||||
|
pub struct S3BlockSourceMetrics {
|
||||||
|
/// How many times the S3 block source is polling for a block
|
||||||
|
pub polling_attempt: Counter,
|
||||||
|
/// How many times the S3 block source has polled a block
|
||||||
|
pub fetched: Counter,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl S3BlockSource {
|
impl S3BlockSource {
|
||||||
pub fn new(client: aws_sdk_s3::Client, bucket: String, polling_interval: Duration) -> Self {
|
pub fn new(client: aws_sdk_s3::Client, bucket: String, polling_interval: Duration) -> Self {
|
||||||
Self { client: client.into(), bucket, polling_interval }
|
Self {
|
||||||
|
client: client.into(),
|
||||||
|
bucket,
|
||||||
|
polling_interval,
|
||||||
|
metrics: S3BlockSourceMetrics::default(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn pick_path_with_highest_number(
|
async fn pick_path_with_highest_number(
|
||||||
@ -52,14 +68,18 @@ impl BlockSource for S3BlockSource {
|
|||||||
fn collect_block(&self, height: u64) -> BoxFuture<'static, eyre::Result<BlockAndReceipts>> {
|
fn collect_block(&self, height: u64) -> BoxFuture<'static, eyre::Result<BlockAndReceipts>> {
|
||||||
let client = self.client.clone();
|
let client = self.client.clone();
|
||||||
let bucket = self.bucket.clone();
|
let bucket = self.bucket.clone();
|
||||||
|
let metrics = self.metrics.clone();
|
||||||
async move {
|
async move {
|
||||||
let path = utils::rmp_path(height);
|
let path = utils::rmp_path(height);
|
||||||
|
metrics.polling_attempt.increment(1);
|
||||||
|
|
||||||
let request = client
|
let request = client
|
||||||
.get_object()
|
.get_object()
|
||||||
.request_payer(RequestPayer::Requester)
|
.request_payer(RequestPayer::Requester)
|
||||||
.bucket(&bucket)
|
.bucket(&bucket)
|
||||||
.key(path);
|
.key(path);
|
||||||
let response = request.send().await?;
|
let response = request.send().await?;
|
||||||
|
metrics.fetched.increment(1);
|
||||||
let bytes = response.body.collect().await?.into_bytes();
|
let bytes = response.body.collect().await?.into_bytes();
|
||||||
let mut decoder = lz4_flex::frame::FrameDecoder::new(&bytes[..]);
|
let mut decoder = lz4_flex::frame::FrameDecoder::new(&bytes[..]);
|
||||||
let blocks: Vec<BlockAndReceipts> = rmp_serde::from_read(&mut decoder)?;
|
let blocks: Vec<BlockAndReceipts> = rmp_serde::from_read(&mut decoder)?;
|
||||||
|
|||||||
35
src/version.rs
Normal file
35
src/version.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use reth_node_core::version::{try_init_version_metadata, RethCliVersionConsts};
|
||||||
|
|
||||||
|
pub fn init_reth_hl_version() {
|
||||||
|
let cargo_pkg_version = env!("CARGO_PKG_VERSION").to_string();
|
||||||
|
|
||||||
|
let short = env!("RETH_HL_SHORT_VERSION").to_string();
|
||||||
|
let long = format!(
|
||||||
|
"{}\n{}\n{}\n{}\n{}",
|
||||||
|
env!("RETH_HL_LONG_VERSION_0"),
|
||||||
|
env!("RETH_HL_LONG_VERSION_1"),
|
||||||
|
env!("RETH_HL_LONG_VERSION_2"),
|
||||||
|
env!("RETH_HL_LONG_VERSION_3"),
|
||||||
|
env!("RETH_HL_LONG_VERSION_4"),
|
||||||
|
);
|
||||||
|
let p2p = env!("RETH_HL_P2P_CLIENT_VERSION").to_string();
|
||||||
|
|
||||||
|
let meta = RethCliVersionConsts {
|
||||||
|
name_client: Cow::Borrowed("reth_hl"),
|
||||||
|
cargo_pkg_version: Cow::Owned(cargo_pkg_version.clone()),
|
||||||
|
vergen_git_sha_long: Cow::Owned(env!("VERGEN_GIT_SHA").to_string()),
|
||||||
|
vergen_git_sha: Cow::Owned(env!("VERGEN_GIT_SHA_SHORT").to_string()),
|
||||||
|
vergen_build_timestamp: Cow::Owned(env!("VERGEN_BUILD_TIMESTAMP").to_string()),
|
||||||
|
vergen_cargo_target_triple: Cow::Owned(env!("VERGEN_CARGO_TARGET_TRIPLE").to_string()),
|
||||||
|
vergen_cargo_features: Cow::Owned(env!("VERGEN_CARGO_FEATURES").to_string()),
|
||||||
|
short_version: Cow::Owned(short),
|
||||||
|
long_version: Cow::Owned(long),
|
||||||
|
build_profile_name: Cow::Owned(env!("RETH_HL_BUILD_PROFILE").to_string()),
|
||||||
|
p2p_client_version: Cow::Owned(p2p),
|
||||||
|
extra_data: Cow::Owned(format!("reth_hl/v{}/{}", cargo_pkg_version, std::env::consts::OS)),
|
||||||
|
};
|
||||||
|
|
||||||
|
let _ = try_init_version_metadata(meta);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user