Skip to content

Commit 5bb4fab

Browse files
pythonberg1997j75689forcodedancing
authored
fix: testnet hertz issue (#1)
* ci: tag non-beta version as latest image (bnb-chain#51) * chore: add bsc and docker commands to readme (bnb-chain#50) * chore: add bsc commands to readme * fix review comments * fix op dockerfile issue * fix: spec mapping issue and snapshot overwrite issue (bnb-chain#52) * fix: system account status issue (bnb-chain#53) * test1 * test2 * test3 * test4 * test5 * test6 * test7 * test8 * update CI --------- Co-authored-by: dylanhuang <j75689@gmail.com> Co-authored-by: forcodedancing <just.haha.it@gmail.com>
1 parent 9dab153 commit 5bb4fab

File tree

7 files changed

+154
-43
lines changed

7 files changed

+154
-43
lines changed

.github/workflows/docker.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ on:
1111
env:
1212
REPO_NAME: ${{ github.repository_owner }}/reth
1313
# IMAGE_NAME: ${{ github.repository_owner }}/reth
14-
OP_IMAGE_NAME: ${{ github.repository_owner }}/op-reth
14+
# OP_IMAGE_NAME: ${{ github.repository_owner }}/op-reth
1515
BSC_IMAGE_NAME: ${{ github.repository_owner }}/bsc-reth
1616
CARGO_TERM_COLOR: always
1717
# DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/reth
18-
OP_DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/op-reth
18+
# OP_DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/op-reth
1919
BSC_DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/bsc-reth
2020
DOCKER_USERNAME: ${{ github.actor }}
2121

@@ -46,15 +46,15 @@ jobs:
4646
# - name: Build and push reth image
4747
# if: ${{ ! contains(github.event.ref, 'beta') }}
4848
# run: make PROFILE=maxperf docker-build-push
49-
- name: Build and push op-reth image, tag as "latest"
50-
if: ${{ contains(github.event.ref, 'beta') }}
51-
run: make IMAGE_NAME=$OP_IMAGE_NAME DOCKER_IMAGE_NAME=$OP_DOCKER_IMAGE_NAME PROFILE=maxperf op-docker-build-push-latest
52-
- name: Build and push op-reth image
53-
if: ${{ ! contains(github.event.ref, 'beta') }}
54-
run: make IMAGE_NAME=$OP_IMAGE_NAME DOCKER_IMAGE_NAME=$OP_DOCKER_IMAGE_NAME PROFILE=maxperf op-docker-build-push
49+
# - name: Build and push op-reth image, tag as "latest"
50+
# if: ${{ ! contains(github.event.ref, 'beta') }}
51+
# run: make IMAGE_NAME=$OP_IMAGE_NAME DOCKER_IMAGE_NAME=$OP_DOCKER_IMAGE_NAME PROFILE=maxperf op-docker-build-push-latest
52+
# - name: Build and push op-reth image
53+
# if: ${{ contains(github.event.ref, 'beta') }}
54+
# run: make IMAGE_NAME=$OP_IMAGE_NAME DOCKER_IMAGE_NAME=$OP_DOCKER_IMAGE_NAME PROFILE=maxperf op-docker-build-push
5555
- name: Build and push bsc-reth image, tag as "latest"
56-
if: ${{ contains(github.event.ref, 'beta') }}
56+
if: ${{ ! contains(github.event.ref, 'beta') }}
5757
run: make IMAGE_NAME=$BSC_IMAGE_NAME DOCKER_IMAGE_NAME=$BSC_DOCKER_IMAGE_NAME PROFILE=maxperf bsc-docker-build-push-latest
5858
- name: Build and push bsc-reth image
59-
if: ${{ ! contains(github.event.ref, 'beta') }}
59+
if: ${{ contains(github.event.ref, 'beta') }}
6060
run: make IMAGE_NAME=$BSC_IMAGE_NAME DOCKER_IMAGE_NAME=$BSC_DOCKER_IMAGE_NAME PROFILE=maxperf bsc-docker-build-push

README.md

Lines changed: 114 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
[![Discord Chat][discord-badge]][discord-url]
66

77
[gh-ci]: https://github.com/bnb-chain/reth/actions/workflows/unit.yml
8+
89
[gh-deny]: https://github.com/bnb-chain/reth/actions/workflows/deny.yml
10+
911
[discord-badge]: https://img.shields.io/badge/discord-join%20chat-blue.svg
12+
1013
[discord-url]: https://discord.gg/z2VpC455eU
1114

12-
BNB Chain Reth is a cutting-edge rust client developed in collaboration with Paradigm, designed to provide seamless support
13-
for [BNB Smart Chain(BSC)](https://github.com/bnb-chain/bsc) and [opBNB](https://github.com/bnb-chain/op-geth).
15+
BNB Chain Reth is a cutting-edge rust client developed in collaboration with Paradigm, designed to provide seamless
16+
support for [BNB Smart Chain(BSC)](https://github.com/bnb-chain/bsc) and [opBNB](https://github.com/bnb-chain/op-geth).
1417

1518
## Build from Source
1619

17-
For prerequisites and detailed build instructions please read the [Installation Instructions](https://paradigmxyz.github.io/reth/installation/source.html).
20+
For prerequisites and detailed build instructions please read
21+
the [Installation Instructions](https://paradigmxyz.github.io/reth/installation/source.html).
1822

1923
With Rust and the dependencies installed, you're ready to build BNB Chain Reth. First, clone the repository:
2024

@@ -23,16 +27,16 @@ git clone https://github.com/bnb-chain/reth.git
2327
cd reth
2428
```
2529

26-
In the realm of BSC, you have the option to execute the following commands to compile reth:
30+
In the realm of BSC, you have the option to execute the following commands to compile bsc-reth:
2731

2832
```shell
29-
make build
33+
make build-bsc
3034
```
3135

3236
Alternatively, you can install reth using the following command:
3337

3438
```shell
35-
make install
39+
make install-bsc
3640
```
3741

3842
When it comes to opBNB, you can run the following commands to compile op-reth:
@@ -49,25 +53,70 @@ make install-op
4953

5054
## Run Reth for BSC
5155

52-
Coming soon......
56+
The command below is for an archive node. To run a full node, simply add the `--full` tag.
5357

54-
## Run Reth for opBNB
58+
```shell
59+
# for testnet
60+
export network=bsc-testnet
5561

56-
The op-reth can function as both a full node and an archive node. Due to its unique storage advantages, it is primarily utilized for running archive nodes.
62+
# for mainnet
63+
# export network=bsc
5764

58-
### Hardware Requirements
65+
./target/release/bsc-reth node \
66+
--datadir=./datadir \
67+
--chain=${network} \
68+
--http \
69+
--http.addr=0.0.0.0 \
70+
--http.port=8545 \
71+
--http.api="eth, net, txpool, web3, rpc" \
72+
--ws \
73+
--ws.addr=0.0.0.0 \
74+
--ws.port=8546 \
75+
--nat=any \
76+
--log.file.directory ./datadir/logs
77+
```
78+
79+
You can run `bsc-reth --help` for command explanations.
80+
81+
For running bsc-reth with docker, please use the following command:
82+
83+
```shell
84+
# for testnet
85+
export network=bsc-testnet
86+
87+
# for mainnet
88+
# export network=bsc
5989

60-
* CPU with 16+ cores
61-
* 128GB RAM
62-
* High-performance NVMe SSD with at least 3TB of free space
63-
* A broadband internet connection with upload/download speeds of 25 MB/s
90+
# check this for version of the docker image, https://github.com/bnb-chain/reth/pkgs/container/bsc-reth
91+
export version=latest
6492

65-
### Steps to Run op-reth
93+
# the directory where reth data will be stored
94+
export data_dir=/xxx/xxx
6695

67-
The op-reth is an [execution client](https://ethereum.org/en/developers/docs/nodes-and-clients/#execution-clients) for opBNB.
96+
docker run -d -p 8545:8545 -p 8546:8546 -p 30303:30303 -p 30303:30303/udp -v ${data_dir}:/data \
97+
--name bsc-reth ghcr.io/bnb-chain/bsc-reth:${version} node \
98+
--datadir=/data \
99+
--chain=${network} \
100+
--http \
101+
--http.addr=0.0.0.0 \
102+
--http.port=8545 \
103+
--http.api="eth, net, txpool, web3, rpc" \
104+
--ws \
105+
--ws.addr=0.0.0.0 \
106+
--ws.port=8546 \
107+
--nat=any \
108+
--log.file.directory /data/logs
109+
```
110+
111+
## Run Reth for opBNB
112+
113+
The op-reth is an [execution client](https://ethereum.org/en/developers/docs/nodes-and-clients/#execution-clients) for
114+
opBNB.
68115
You need to run op-node along with op-reth to synchronize with the opBNB network.
69116

70-
Here is the quick command for running the op-node. For more details, refer to the [opbnb repository](https://github.com/bnb-chain/opbnb).
117+
Here is the quick command for running the op-node. For more details, refer to
118+
the [opbnb repository](https://github.com/bnb-chain/opbnb).
119+
71120
```shell
72121
git clone https://github.com/bnb-chain/opbnb
73122
cd opbnb
@@ -110,8 +159,10 @@ export P2P_BOOTNODES="enr:-J24QGQBeMsXOaCCaLWtNFSfb2Gv50DjGOKToH2HUTAIn9yXImowlR
110159
--l2.jwt-secret=./jwt.txt
111160
```
112161

113-
Copy the JWT file generated when running the op-node to the current workspace. Here is a quick command for running op-reth.
162+
Copy the JWT file generated when running the op-node to the current workspace. Here is a quick command for running
163+
op-reth.
114164
The command below is for an archive node. To run a full node, simply add the `--full` tag.
165+
115166
```shell
116167
# for testnet
117168
export network=testnet
@@ -133,7 +184,7 @@ export TRUST_NODES="enode://1a8f2d3160ad6efd6591981c026bd31807b79844422d99107f8f
133184
--http \
134185
--http.addr=0.0.0.0 \
135186
--http.port=8545 \
136-
--http.api="admin, debug, eth, net, trace, txpool, web3, rpc, reth, ots, eth-call-bundle" \
187+
--http.api="eth, net, txpool, web3, rpc" \
137188
--ws \
138189
--ws.addr=0.0.0.0 \
139190
--ws.port=8546 \
@@ -143,7 +194,48 @@ export TRUST_NODES="enode://1a8f2d3160ad6efd6591981c026bd31807b79844422d99107f8f
143194
--log.file.directory ./datadir/logs
144195
```
145196

146-
You can run `op-reth --help` for command explanations. More details on running opbnb nodes can be found [here](https://docs.bnbchain.org/opbnb-docs/docs/tutorials/running-a-local-node/).
197+
You can run `op-reth --help` for command explanations. More details on running opbnb nodes can be
198+
found [here](https://docs.bnbchain.org/opbnb-docs/docs/tutorials/running-a-local-node/).
199+
200+
For running op-reth with docker, please use the following command:
201+
202+
```shell
203+
# for testnet
204+
export network=testnet
205+
export L2_RPC=https://opbnb-testnet-rpc.bnbchain.org
206+
207+
# for mainnet
208+
# export network=mainnet
209+
# export L2_RPC=https://opbnb-mainnet-rpc.bnbchain.org
210+
211+
# check this for version of the docker image, https://github.com/bnb-chain/reth/pkgs/container/op-reth
212+
export version=latest
213+
214+
# the directory where reth data will be stored
215+
export data_dir=/xxx/xxx
216+
217+
# the directory where the jwt.txt file is stored
218+
export jwt_dir=/xxx/xxx
219+
220+
docker run -d -p 8545:8545 -p 8546:8546 -p 30303:30303 -p 30303:30303/udp -v ${data_dir}:/data -v ${jwt_dir}:/jwt \
221+
--name op-reth ghcr.io/bnb-chain/op-reth:${version} node \
222+
--datadir=/data \
223+
--chain=opbnb-${network} \
224+
--rollup.sequencer-http=${L2_RPC} \
225+
--authrpc.addr="0.0.0.0" \
226+
--authrpc.port=8551 \
227+
--authrpc.jwtsecret=/jwt/jwt.txt \
228+
--http \
229+
--http.addr=0.0.0.0 \
230+
--http.port=8545 \
231+
--http.api="eth, net, txpool, web3, rpc" \
232+
--ws \
233+
--ws.addr=0.0.0.0 \
234+
--ws.port=8546 \
235+
--builder.gaslimit=150000000 \
236+
--nat=any \
237+
--log.file.directory /data/logs
238+
```
147239

148240
## Contribution
149241

@@ -152,7 +244,8 @@ from anyone on the internet, and are grateful for even the smallest of fixes!
152244

153245
If you'd like to contribute to bnb chain reth, please fork, fix, commit and send a pull request
154246
for the maintainers to review and merge into the main code base. If you wish to submit
155-
more complex changes though, please check up with the core devs first on [our discord channel](https://discord.gg/bnbchain)
247+
more complex changes though, please check up with the core devs first
248+
on [our discord channel](https://discord.gg/bnbchain)
156249
to ensure those changes are in line with the general philosophy of the project and/or get
157250
some early feedback which can make both your efforts much lighter as well as our review
158251
and merge procedures quick and simple.

crates/bsc/evm/src/execute.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use reth_evm::{
1717
ConfigureEvm,
1818
};
1919
use reth_primitives::{
20+
b256,
2021
parlia::{ParliaConfig, Snapshot, VoteAddress, CHECKPOINT_INTERVAL},
2122
system_contracts::get_upgrade_system_contracts,
2223
Address, BlockNumber, BlockWithSenders, Bytes, Header, Receipt, Transaction, TransactionSigned,
@@ -201,7 +202,20 @@ where
201202
error: err.into(),
202203
}
203204
})?;
204-
205+
if block.number == 35547819 &&
206+
transaction.recalculate_hash() ==
207+
b256!("5ebef67c81a8b0121c081056f10c17a3943eb59f74f53e2c54dc939d0bb06f55")
208+
{
209+
debug!("tx hash: {:?}", transaction.hash());
210+
debug!("tx state: {:?}", state);
211+
}
212+
if block.number == 35547779 &&
213+
transaction.recalculate_hash() ==
214+
b256!("7ce9a3cf77108fcc85c1e84e88e363e3335eca515dfcf2feb2011729878b13a7")
215+
{
216+
debug!("tx hash: {:?}", transaction.hash());
217+
debug!("tx state: {:?}", state);
218+
}
205219
evm.db_mut().commit(state);
206220

207221
// append gas used

crates/bsc/evm/src/post_execution.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use reth_primitives::{
1313
Address, BlockWithSenders, GotExpected, Header, Receipt, TransactionSigned, U256,
1414
};
1515
use reth_provider::ParliaProvider;
16-
use reth_revm::{bsc::SYSTEM_ADDRESS, db::AccountStatus};
16+
use reth_revm::bsc::SYSTEM_ADDRESS;
1717
use revm_primitives::{db::Database, EnvWithHandlerCfg};
1818
use std::collections::HashMap;
1919
use tracing::log::debug;
@@ -269,17 +269,17 @@ where
269269
.state
270270
.load_cache_account(SYSTEM_ADDRESS)
271271
.map_err(|err| BscBlockExecutionError::ProviderInnerError { error: err.into() })?;
272-
if system_account.status == AccountStatus::LoadedNotExisting ||
273-
system_account.status == AccountStatus::DestroyedAgain
274-
{
275-
return Ok(());
276-
}
277-
278272
let (mut block_reward, transition) = system_account.drain_balance();
279-
self.state.apply_transition(vec![(SYSTEM_ADDRESS, transition)]);
280273
if block_reward == 0 {
274+
if header.number == 1 {
275+
// We have to apply the transition to the system account
276+
// even if the block reward is 0
277+
// because the system account is initialized in genesis.
278+
self.state.apply_transition(vec![(SYSTEM_ADDRESS, transition)]);
279+
}
281280
return Ok(());
282281
}
282+
self.state.apply_transition(vec![(SYSTEM_ADDRESS, transition)]);
283283

284284
let mut balance_increment = HashMap::new();
285285
balance_increment.insert(validator, block_reward);

crates/primitives/src/revm/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,16 @@ pub fn revm_spec(chain_spec: &ChainSpec, block: Head) -> revm_primitives::SpecId
112112
} else if chain_spec.fork(Hardfork::Gibbs).active_at_head(&block) {
113113
// bsc mainnet and testnet have different order for Moran, Nano and Gibbs
114114
return if chain_spec.fork(Hardfork::Moran).active_at_head(&block) {
115-
revm_primitives::GIBBS
115+
revm_primitives::MORAN
116116
} else if chain_spec.fork(Hardfork::Nano).active_at_head(&block) {
117117
revm_primitives::NANO
118118
} else {
119119
revm_primitives::EULER
120120
}
121+
} else if chain_spec.fork(Hardfork::Moran).active_at_head(&block) {
122+
return revm_primitives::MORAN
123+
} else if chain_spec.fork(Hardfork::Nano).active_at_head(&block) {
124+
return revm_primitives::NANO
121125
} else if chain_spec.fork(Hardfork::Euler).active_at_head(&block) {
122126
return revm_primitives::EULER
123127
} else if chain_spec.fork(Hardfork::Bruno).active_at_head(&block) {

crates/storage/provider/src/bundle_state/bundle_state_with_receipts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl StateWriter for ExecutionOutcome {
6262
if !self.snapshots.is_empty() {
6363
let mut snapshot_cursor = tx.cursor_write::<tables::ParliaSnapshot>()?;
6464
for snap in self.snapshots {
65-
snapshot_cursor.insert(snap.block_hash, snap)?;
65+
snapshot_cursor.upsert(snap.block_hash, snap)?;
6666
}
6767
}
6868

op.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ FROM ubuntu AS runtime
4343
WORKDIR /app
4444

4545
# Copy reth over from the build stage
46-
COPY --from=builder /app/bsc-reth /usr/local/bin
46+
COPY --from=builder /app/op-reth /usr/local/bin
4747

4848
# Copy licenses
4949
COPY LICENSE-* ./

0 commit comments

Comments
 (0)