mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Compare commits
19 Commits
ab11ce513f
...
nb-2025091
| Author | SHA1 | Date | |
|---|---|---|---|
| 491e902904 | |||
| 45648a7a98 | |||
| c87c5a055a | |||
| c9416a3948 | |||
| db10c23c56 | |||
| fc395123f3 | |||
| 84ea1af682 | |||
| bd3e0626ed | |||
| 7d223a464e | |||
| afcc551f67 | |||
| 0dfd7a4c7f | |||
| 8faac526b7 | |||
| acfabf969c | |||
| fccf877a3a | |||
| 9e3f0c722e | |||
| cd5bcc4cb0 | |||
| d831a459bb | |||
| 66c2ee654c | |||
| 701e6a25e6 |
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)
|
||||
1
.github/workflows/docker.yml
vendored
1
.github/workflows/docker.yml
vendored
@ -6,6 +6,7 @@ on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
- nb-*
|
||||
|
||||
env:
|
||||
IMAGE_NAME: ${{ github.repository_owner }}/nanoreth
|
||||
|
||||
779
Cargo.lock
generated
779
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
108
Cargo.toml
108
Cargo.toml
@ -26,67 +26,73 @@ lto = "fat"
|
||||
codegen-units = 1
|
||||
|
||||
[dependencies]
|
||||
reth = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-cli = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-cli-commands = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-basic-payload-builder = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-db = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-db-api = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-chainspec = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-cli-util = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-discv4 = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-engine-primitives = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-ethereum-forks = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-ethereum-payload-builder = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-ethereum-primitives = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-eth-wire = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-eth-wire-types = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-evm = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-evm-ethereum = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-node-core = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-revm = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-network = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-network-p2p = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-network-api = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-node-ethereum = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-network-peers = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-payload-primitives = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-primitives = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-primitives-traits = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-provider = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb", features = ["test-utils"] }
|
||||
reth-rpc = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-rpc-eth-api = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-rpc-engine-api = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-tracing = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-trie-common = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-trie-db = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-codecs = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-transaction-pool = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
reth-stages-types = { git = "https://github.com/sprites0/reth", rev = "a690ef25b56039195e7e4a4abd01c78aedcc73fb" }
|
||||
revm = { version = "28.0.1", default-features = false }
|
||||
reth = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-cli = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-cli-commands = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-basic-payload-builder = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-db = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-db-api = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-chainspec = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-cli-util = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-discv4 = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-engine-primitives = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-ethereum-forks = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-ethereum-payload-builder = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-ethereum-primitives = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-eth-wire = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-eth-wire-types = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-evm = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-evm-ethereum = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-node-core = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-revm = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-network = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-network-p2p = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-network-api = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-node-ethereum = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-network-peers = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-payload-primitives = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-primitives = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-primitives-traits = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-provider = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505", features = ["test-utils"] }
|
||||
reth-rpc = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-rpc-eth-api = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-rpc-engine-api = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-tracing = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-trie-common = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-trie-db = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-codecs = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-transaction-pool = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
reth-stages-types = { git = "https://github.com/sprites0/reth", rev = "d26fd2e25b57d695aa453c93f15a8cd158a1f505" }
|
||||
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-genesis = { version = "1.0.23", default-features = false }
|
||||
alloy-consensus = { version = "1.0.23", default-features = false }
|
||||
alloy-genesis = { version = "1.0.30", default-features = false }
|
||||
alloy-consensus = { version = "1.0.30", default-features = false }
|
||||
alloy-chains = { version = "0.2.5", default-features = false }
|
||||
alloy-eips = { version = "1.0.23", default-features = false }
|
||||
alloy-evm = { version = "0.18.2", default-features = false }
|
||||
alloy-eips = { version = "1.0.30", default-features = false }
|
||||
alloy-evm = { version = "0.20.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-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-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-eth = { version = "1.0.23", default-features = false }
|
||||
alloy-rpc-types-engine = { version = "1.0.23", default-features = false }
|
||||
alloy-signer = { version = "1.0.23", default-features = false }
|
||||
alloy-rpc-types = { version = "1.0.30", features = ["eth"], default-features = false }
|
||||
alloy-rpc-types-eth = { version = "1.0.30", default-features = false }
|
||||
alloy-rpc-types-engine = { version = "1.0.30", default-features = false }
|
||||
alloy-signer = { version = "1.0.30", default-features = false }
|
||||
alloy-sol-macro = "1.3.1"
|
||||
alloy-sol-types = { version = "1.3.1", default-features = false }
|
||||
|
||||
jsonrpsee = "0.25.1"
|
||||
jsonrpsee-core = "0.25.1"
|
||||
jsonrpsee-types = "0.25.1"
|
||||
jsonrpsee = "0.26.0"
|
||||
jsonrpsee-core = "0.26.0"
|
||||
jsonrpsee-types = "0.26.0"
|
||||
|
||||
# misc dependencies
|
||||
auto_impl = "1"
|
||||
|
||||
1
Makefile
1
Makefile
@ -255,7 +255,6 @@ define docker_build_push
|
||||
--tag $(DOCKER_IMAGE_NAME):$(2) \
|
||||
--build-arg BUILD_PROFILE="$(PROFILE)" \
|
||||
--build-arg FEATURES="jemalloc,asm-keccak" \
|
||||
--build-arg RUSTFLAGS="-C target-cpu=native" \
|
||||
--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).
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
Testnet is supported since block 21304281.
|
||||
Testnet is supported since block 30281484.
|
||||
|
||||
```sh
|
||||
# Get testnet genesis at block 21304281
|
||||
# Get testnet genesis at block 30281484
|
||||
$ cd ~
|
||||
$ git clone https://github.com/sprites0/hl-testnet-genesis
|
||||
$ zstd --rm -d ~/hl-testnet-genesis/*.zst
|
||||
|
||||
# Init node
|
||||
$ make install
|
||||
$ reth-hl init-state --without-evm --chain testnet --header ~/hl-testnet-genesis/21304281.rlp \
|
||||
--header-hash 0x5b10856d2b1ad241c9bd6136bcc60ef7e8553560ca53995a590db65f809269b4 \
|
||||
~/hl-testnet-genesis/21304281.jsonl --total-difficulty 0
|
||||
$ reth-hl init-state --without-evm --chain testnet --header ~/hl-testnet-genesis/30281484.rlp \
|
||||
--header-hash 0x147cc3c09e9ddbb11799c826758db284f77099478ab5f528d3a57a6105516c21 \
|
||||
~/hl-testnet-genesis/30281484.jsonl --total-difficulty 0
|
||||
|
||||
# Run node
|
||||
$ reth-hl node --chain testnet --http --http.addr 0.0.0.0 --http.api eth,ots,net,web3 \
|
||||
|
||||
@ -37,10 +37,6 @@ impl EthChainSpec for HlChainSpec {
|
||||
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 {
|
||||
self.inner.base_fee_params_at_timestamp(timestamp)
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use crate::node::primitives::TransactionSigned;
|
||||
use alloy_evm::eth::receipt_builder::{ReceiptBuilder, ReceiptBuilderCtx};
|
||||
use reth_codecs::alloy::transaction::Envelope;
|
||||
use reth_evm::Evm;
|
||||
use reth_primitives::Receipt;
|
||||
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
//! HlNodePrimitives::TransactionSigned; it's the same as ethereum transaction type,
|
||||
//! except that it supports pseudo signer for system transactions.
|
||||
use crate::evm::transaction::HlTxEnv;
|
||||
use alloy_consensus::{
|
||||
crypto::RecoveryError, error::ValueError, EthereumTxEnvelope, EthereumTypedTransaction,
|
||||
SignableTransaction, Signed, Transaction as TransactionTrait, TransactionEnvelope, TxEip1559,
|
||||
TxEip2930, TxEip4844, TxEip4844WithSidecar, TxEip7702, TxLegacy, TxType, TypedTransaction,
|
||||
crypto::RecoveryError, error::ValueError, SignableTransaction, Signed,
|
||||
Transaction as TransactionTrait, TransactionEnvelope, TxEip1559, TxEip2930, TxEip4844,
|
||||
TxEip7702, TxLegacy, TxType, TypedTransaction,
|
||||
};
|
||||
use alloy_eips::{eip7594::BlobTransactionSidecarVariant, Encodable2718};
|
||||
use alloy_eips::Encodable2718;
|
||||
use alloy_network::TxSigner;
|
||||
use alloy_primitives::{address, Address, TxHash, U256};
|
||||
use alloy_rpc_types::{Transaction, TransactionInfo, TransactionRequest};
|
||||
use alloy_signer::Signature;
|
||||
use reth_codecs::alloy::transaction::FromTxCompact;
|
||||
use reth_codecs::alloy::transaction::{Envelope, FromTxCompact};
|
||||
use reth_db::{
|
||||
table::{Compress, Decompress},
|
||||
DatabaseError,
|
||||
};
|
||||
use reth_ethereum_primitives::PooledTransactionVariant;
|
||||
use reth_evm::FromRecoveredTx;
|
||||
use reth_primitives::Recovered;
|
||||
use reth_primitives_traits::{
|
||||
@ -26,8 +28,6 @@ use reth_rpc_eth_api::{
|
||||
};
|
||||
use revm::context::{BlockEnv, CfgEnv, TxEnv};
|
||||
|
||||
use crate::evm::transaction::HlTxEnv;
|
||||
|
||||
type InnerType = alloy_consensus::EthereumTxEnvelope<TxEip4844>;
|
||||
|
||||
#[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 {
|
||||
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>;
|
||||
|
||||
impl TryFrom<TransactionSigned>
|
||||
for EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>>
|
||||
{
|
||||
type Error = <InnerType as TryInto<
|
||||
EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>>,
|
||||
>>::Error;
|
||||
impl TryFrom<TransactionSigned> for PooledTransactionVariant {
|
||||
type Error = <InnerType as TryInto<PooledTransactionVariant>>::Error;
|
||||
|
||||
fn try_from(value: TransactionSigned) -> Result<Self, Self::Error> {
|
||||
value.into_inner().try_into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>>>
|
||||
for TransactionSigned
|
||||
{
|
||||
fn from(
|
||||
value: EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>>,
|
||||
) -> Self {
|
||||
impl From<PooledTransactionVariant> for TransactionSigned {
|
||||
fn from(value: PooledTransactionVariant) -> Self {
|
||||
Self::Default(value.into())
|
||||
}
|
||||
}
|
||||
@ -277,26 +261,7 @@ impl SignableTxRequest<TransactionSigned> for TransactionRequest {
|
||||
self,
|
||||
signer: impl TxSigner<Signature> + Send,
|
||||
) -> Result<TransactionSigned, SignTxRequestError> {
|
||||
let mut tx =
|
||||
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))
|
||||
}
|
||||
};
|
||||
let signed = SignableTxRequest::<InnerType>::try_build_and_sign(self, signer).await?;
|
||||
Ok(TransactionSigned::Default(signed))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
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_evm::{ConfigureEvm, Database, EvmEnvFor, 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::{
|
||||
helpers::{estimate::EstimateCall, Call, EthCall},
|
||||
helpers::{Call, EthCall},
|
||||
FromEvmError, RpcConvert, RpcNodeCore,
|
||||
};
|
||||
use revm::DatabaseCommit;
|
||||
use revm::{context::result::ResultAndState, DatabaseCommit};
|
||||
|
||||
impl<N> HlRpcNodeCore for N where N: RpcNodeCore<Primitives: NodePrimitives<Block = HlBlock>> {}
|
||||
|
||||
@ -19,15 +21,12 @@ impl<N, Rpc> EthCall for HlEthApi<N, Rpc>
|
||||
where
|
||||
N: HlRpcNodeCore,
|
||||
EthApiError: FromEvmError<N::Evm>,
|
||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError, TxEnv = TxEnvFor<N::Evm>>,
|
||||
{
|
||||
}
|
||||
|
||||
impl<N, Rpc> EstimateCall for HlEthApi<N, Rpc>
|
||||
where
|
||||
N: HlRpcNodeCore,
|
||||
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>,
|
||||
>,
|
||||
{
|
||||
}
|
||||
|
||||
@ -35,7 +34,12 @@ impl<N, Rpc> Call for HlEthApi<N, Rpc>
|
||||
where
|
||||
N: HlRpcNodeCore,
|
||||
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]
|
||||
fn call_gas_limit(&self) -> u64 {
|
||||
@ -47,6 +51,46 @@ where
|
||||
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,
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,7 @@ use reth_rpc::RpcTypes;
|
||||
use reth_rpc_eth_api::{
|
||||
helpers::{
|
||||
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,
|
||||
SignableTxRequest,
|
||||
@ -42,6 +42,7 @@ use std::{fmt, marker::PhantomData, sync::Arc};
|
||||
mod block;
|
||||
mod call;
|
||||
pub mod engine_api;
|
||||
mod estimate;
|
||||
mod transaction;
|
||||
|
||||
pub trait HlRpcNodeCore: RpcNodeCore<Primitives: NodePrimitives<Block = HlBlock>> {}
|
||||
@ -189,6 +190,7 @@ impl<N, Rpc> LoadState for HlEthApi<N, Rpc>
|
||||
where
|
||||
N: HlRpcNodeCore,
|
||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||
Self: LoadPendingBlock,
|
||||
{
|
||||
}
|
||||
|
||||
@ -196,6 +198,7 @@ impl<N, Rpc> EthState for HlEthApi<N, Rpc>
|
||||
where
|
||||
N: HlRpcNodeCore,
|
||||
Rpc: RpcConvert<Primitives = N::Primitives, Error = EthApiError>,
|
||||
Self: LoadPendingBlock,
|
||||
{
|
||||
#[inline]
|
||||
fn max_proof_window(&self) -> u64 {
|
||||
|
||||
@ -5,6 +5,8 @@ use std::collections::BTreeMap;
|
||||
|
||||
use crate::chainspec::{MAINNET_CHAIN_ID, TESTNET_CHAIN_ID};
|
||||
|
||||
mod patch;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
struct EvmContract {
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
if chain_id == TESTNET_CHAIN_ID {
|
||||
patch::patch_testnet_spot_meta(&mut 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 });
|
||||
}
|
||||
@ -14,6 +14,7 @@ use self::{
|
||||
use super::{BlockSource, BlockSourceBoxed};
|
||||
use crate::node::types::BlockAndReceipts;
|
||||
use futures::future::BoxFuture;
|
||||
use reth_metrics::{metrics, metrics::Counter, Metrics};
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
@ -41,6 +42,16 @@ pub struct HlNodeBlockSource {
|
||||
pub local_blocks_cache: Arc<Mutex<LocalBlocksCache>>,
|
||||
pub last_local_fetch: Arc<Mutex<Option<(u64, OffsetDateTime)>>>,
|
||||
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 {
|
||||
@ -49,11 +60,13 @@ impl BlockSource for HlNodeBlockSource {
|
||||
let args = self.args.clone();
|
||||
let local_blocks_cache = self.local_blocks_cache.clone();
|
||||
let last_local_fetch = self.last_local_fetch.clone();
|
||||
let metrics = self.metrics.clone();
|
||||
Box::pin(async move {
|
||||
let now = OffsetDateTime::now_utc();
|
||||
|
||||
if let Some(block) = Self::try_collect_local_block(local_blocks_cache, height).await {
|
||||
Self::update_last_fetch(last_local_fetch, height, now).await;
|
||||
metrics.fetched_from_hl_node.increment(1);
|
||||
return Ok(block);
|
||||
}
|
||||
|
||||
@ -68,6 +81,7 @@ impl BlockSource for HlNodeBlockSource {
|
||||
}
|
||||
|
||||
let block = fallback.collect_block(height).await?;
|
||||
metrics.fetched_from_fallback.increment(1);
|
||||
Self::update_last_fetch(last_local_fetch, height, now).await;
|
||||
Ok(block)
|
||||
})
|
||||
@ -224,6 +238,7 @@ impl HlNodeBlockSource {
|
||||
args,
|
||||
local_blocks_cache: Arc::new(Mutex::new(LocalBlocksCache::new(CACHE_SIZE))),
|
||||
last_local_fetch: Arc::new(Mutex::new(None)),
|
||||
metrics: HlNodeBlockSourceMetrics::default(),
|
||||
};
|
||||
block_source.run(next_block_number).await.unwrap();
|
||||
block_source
|
||||
|
||||
@ -2,6 +2,7 @@ use super::{utils, BlockSource};
|
||||
use crate::node::types::BlockAndReceipts;
|
||||
use eyre::Context;
|
||||
use futures::{future::BoxFuture, FutureExt};
|
||||
use reth_metrics::{metrics, metrics::Counter, Metrics};
|
||||
use std::path::PathBuf;
|
||||
use tracing::info;
|
||||
|
||||
@ -9,11 +10,21 @@ use tracing::info;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LocalBlockSource {
|
||||
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 {
|
||||
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)> {
|
||||
@ -31,13 +42,17 @@ impl LocalBlockSource {
|
||||
impl BlockSource for LocalBlockSource {
|
||||
fn collect_block(&self, height: u64) -> BoxFuture<'static, eyre::Result<BlockAndReceipts>> {
|
||||
let dir = self.dir.clone();
|
||||
let metrics = self.metrics.clone();
|
||||
async move {
|
||||
let path = dir.join(utils::rmp_path(height));
|
||||
metrics.polling_attempt.increment(1);
|
||||
|
||||
let file = tokio::fs::read(&path)
|
||||
.await
|
||||
.wrap_err_with(|| format!("Failed to read block from {path:?}"))?;
|
||||
let mut decoder = lz4_flex::frame::FrameDecoder::new(&file[..]);
|
||||
let blocks: Vec<BlockAndReceipts> = rmp_serde::from_read(&mut decoder)?;
|
||||
metrics.fetched.increment(1);
|
||||
Ok(blocks[0].clone())
|
||||
}
|
||||
.boxed()
|
||||
|
||||
@ -2,6 +2,7 @@ use super::{utils, BlockSource};
|
||||
use crate::node::types::BlockAndReceipts;
|
||||
use aws_sdk_s3::types::RequestPayer;
|
||||
use futures::{future::BoxFuture, FutureExt};
|
||||
use reth_metrics::{metrics, metrics::Counter, Metrics};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use tracing::info;
|
||||
|
||||
@ -11,11 +12,26 @@ pub struct S3BlockSource {
|
||||
client: Arc<aws_sdk_s3::Client>,
|
||||
bucket: String,
|
||||
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 {
|
||||
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(
|
||||
@ -52,14 +68,18 @@ impl BlockSource for S3BlockSource {
|
||||
fn collect_block(&self, height: u64) -> BoxFuture<'static, eyre::Result<BlockAndReceipts>> {
|
||||
let client = self.client.clone();
|
||||
let bucket = self.bucket.clone();
|
||||
let metrics = self.metrics.clone();
|
||||
async move {
|
||||
let path = utils::rmp_path(height);
|
||||
metrics.polling_attempt.increment(1);
|
||||
|
||||
let request = client
|
||||
.get_object()
|
||||
.request_payer(RequestPayer::Requester)
|
||||
.bucket(&bucket)
|
||||
.key(path);
|
||||
let response = request.send().await?;
|
||||
metrics.fetched.increment(1);
|
||||
let bytes = response.body.collect().await?.into_bytes();
|
||||
let mut decoder = lz4_flex::frame::FrameDecoder::new(&bytes[..]);
|
||||
let blocks: Vec<BlockAndReceipts> = rmp_serde::from_read(&mut decoder)?;
|
||||
|
||||
Reference in New Issue
Block a user