Compare commits
84 Commits
stale-peer
...
txpool-new
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60bdc2539e | ||
|
|
0dd0bd7b38 | ||
|
|
f41bb13160 | ||
|
|
0e67514ee7 | ||
|
|
8170d99b2f | ||
|
|
7a929d6324 | ||
|
|
00a36bb0cc | ||
|
|
3a6dbe4d85 | ||
|
|
72ec06eae7 | ||
|
|
55896bf610 | ||
|
|
5d44ba9c6a | ||
|
|
bff9d252d6 | ||
|
|
9c72c02502 | ||
|
|
a8959fe60e | ||
|
|
31c9465eac | ||
|
|
4e69ac4a0f | ||
|
|
d5b10e09a7 | ||
|
|
1ad40cda3f | ||
|
|
355dee9000 | ||
|
|
6a6e09c849 | ||
|
|
846e55b9a4 | ||
|
|
09575625db | ||
|
|
27f67a5210 | ||
|
|
8c1acb0b22 | ||
|
|
3e3c56b235 | ||
|
|
089064c1ff | ||
|
|
629af6dab4 | ||
|
|
774e314096 | ||
|
|
5289ecdfe2 | ||
|
|
d141ff06c3 | ||
|
|
9cbac84363 | ||
|
|
21faa2de3f | ||
|
|
34059cb144 | ||
|
|
3e44dcaa55 | ||
|
|
b818cb78db | ||
|
|
282aee5856 | ||
|
|
44e91bba23 | ||
|
|
cf10c5cfe6 | ||
|
|
248bb6b0d6 | ||
|
|
774d1b7ddb | ||
|
|
8bbd8fbf48 | ||
|
|
a28262b3ec | ||
|
|
7de27ca9e9 | ||
|
|
0a5dbef9f4 | ||
|
|
0e61543954 | ||
|
|
03069a7703 | ||
|
|
24a46de5b2 | ||
|
|
706a24eb2c | ||
|
|
5f398db90a | ||
|
|
8e6833cec4 | ||
|
|
53042e15d7 | ||
|
|
aeec0c7129 | ||
|
|
76d157d08b | ||
|
|
0f8a1b5c5a | ||
|
|
16a2a53635 | ||
|
|
e7d0a16bc4 | ||
|
|
70ece9355a | ||
|
|
069eaf22f7 | ||
|
|
e45e7eb9c6 | ||
|
|
bdb4cc2acd | ||
|
|
ebd8f590a3 | ||
|
|
6673f3e75a | ||
|
|
40dcfcd776 | ||
|
|
0692a99ea9 | ||
|
|
75af65dbf2 | ||
|
|
253d9a566b | ||
|
|
a1a25e91a4 | ||
|
|
9d7298f0c1 | ||
|
|
6daecfb105 | ||
|
|
ed2d1d7f8f | ||
|
|
94a60a9006 | ||
|
|
d03f7e5e94 | ||
|
|
6b4e16ba7b | ||
|
|
5bb78b34be | ||
|
|
26a4d4fda6 | ||
|
|
5faf41359a | ||
|
|
d0d6a272f0 | ||
|
|
4369e3d997 | ||
|
|
4538e92dbb | ||
|
|
8655d30cb9 | ||
|
|
f80ac01c95 | ||
|
|
e30248be3a | ||
|
|
83a9b13771 | ||
|
|
dfb046e852 |
8
.github/workflows/pre-release.yml
vendored
8
.github/workflows/pre-release.yml
vendored
@@ -82,28 +82,28 @@ jobs:
|
|||||||
# ==============================
|
# ==============================
|
||||||
|
|
||||||
- name: Upload Linux Build
|
- name: Upload Linux Build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4.3.3
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
with:
|
with:
|
||||||
name: linux
|
name: linux
|
||||||
path: ./build/bin/geth
|
path: ./build/bin/geth
|
||||||
|
|
||||||
- name: Upload MacOS Build
|
- name: Upload MacOS Build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4.3.3
|
||||||
if: matrix.os == 'macos-latest'
|
if: matrix.os == 'macos-latest'
|
||||||
with:
|
with:
|
||||||
name: macos
|
name: macos
|
||||||
path: ./build/bin/geth
|
path: ./build/bin/geth
|
||||||
|
|
||||||
- name: Upload Windows Build
|
- name: Upload Windows Build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4.3.3
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
with:
|
with:
|
||||||
name: windows
|
name: windows
|
||||||
path: ./build/bin/geth.exe
|
path: ./build/bin/geth.exe
|
||||||
|
|
||||||
- name: Upload ARM-64 Build
|
- name: Upload ARM-64 Build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4.3.3
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
with:
|
with:
|
||||||
name: arm64
|
name: arm64
|
||||||
|
|||||||
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -81,28 +81,28 @@ jobs:
|
|||||||
# ==============================
|
# ==============================
|
||||||
|
|
||||||
- name: Upload Linux Build
|
- name: Upload Linux Build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4.3.3
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
with:
|
with:
|
||||||
name: linux
|
name: linux
|
||||||
path: ./build/bin/geth
|
path: ./build/bin/geth
|
||||||
|
|
||||||
- name: Upload MacOS Build
|
- name: Upload MacOS Build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4.3.3
|
||||||
if: matrix.os == 'macos-latest'
|
if: matrix.os == 'macos-latest'
|
||||||
with:
|
with:
|
||||||
name: macos
|
name: macos
|
||||||
path: ./build/bin/geth
|
path: ./build/bin/geth
|
||||||
|
|
||||||
- name: Upload Windows Build
|
- name: Upload Windows Build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4.3.3
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
with:
|
with:
|
||||||
name: windows
|
name: windows
|
||||||
path: ./build/bin/geth.exe
|
path: ./build/bin/geth.exe
|
||||||
|
|
||||||
- name: Upload ARM-64 Build
|
- name: Upload ARM-64 Build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4.3.3
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
with:
|
with:
|
||||||
name: arm64
|
name: arm64
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
CVE-2024-34478 # "CWE-754: Improper Check for Unusual or Exceptional Conditions." This vulnerability is BTC only, BSC does not have the issue.
|
CVE-2024-34478 # "CWE-754: Improper Check for Unusual or Exceptional Conditions." This vulnerability is BTC only, BSC does not have the issue.
|
||||||
CVE-2024-6104 # "CWE-532: Information Exposure Through Log Files" This is caused by the vulnerabilities go-retryablehttp@v0.7.4, it is only used in cmd devp2p, impact is limited. will upgrade to v0.7.7 later
|
CVE-2024-6104 # "CWE-532: Information Exposure Through Log Files" This is caused by the vulnerabilities go-retryablehttp@v0.7.4, it is only used in cmd devp2p, impact is limited. will upgrade to v0.7.7 later
|
||||||
|
CVE-2024-8421 # "CWE-400: Uncontrolled Resource Consumption (Resource Exhaustion)" This vulnerability is caused by issues in the golang.org/x/net package. Even the latest version(v0.29.0) has not yet addressed it, but we will continue to monitor updates closely.
|
||||||
22
CHANGELOG.md
22
CHANGELOG.md
@@ -1,4 +1,26 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
## v1.4.15
|
||||||
|
### BUGFIX
|
||||||
|
* [\#2680](https://github.com/bnb-chain/bsc/pull/2680) txpool: apply miner's gasceil to txpool
|
||||||
|
* [\#2688](https://github.com/bnb-chain/bsc/pull/2688) txpool: set default GasCeil from 30M to 0
|
||||||
|
* [\#2696](https://github.com/bnb-chain/bsc/pull/2696) miner: limit block size to eth protocol msg size
|
||||||
|
* [\#2684](https://github.com/bnb-chain/bsc/pull/2684) eth: Add sidecars when available to broadcasted current block
|
||||||
|
|
||||||
|
### FEATURE
|
||||||
|
* [\#2672](https://github.com/bnb-chain/bsc/pull/2672) faucet: with mainnet balance check, 0.002BNB at least
|
||||||
|
* [\#2678](https://github.com/bnb-chain/bsc/pull/2678) beaconserver: simulated beacon api server for op-stack
|
||||||
|
* [\#2687](https://github.com/bnb-chain/bsc/pull/2687) faucet: support customized token
|
||||||
|
* [\#2698](https://github.com/bnb-chain/bsc/pull/2698) faucet: add example for custimized token
|
||||||
|
* [\#2706](https://github.com/bnb-chain/bsc/pull/2706) faucet: update DIN token faucet support
|
||||||
|
|
||||||
|
### IMPROVEMENT
|
||||||
|
* [\#2677](https://github.com/bnb-chain/bsc/pull/2677) log: add some p2p log
|
||||||
|
* [\#2679](https://github.com/bnb-chain/bsc/pull/2679) build(deps): bump actions/download-artifact in /.github/workflows
|
||||||
|
* [\#2662](https://github.com/bnb-chain/bsc/pull/2662) metrics: add some extra feature flags as node stats
|
||||||
|
* [\#2675](https://github.com/bnb-chain/bsc/pull/2675) fetcher: Sleep after marking block as done when requeuing
|
||||||
|
* [\#2695](https://github.com/bnb-chain/bsc/pull/2695) CI: nancy ignore CVE-2024-8421
|
||||||
|
* [\#2689](https://github.com/bnb-chain/bsc/pull/2689) consensus/parlia: wait more time when processing huge blocks
|
||||||
|
|
||||||
## v1.4.14
|
## v1.4.14
|
||||||
|
|
||||||
### BUGFIX
|
### BUGFIX
|
||||||
|
|||||||
24
README.md
24
README.md
@@ -11,14 +11,13 @@ https://pkg.go.dev/badge/github.com/ethereum/go-ethereum
|
|||||||
|
|
||||||
But from that baseline of EVM compatible, BNB Smart Chain introduces a system of 21 validators with Proof of Staked Authority (PoSA) consensus that can support short block time and lower fees. The most bonded validator candidates of staking will become validators and produce blocks. The double-sign detection and other slashing logic guarantee security, stability, and chain finality.
|
But from that baseline of EVM compatible, BNB Smart Chain introduces a system of 21 validators with Proof of Staked Authority (PoSA) consensus that can support short block time and lower fees. The most bonded validator candidates of staking will become validators and produce blocks. The double-sign detection and other slashing logic guarantee security, stability, and chain finality.
|
||||||
|
|
||||||
Cross-chain transfer and other communication are possible due to native support of interoperability. Relayers and on-chain contracts are developed to support that. BNB Beacon Chain DEX remains a liquid venue of the exchange of assets on both chains. This dual-chain architecture will be ideal for users to take advantage of the fast trading on one side and build their decentralized apps on the other side. **The BNB Smart Chain** will be:
|
**The BNB Smart Chain** will be:
|
||||||
|
|
||||||
- **A self-sovereign blockchain**: Provides security and safety with elected validators.
|
- **A self-sovereign blockchain**: Provides security and safety with elected validators.
|
||||||
- **EVM-compatible**: Supports all the existing Ethereum tooling along with faster finality and cheaper transaction fees.
|
- **EVM-compatible**: Supports all the existing Ethereum tooling along with faster finality and cheaper transaction fees.
|
||||||
- **Interoperable**: Comes with efficient native dual chain communication; Optimized for scaling high-performance dApps that require fast and smooth user experience.
|
|
||||||
- **Distributed with on-chain governance**: Proof of Staked Authority brings in decentralization and community participants. As the native token, BNB will serve as both the gas of smart contract execution and tokens for staking.
|
- **Distributed with on-chain governance**: Proof of Staked Authority brings in decentralization and community participants. As the native token, BNB will serve as both the gas of smart contract execution and tokens for staking.
|
||||||
|
|
||||||
More details in [White Paper](https://www.bnbchain.org/en#smartChain).
|
More details in [White Paper](https://github.com/bnb-chain/whitepaper/blob/master/WHITEPAPER.md).
|
||||||
|
|
||||||
## Key features
|
## Key features
|
||||||
|
|
||||||
@@ -34,18 +33,8 @@ To combine DPoS and PoA for consensus, BNB Smart Chain implement a novel consens
|
|||||||
|
|
||||||
1. Blocks are produced by a limited set of validators.
|
1. Blocks are produced by a limited set of validators.
|
||||||
2. Validators take turns to produce blocks in a PoA manner, similar to Ethereum's Clique consensus engine.
|
2. Validators take turns to produce blocks in a PoA manner, similar to Ethereum's Clique consensus engine.
|
||||||
3. Validator set are elected in and out based on a staking based governance on BNB Beacon Chain.
|
3. Validator set are elected in and out based on a staking based governance on BNB Smart Chain.
|
||||||
4. The validator set change is relayed via a cross-chain communication mechanism.
|
4. Parlia consensus engine will interact with a set of [system contracts](https://docs.bnbchain.org/bnb-smart-chain/staking/overview/#system-contracts) to achieve liveness slash, revenue distributing and validator set renewing func.
|
||||||
5. Parlia consensus engine will interact with a set of [system contracts](https://docs.bnbchain.org/bnb-smart-chain/staking/overview/#system-contracts) to achieve liveness slash, revenue distributing and validator set renewing func.
|
|
||||||
|
|
||||||
|
|
||||||
### Light Client of BNB Beacon Chain
|
|
||||||
|
|
||||||
To achieve the cross-chain communication from BNB Beacon Chain to BNB Smart Chain, need introduce a on-chain light client verification algorithm.
|
|
||||||
It contains two parts:
|
|
||||||
|
|
||||||
1. [Stateless Precompiled contracts](https://github.com/bnb-chain/bsc/blob/master/core/vm/contracts_lightclient.go) to do tendermint header verification and Merkle Proof verification.
|
|
||||||
2. [Stateful solidity contracts](https://github.com/bnb-chain/bsc-genesis-contract/blob/master/contracts/TendermintLightClient.sol) to store validator set and trusted appHash.
|
|
||||||
|
|
||||||
## Native Token
|
## Native Token
|
||||||
|
|
||||||
@@ -53,7 +42,6 @@ BNB will run on BNB Smart Chain in the same way as ETH runs on Ethereum so that
|
|||||||
BNB will be used to:
|
BNB will be used to:
|
||||||
|
|
||||||
1. pay `gas` to deploy or invoke Smart Contract on BSC
|
1. pay `gas` to deploy or invoke Smart Contract on BSC
|
||||||
2. perform cross-chain operations, such as transfer token assets across BNB Smart Chain and BNB Beacon Chain.
|
|
||||||
|
|
||||||
## Building the source
|
## Building the source
|
||||||
|
|
||||||
@@ -247,9 +235,7 @@ running web servers, so malicious web pages could try to subvert locally availab
|
|||||||
APIs!**
|
APIs!**
|
||||||
|
|
||||||
### Operating a private network
|
### Operating a private network
|
||||||
- [BSC-Deploy](https://github.com/bnb-chain/node-deploy/): deploy tool for setting up both BNB Beacon Chain, BNB Smart Chain and the cross chain infrastructure between them.
|
- [BSC-Deploy](https://github.com/bnb-chain/node-deploy/): deploy tool for setting up BNB Smart Chain.
|
||||||
- [BSC-Docker](https://github.com/bnb-chain/bsc-docker): deploy tool for setting up local BSC cluster in container.
|
|
||||||
|
|
||||||
|
|
||||||
## Running a bootnode
|
## Running a bootnode
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -101,7 +100,7 @@ type ContractTransactor interface {
|
|||||||
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
|
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
|
||||||
|
|
||||||
// SendTransactionConditional injects the conditional transaction into the pending pool for execution after verification.
|
// SendTransactionConditional injects the conditional transaction into the pending pool for execution after verification.
|
||||||
SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts ethapi.TransactionOpts) error
|
SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts types.TransactionOpts) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeployBackend wraps the operations needed by WaitMined and WaitDeployed.
|
// DeployBackend wraps the operations needed by WaitMined and WaitDeployed.
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@@ -76,7 +75,7 @@ func (mt *mockTransactor) SendTransaction(ctx context.Context, tx *types.Transac
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mt *mockTransactor) SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts ethapi.TransactionOpts) error {
|
func (mt *mockTransactor) SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts types.TransactionOpts) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
cmd/faucet/customized/DIN.png
Normal file
BIN
cmd/faucet/customized/DIN.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
23
cmd/faucet/customized/README.md
Normal file
23
cmd/faucet/customized/README.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# 1.Background
|
||||||
|
This is to support some projects with customized tokens that they want to integrate into the BSC faucet tool.
|
||||||
|
|
||||||
|
## 1.1. How to Integrate Your Token
|
||||||
|
- Step 1: Fund the faucet address by sending a specific amount of your BEP-20 token to the faucet address (0xaa25aa7a19f9c426e07dee59b12f944f4d9f1dd3) on the BSC testnet.
|
||||||
|
- Step 2: Update this README.md file and create a Pull Request on [bsc github](https://github.com/bnb-chain/bsc) with relevant information.
|
||||||
|
|
||||||
|
We will review the request, and once it is approved, the faucet tool will start to support the customized token and list it on https://www.bnbchain.org/en/testnet-faucet.
|
||||||
|
|
||||||
|
# 2.Token List
|
||||||
|
## 2.1.DemoToken
|
||||||
|
- symbol: DEMO
|
||||||
|
- amount: 10000000000000000000
|
||||||
|
- icon: ./demotoken.png
|
||||||
|
- addr: https://testnet.bscscan.com/address/0xe15c158d768c306dae87b96430a94f884333e55d
|
||||||
|
- fundTx: [0xa499dc9aaf918aff0507538a8aa80a88d0af6ca15054e6acc57b69c651945280](https://testnet.bscscan.com/tx/0x2a3f334b6ca756b64331bdec9e6cf3207ac50a4839fda6379e909de4d9a194ca)
|
||||||
|
-
|
||||||
|
## 2.2.DIN token
|
||||||
|
- symbol: DIN
|
||||||
|
- amount: 10000000000000000000
|
||||||
|
- icon: ./DIN.png
|
||||||
|
- addr: https://testnet.bscscan.com/address/0xb8b40FcC5B4519Dba0E07Ac8821884CE90BdE677
|
||||||
|
- fundTx: [0x17fc4c1db133830c7c146a0d41ca1df31cb446989ec11b382d58bb6176d6fde3](https://testnet.bscscan.com/tx/0x17fc4c1db133830c7c146a0d41ca1df31cb446989ec11b382d58bb6176d6fde3)
|
||||||
BIN
cmd/faucet/customized/demotoken.png
Normal file
BIN
cmd/faucet/customized/demotoken.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
@@ -500,7 +500,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// check #2: check IP and ID(address) to ensure the user didn't request funds too recently,
|
// check #2: check IP and ID(address) to ensure the user didn't request funds too frequently
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
|
|
||||||
if ipTimeout := f.timeouts[ips[len(ips)-2]]; time.Now().Before(ipTimeout) {
|
if ipTimeout := f.timeouts[ips[len(ips)-2]]; time.Now().Before(ipTimeout) {
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ var (
|
|||||||
Flags: flags.Merge([]cli.Flag{
|
Flags: flags.Merge([]cli.Flag{
|
||||||
utils.CachePreimagesFlag,
|
utils.CachePreimagesFlag,
|
||||||
utils.OverridePassedForkTime,
|
utils.OverridePassedForkTime,
|
||||||
utils.OverrideBohr,
|
utils.OverridePascal,
|
||||||
|
utils.OverridePrague,
|
||||||
utils.OverrideVerkle,
|
utils.OverrideVerkle,
|
||||||
utils.MultiDataBaseFlag,
|
utils.MultiDataBaseFlag,
|
||||||
}, utils.DatabaseFlags),
|
}, utils.DatabaseFlags),
|
||||||
@@ -258,9 +259,13 @@ func initGenesis(ctx *cli.Context) error {
|
|||||||
v := ctx.Uint64(utils.OverridePassedForkTime.Name)
|
v := ctx.Uint64(utils.OverridePassedForkTime.Name)
|
||||||
overrides.OverridePassedForkTime = &v
|
overrides.OverridePassedForkTime = &v
|
||||||
}
|
}
|
||||||
if ctx.IsSet(utils.OverrideBohr.Name) {
|
if ctx.IsSet(utils.OverridePascal.Name) {
|
||||||
v := ctx.Uint64(utils.OverrideBohr.Name)
|
v := ctx.Uint64(utils.OverridePascal.Name)
|
||||||
overrides.OverrideBohr = &v
|
overrides.OverridePascal = &v
|
||||||
|
}
|
||||||
|
if ctx.IsSet(utils.OverridePrague.Name) {
|
||||||
|
v := ctx.Uint64(utils.OverridePrague.Name)
|
||||||
|
overrides.OverridePrague = &v
|
||||||
}
|
}
|
||||||
if ctx.IsSet(utils.OverrideVerkle.Name) {
|
if ctx.IsSet(utils.OverrideVerkle.Name) {
|
||||||
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
||||||
|
|||||||
@@ -191,9 +191,13 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
|
|||||||
v := ctx.Uint64(utils.OverridePassedForkTime.Name)
|
v := ctx.Uint64(utils.OverridePassedForkTime.Name)
|
||||||
cfg.Eth.OverridePassedForkTime = &v
|
cfg.Eth.OverridePassedForkTime = &v
|
||||||
}
|
}
|
||||||
if ctx.IsSet(utils.OverrideBohr.Name) {
|
if ctx.IsSet(utils.OverridePascal.Name) {
|
||||||
v := ctx.Uint64(utils.OverrideBohr.Name)
|
v := ctx.Uint64(utils.OverridePascal.Name)
|
||||||
cfg.Eth.OverrideBohr = &v
|
cfg.Eth.OverridePascal = &v
|
||||||
|
}
|
||||||
|
if ctx.IsSet(utils.OverridePrague.Name) {
|
||||||
|
v := ctx.Uint64(utils.OverridePrague.Name)
|
||||||
|
cfg.Eth.OverridePrague = &v
|
||||||
}
|
}
|
||||||
if ctx.IsSet(utils.OverrideVerkle.Name) {
|
if ctx.IsSet(utils.OverrideVerkle.Name) {
|
||||||
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ var (
|
|||||||
utils.SmartCardDaemonPathFlag,
|
utils.SmartCardDaemonPathFlag,
|
||||||
utils.RialtoHash,
|
utils.RialtoHash,
|
||||||
utils.OverridePassedForkTime,
|
utils.OverridePassedForkTime,
|
||||||
utils.OverrideBohr,
|
utils.OverridePascal,
|
||||||
|
utils.OverridePrague,
|
||||||
utils.OverrideVerkle,
|
utils.OverrideVerkle,
|
||||||
utils.OverrideFullImmutabilityThreshold,
|
utils.OverrideFullImmutabilityThreshold,
|
||||||
utils.OverrideMinBlocksForBlobRequests,
|
utils.OverrideMinBlocksForBlobRequests,
|
||||||
@@ -91,6 +92,7 @@ var (
|
|||||||
utils.TxPoolGlobalSlotsFlag,
|
utils.TxPoolGlobalSlotsFlag,
|
||||||
utils.TxPoolAccountQueueFlag,
|
utils.TxPoolAccountQueueFlag,
|
||||||
utils.TxPoolGlobalQueueFlag,
|
utils.TxPoolGlobalQueueFlag,
|
||||||
|
utils.TxPoolOverflowPoolSlotsFlag,
|
||||||
utils.TxPoolLifetimeFlag,
|
utils.TxPoolLifetimeFlag,
|
||||||
utils.TxPoolReannounceTimeFlag,
|
utils.TxPoolReannounceTimeFlag,
|
||||||
utils.BlobPoolDataDirFlag,
|
utils.BlobPoolDataDirFlag,
|
||||||
|
|||||||
@@ -310,12 +310,17 @@ var (
|
|||||||
}
|
}
|
||||||
OverridePassedForkTime = &cli.Uint64Flag{
|
OverridePassedForkTime = &cli.Uint64Flag{
|
||||||
Name: "override.passedforktime",
|
Name: "override.passedforktime",
|
||||||
Usage: "Manually specify the hard fork timestamp except the last one, overriding the bundled setting",
|
Usage: "Manually specify the hard fork timestamps which have passed on the mainnet, overriding the bundled setting",
|
||||||
Category: flags.EthCategory,
|
Category: flags.EthCategory,
|
||||||
}
|
}
|
||||||
OverrideBohr = &cli.Uint64Flag{
|
OverridePascal = &cli.Uint64Flag{
|
||||||
Name: "override.bohr",
|
Name: "override.pascal",
|
||||||
Usage: "Manually specify the Bohr fork timestamp, overriding the bundled setting",
|
Usage: "Manually specify the Pascal fork timestamp, overriding the bundled setting",
|
||||||
|
Category: flags.EthCategory,
|
||||||
|
}
|
||||||
|
OverridePrague = &cli.Uint64Flag{
|
||||||
|
Name: "override.prague",
|
||||||
|
Usage: "Manually specify the Prague fork timestamp, overriding the bundled setting",
|
||||||
Category: flags.EthCategory,
|
Category: flags.EthCategory,
|
||||||
}
|
}
|
||||||
OverrideVerkle = &cli.Uint64Flag{
|
OverrideVerkle = &cli.Uint64Flag{
|
||||||
@@ -453,6 +458,12 @@ var (
|
|||||||
Value: ethconfig.Defaults.TxPool.GlobalQueue,
|
Value: ethconfig.Defaults.TxPool.GlobalQueue,
|
||||||
Category: flags.TxPoolCategory,
|
Category: flags.TxPoolCategory,
|
||||||
}
|
}
|
||||||
|
TxPoolOverflowPoolSlotsFlag = &cli.Uint64Flag{
|
||||||
|
Name: "txpool.overflowpoolslots",
|
||||||
|
Usage: "Maximum number of transaction slots in overflow pool",
|
||||||
|
Value: ethconfig.Defaults.TxPool.OverflowPoolSlots,
|
||||||
|
Category: flags.TxPoolCategory,
|
||||||
|
}
|
||||||
TxPoolLifetimeFlag = &cli.DurationFlag{
|
TxPoolLifetimeFlag = &cli.DurationFlag{
|
||||||
Name: "txpool.lifetime",
|
Name: "txpool.lifetime",
|
||||||
Usage: "Maximum amount of time non-executable transaction are queued",
|
Usage: "Maximum amount of time non-executable transaction are queued",
|
||||||
@@ -1784,6 +1795,9 @@ func setTxPool(ctx *cli.Context, cfg *legacypool.Config) {
|
|||||||
if ctx.IsSet(TxPoolGlobalQueueFlag.Name) {
|
if ctx.IsSet(TxPoolGlobalQueueFlag.Name) {
|
||||||
cfg.GlobalQueue = ctx.Uint64(TxPoolGlobalQueueFlag.Name)
|
cfg.GlobalQueue = ctx.Uint64(TxPoolGlobalQueueFlag.Name)
|
||||||
}
|
}
|
||||||
|
if ctx.IsSet(TxPoolOverflowPoolSlotsFlag.Name) {
|
||||||
|
cfg.OverflowPoolSlots = ctx.Uint64(TxPoolOverflowPoolSlotsFlag.Name)
|
||||||
|
}
|
||||||
if ctx.IsSet(TxPoolLifetimeFlag.Name) {
|
if ctx.IsSet(TxPoolLifetimeFlag.Name) {
|
||||||
cfg.Lifetime = ctx.Duration(TxPoolLifetimeFlag.Name)
|
cfg.Lifetime = ctx.Duration(TxPoolLifetimeFlag.Name)
|
||||||
}
|
}
|
||||||
@@ -2314,6 +2328,7 @@ func EnableNodeInfo(poolConfig *legacypool.Config, nodeInfo *p2p.NodeInfo) Setup
|
|||||||
"GlobalSlots": poolConfig.GlobalSlots,
|
"GlobalSlots": poolConfig.GlobalSlots,
|
||||||
"AccountQueue": poolConfig.AccountQueue,
|
"AccountQueue": poolConfig.AccountQueue,
|
||||||
"GlobalQueue": poolConfig.GlobalQueue,
|
"GlobalQueue": poolConfig.GlobalQueue,
|
||||||
|
"OverflowPoolSlots": poolConfig.OverflowPoolSlots,
|
||||||
"Lifetime": poolConfig.Lifetime,
|
"Lifetime": poolConfig.Lifetime,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ const (
|
|||||||
|
|
||||||
wiggleTime = uint64(1) // second, Random delay (per signer) to allow concurrent signers
|
wiggleTime = uint64(1) // second, Random delay (per signer) to allow concurrent signers
|
||||||
initialBackOffTime = uint64(1) // second
|
initialBackOffTime = uint64(1) // second
|
||||||
processBackOffTime = uint64(1) // second
|
|
||||||
|
|
||||||
systemRewardPercent = 4 // it means 1/2^4 = 1/16 percentage of gas fee incoming will be distributed to system
|
systemRewardPercent = 4 // it means 1/2^4 = 1/16 percentage of gas fee incoming will be distributed to system
|
||||||
|
|
||||||
@@ -1616,12 +1615,15 @@ func (p *Parlia) Seal(chain consensus.ChainHeaderReader, block *types.Block, res
|
|||||||
copy(header.Extra[len(header.Extra)-extraSeal:], sig)
|
copy(header.Extra[len(header.Extra)-extraSeal:], sig)
|
||||||
|
|
||||||
if p.shouldWaitForCurrentBlockProcess(chain, header, snap) {
|
if p.shouldWaitForCurrentBlockProcess(chain, header, snap) {
|
||||||
log.Info("Waiting for received in turn block to process")
|
highestVerifiedHeader := chain.GetHighestVerifiedHeader()
|
||||||
|
// including time for writing and committing blocks
|
||||||
|
waitProcessEstimate := math.Ceil(float64(highestVerifiedHeader.GasUsed) / float64(100_000_000))
|
||||||
|
log.Info("Waiting for received in turn block to process", "waitProcessEstimate(Seconds)", waitProcessEstimate)
|
||||||
select {
|
select {
|
||||||
case <-stop:
|
case <-stop:
|
||||||
log.Info("Received block process finished, abort block seal")
|
log.Info("Received block process finished, abort block seal")
|
||||||
return
|
return
|
||||||
case <-time.After(time.Duration(processBackOffTime) * time.Second):
|
case <-time.After(time.Duration(waitProcessEstimate) * time.Second):
|
||||||
if chain.CurrentHeader().Number.Uint64() >= header.Number.Uint64() {
|
if chain.CurrentHeader().Number.Uint64() >= header.Number.Uint64() {
|
||||||
log.Info("Process backoff time exhausted, and current header has updated to abort this seal")
|
log.Info("Process backoff time exhausted, and current header has updated to abort this seal")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -66,31 +66,6 @@ func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain, engin
|
|||||||
return validator
|
return validator
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateListsInBody validates that UncleHash, WithdrawalsHash, and WithdrawalsHash correspond to the lists in the block body, respectively.
|
|
||||||
func ValidateListsInBody(block *types.Block) error {
|
|
||||||
header := block.Header()
|
|
||||||
if hash := types.CalcUncleHash(block.Uncles()); hash != header.UncleHash {
|
|
||||||
return fmt.Errorf("uncle root hash mismatch (header value %x, calculated %x)", header.UncleHash, hash)
|
|
||||||
}
|
|
||||||
if hash := types.DeriveSha(block.Transactions(), trie.NewStackTrie(nil)); hash != header.TxHash {
|
|
||||||
return fmt.Errorf("transaction root hash mismatch: have %x, want %x", hash, header.TxHash)
|
|
||||||
}
|
|
||||||
// Withdrawals are present after the Shanghai fork.
|
|
||||||
if header.WithdrawalsHash != nil {
|
|
||||||
// Withdrawals list must be present in body after Shanghai.
|
|
||||||
if block.Withdrawals() == nil {
|
|
||||||
return errors.New("missing withdrawals in block body")
|
|
||||||
}
|
|
||||||
if hash := types.DeriveSha(block.Withdrawals(), trie.NewStackTrie(nil)); hash != *header.WithdrawalsHash {
|
|
||||||
return fmt.Errorf("withdrawals root hash mismatch (header value %x, calculated %x)", *header.WithdrawalsHash, hash)
|
|
||||||
}
|
|
||||||
} else if block.Withdrawals() != nil { // Withdrawals turn into empty from nil when BlockBody has Sidecars
|
|
||||||
// Withdrawals are not allowed prior to shanghai fork
|
|
||||||
return errors.New("withdrawals present in block body")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidateBody validates the given block's uncles and verifies the block
|
// ValidateBody validates the given block's uncles and verifies the block
|
||||||
// header's transaction and uncle roots. The headers are assumed to be already
|
// header's transaction and uncle roots. The headers are assumed to be already
|
||||||
// validated at this point.
|
// validated at this point.
|
||||||
@@ -108,12 +83,31 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
|||||||
if err := v.engine.VerifyUncles(v.bc, block); err != nil {
|
if err := v.engine.VerifyUncles(v.bc, block); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if hash := types.CalcUncleHash(block.Uncles()); hash != header.UncleHash {
|
||||||
|
return fmt.Errorf("uncle root hash mismatch (header value %x, calculated %x)", header.UncleHash, hash)
|
||||||
|
}
|
||||||
|
|
||||||
validateFuns := []func() error{
|
validateFuns := []func() error{
|
||||||
func() error {
|
func() error {
|
||||||
return ValidateListsInBody(block)
|
if hash := types.DeriveSha(block.Transactions(), trie.NewStackTrie(nil)); hash != header.TxHash {
|
||||||
|
return fmt.Errorf("transaction root hash mismatch: have %x, want %x", hash, header.TxHash)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
func() error {
|
func() error {
|
||||||
|
// Withdrawals are present after the Shanghai fork.
|
||||||
|
if header.WithdrawalsHash != nil {
|
||||||
|
// Withdrawals list must be present in body after Shanghai.
|
||||||
|
if block.Withdrawals() == nil {
|
||||||
|
return errors.New("missing withdrawals in block body")
|
||||||
|
}
|
||||||
|
if hash := types.DeriveSha(block.Withdrawals(), trie.NewStackTrie(nil)); hash != *header.WithdrawalsHash {
|
||||||
|
return fmt.Errorf("withdrawals root hash mismatch (header value %x, calculated %x)", *header.WithdrawalsHash, hash)
|
||||||
|
}
|
||||||
|
} else if block.Withdrawals() != nil { // Withdrawals turn into empty from nil when BlockBody has Sidecars
|
||||||
|
// Withdrawals are not allowed prior to shanghai fork
|
||||||
|
return errors.New("withdrawals present in block body")
|
||||||
|
}
|
||||||
// Blob transactions may be present after the Cancun fork.
|
// Blob transactions may be present after the Cancun fork.
|
||||||
var blobs int
|
var blobs int
|
||||||
for i, tx := range block.Transactions() {
|
for i, tx := range block.Transactions() {
|
||||||
|
|||||||
@@ -217,7 +217,8 @@ func (e *GenesisMismatchError) Error() string {
|
|||||||
// Typically, these modifications involve hardforks that are not enabled on the BSC mainnet, intended for testing purposes.
|
// Typically, these modifications involve hardforks that are not enabled on the BSC mainnet, intended for testing purposes.
|
||||||
type ChainOverrides struct {
|
type ChainOverrides struct {
|
||||||
OverridePassedForkTime *uint64
|
OverridePassedForkTime *uint64
|
||||||
OverrideBohr *uint64
|
OverridePascal *uint64
|
||||||
|
OverridePrague *uint64
|
||||||
OverrideVerkle *uint64
|
OverrideVerkle *uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,9 +253,13 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
|
|||||||
config.CancunTime = overrides.OverridePassedForkTime
|
config.CancunTime = overrides.OverridePassedForkTime
|
||||||
config.HaberTime = overrides.OverridePassedForkTime
|
config.HaberTime = overrides.OverridePassedForkTime
|
||||||
config.HaberFixTime = overrides.OverridePassedForkTime
|
config.HaberFixTime = overrides.OverridePassedForkTime
|
||||||
|
config.BohrTime = overrides.OverridePassedForkTime
|
||||||
}
|
}
|
||||||
if overrides != nil && overrides.OverrideBohr != nil {
|
if overrides != nil && overrides.OverridePascal != nil {
|
||||||
config.BohrTime = overrides.OverrideBohr
|
config.PascalTime = overrides.OverridePascal
|
||||||
|
}
|
||||||
|
if overrides != nil && overrides.OverridePrague != nil {
|
||||||
|
config.PragueTime = overrides.OverridePrague
|
||||||
}
|
}
|
||||||
if overrides != nil && overrides.OverrideVerkle != nil {
|
if overrides != nil && overrides.OverrideVerkle != nil {
|
||||||
config.VerkleTime = overrides.OverrideVerkle
|
config.VerkleTime = overrides.OverrideVerkle
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -17,11 +17,3 @@ var (
|
|||||||
//go:embed chapel/StakeHubContract
|
//go:embed chapel/StakeHubContract
|
||||||
ChapelStakeHubContract string
|
ChapelStakeHubContract string
|
||||||
)
|
)
|
||||||
|
|
||||||
// contract codes for Rialto upgrade
|
|
||||||
var (
|
|
||||||
//go:embed rialto/ValidatorContract
|
|
||||||
RialtoValidatorContract string
|
|
||||||
//go:embed rialto/StakeHubContract
|
|
||||||
RialtoStakeHubContract string
|
|
||||||
)
|
|
||||||
|
|||||||
1
core/systemcontracts/pascal/chapel/CrossChainContract
Normal file
1
core/systemcontracts/pascal/chapel/CrossChainContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/GovHubContract
Normal file
1
core/systemcontracts/pascal/chapel/GovHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/GovTokenContract
Normal file
1
core/systemcontracts/pascal/chapel/GovTokenContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/GovernorContract
Normal file
1
core/systemcontracts/pascal/chapel/GovernorContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/LightClientContract
Normal file
1
core/systemcontracts/pascal/chapel/LightClientContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/RelayerHubContract
Normal file
1
core/systemcontracts/pascal/chapel/RelayerHubContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/SlashContract
Normal file
1
core/systemcontracts/pascal/chapel/SlashContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/StakeCreditContract
Normal file
1
core/systemcontracts/pascal/chapel/StakeCreditContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/StakeHubContract
Normal file
1
core/systemcontracts/pascal/chapel/StakeHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/StakingContract
Normal file
1
core/systemcontracts/pascal/chapel/StakingContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/SystemRewardContract
Normal file
1
core/systemcontracts/pascal/chapel/SystemRewardContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/TimelockContract
Normal file
1
core/systemcontracts/pascal/chapel/TimelockContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/TokenHubContract
Normal file
1
core/systemcontracts/pascal/chapel/TokenHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/TokenManagerContract
Normal file
1
core/systemcontracts/pascal/chapel/TokenManagerContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/ValidatorContract
Normal file
1
core/systemcontracts/pascal/chapel/ValidatorContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/CrossChainContract
Normal file
1
core/systemcontracts/pascal/mainnet/CrossChainContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/GovHubContract
Normal file
1
core/systemcontracts/pascal/mainnet/GovHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/GovTokenContract
Normal file
1
core/systemcontracts/pascal/mainnet/GovTokenContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/GovernorContract
Normal file
1
core/systemcontracts/pascal/mainnet/GovernorContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/LightClientContract
Normal file
1
core/systemcontracts/pascal/mainnet/LightClientContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/RelayerHubContract
Normal file
1
core/systemcontracts/pascal/mainnet/RelayerHubContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/SlashContract
Normal file
1
core/systemcontracts/pascal/mainnet/SlashContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/StakeCreditContract
Normal file
1
core/systemcontracts/pascal/mainnet/StakeCreditContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/StakeHubContract
Normal file
1
core/systemcontracts/pascal/mainnet/StakeHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/StakingContract
Normal file
1
core/systemcontracts/pascal/mainnet/StakingContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/SystemRewardContract
Normal file
1
core/systemcontracts/pascal/mainnet/SystemRewardContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/TimelockContract
Normal file
1
core/systemcontracts/pascal/mainnet/TimelockContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/TokenHubContract
Normal file
1
core/systemcontracts/pascal/mainnet/TokenHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/TokenManagerContract
Normal file
1
core/systemcontracts/pascal/mainnet/TokenManagerContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/ValidatorContract
Normal file
1
core/systemcontracts/pascal/mainnet/ValidatorContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/CrossChainContract
Normal file
1
core/systemcontracts/pascal/rialto/CrossChainContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/GovHubContract
Normal file
1
core/systemcontracts/pascal/rialto/GovHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/GovTokenContract
Normal file
1
core/systemcontracts/pascal/rialto/GovTokenContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/GovernorContract
Normal file
1
core/systemcontracts/pascal/rialto/GovernorContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/LightClientContract
Normal file
1
core/systemcontracts/pascal/rialto/LightClientContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/RelayerHubContract
Normal file
1
core/systemcontracts/pascal/rialto/RelayerHubContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/SlashContract
Normal file
1
core/systemcontracts/pascal/rialto/SlashContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/StakeCreditContract
Normal file
1
core/systemcontracts/pascal/rialto/StakeCreditContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/StakeHubContract
Normal file
1
core/systemcontracts/pascal/rialto/StakeHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/StakingContract
Normal file
1
core/systemcontracts/pascal/rialto/StakingContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/SystemRewardContract
Normal file
1
core/systemcontracts/pascal/rialto/SystemRewardContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/TimelockContract
Normal file
1
core/systemcontracts/pascal/rialto/TimelockContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/TokenHubContract
Normal file
1
core/systemcontracts/pascal/rialto/TokenHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/TokenManagerContract
Normal file
1
core/systemcontracts/pascal/rialto/TokenManagerContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/ValidatorContract
Normal file
1
core/systemcontracts/pascal/rialto/ValidatorContract
Normal file
File diff suppressed because one or more lines are too long
168
core/systemcontracts/pascal/types.go
Normal file
168
core/systemcontracts/pascal/types.go
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
package pascal
|
||||||
|
|
||||||
|
import _ "embed"
|
||||||
|
|
||||||
|
// contract codes for Mainnet upgrade
|
||||||
|
var (
|
||||||
|
|
||||||
|
//go:embed mainnet/ValidatorContract
|
||||||
|
MainnetValidatorContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/SlashContract
|
||||||
|
MainnetSlashContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/SystemRewardContract
|
||||||
|
MainnetSystemRewardContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/LightClientContract
|
||||||
|
MainnetLightClientContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/TokenHubContract
|
||||||
|
MainnetTokenHubContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/RelayerIncentivizeContract
|
||||||
|
MainnetRelayerIncentivizeContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/RelayerHubContract
|
||||||
|
MainnetRelayerHubContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/GovHubContract
|
||||||
|
MainnetGovHubContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/TokenManagerContract
|
||||||
|
MainnetTokenManagerContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/CrossChainContract
|
||||||
|
MainnetCrossChainContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/StakingContract
|
||||||
|
MainnetStakingContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/StakeHubContract
|
||||||
|
MainnetStakeHubContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/StakeCreditContract
|
||||||
|
MainnetStakeCreditContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/GovernorContract
|
||||||
|
MainnetGovernorContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/GovTokenContract
|
||||||
|
MainnetGovTokenContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/TimelockContract
|
||||||
|
MainnetTimelockContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/TokenRecoverPortalContract
|
||||||
|
MainnetTokenRecoverPortalContract string
|
||||||
|
)
|
||||||
|
|
||||||
|
// contract codes for Chapel upgrade
|
||||||
|
var (
|
||||||
|
|
||||||
|
//go:embed chapel/ValidatorContract
|
||||||
|
ChapelValidatorContract string
|
||||||
|
|
||||||
|
//go:embed chapel/SlashContract
|
||||||
|
ChapelSlashContract string
|
||||||
|
|
||||||
|
//go:embed chapel/SystemRewardContract
|
||||||
|
ChapelSystemRewardContract string
|
||||||
|
|
||||||
|
//go:embed chapel/LightClientContract
|
||||||
|
ChapelLightClientContract string
|
||||||
|
|
||||||
|
//go:embed chapel/TokenHubContract
|
||||||
|
ChapelTokenHubContract string
|
||||||
|
|
||||||
|
//go:embed chapel/RelayerIncentivizeContract
|
||||||
|
ChapelRelayerIncentivizeContract string
|
||||||
|
|
||||||
|
//go:embed chapel/RelayerHubContract
|
||||||
|
ChapelRelayerHubContract string
|
||||||
|
|
||||||
|
//go:embed chapel/GovHubContract
|
||||||
|
ChapelGovHubContract string
|
||||||
|
|
||||||
|
//go:embed chapel/TokenManagerContract
|
||||||
|
ChapelTokenManagerContract string
|
||||||
|
|
||||||
|
//go:embed chapel/CrossChainContract
|
||||||
|
ChapelCrossChainContract string
|
||||||
|
|
||||||
|
//go:embed chapel/StakingContract
|
||||||
|
ChapelStakingContract string
|
||||||
|
|
||||||
|
//go:embed chapel/StakeHubContract
|
||||||
|
ChapelStakeHubContract string
|
||||||
|
|
||||||
|
//go:embed chapel/StakeCreditContract
|
||||||
|
ChapelStakeCreditContract string
|
||||||
|
|
||||||
|
//go:embed chapel/GovernorContract
|
||||||
|
ChapelGovernorContract string
|
||||||
|
|
||||||
|
//go:embed chapel/GovTokenContract
|
||||||
|
ChapelGovTokenContract string
|
||||||
|
|
||||||
|
//go:embed chapel/TimelockContract
|
||||||
|
ChapelTimelockContract string
|
||||||
|
|
||||||
|
//go:embed chapel/TokenRecoverPortalContract
|
||||||
|
ChapelTokenRecoverPortalContract string
|
||||||
|
)
|
||||||
|
|
||||||
|
// contract codes for Rialto upgrade
|
||||||
|
var (
|
||||||
|
|
||||||
|
//go:embed rialto/ValidatorContract
|
||||||
|
RialtoValidatorContract string
|
||||||
|
|
||||||
|
//go:embed rialto/SlashContract
|
||||||
|
RialtoSlashContract string
|
||||||
|
|
||||||
|
//go:embed rialto/SystemRewardContract
|
||||||
|
RialtoSystemRewardContract string
|
||||||
|
|
||||||
|
//go:embed rialto/LightClientContract
|
||||||
|
RialtoLightClientContract string
|
||||||
|
|
||||||
|
//go:embed rialto/TokenHubContract
|
||||||
|
RialtoTokenHubContract string
|
||||||
|
|
||||||
|
//go:embed rialto/RelayerIncentivizeContract
|
||||||
|
RialtoRelayerIncentivizeContract string
|
||||||
|
|
||||||
|
//go:embed rialto/RelayerHubContract
|
||||||
|
RialtoRelayerHubContract string
|
||||||
|
|
||||||
|
//go:embed rialto/GovHubContract
|
||||||
|
RialtoGovHubContract string
|
||||||
|
|
||||||
|
//go:embed rialto/TokenManagerContract
|
||||||
|
RialtoTokenManagerContract string
|
||||||
|
|
||||||
|
//go:embed rialto/CrossChainContract
|
||||||
|
RialtoCrossChainContract string
|
||||||
|
|
||||||
|
//go:embed rialto/StakingContract
|
||||||
|
RialtoStakingContract string
|
||||||
|
|
||||||
|
//go:embed rialto/StakeHubContract
|
||||||
|
RialtoStakeHubContract string
|
||||||
|
|
||||||
|
//go:embed rialto/StakeCreditContract
|
||||||
|
RialtoStakeCreditContract string
|
||||||
|
|
||||||
|
//go:embed rialto/GovernorContract
|
||||||
|
RialtoGovernorContract string
|
||||||
|
|
||||||
|
//go:embed rialto/GovTokenContract
|
||||||
|
RialtoGovTokenContract string
|
||||||
|
|
||||||
|
//go:embed rialto/TimelockContract
|
||||||
|
RialtoTimelockContract string
|
||||||
|
|
||||||
|
//go:embed rialto/TokenRecoverPortalContract
|
||||||
|
RialtoTokenRecoverPortalContract string
|
||||||
|
)
|
||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/mirror"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/mirror"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/moran"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/moran"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/niels"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/niels"
|
||||||
|
"github.com/ethereum/go-ethereum/core/systemcontracts/pascal"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/planck"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/planck"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/plato"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/plato"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/ramanujan"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/ramanujan"
|
||||||
@@ -82,6 +83,8 @@ var (
|
|||||||
haberFixUpgrade = make(map[string]*Upgrade)
|
haberFixUpgrade = make(map[string]*Upgrade)
|
||||||
|
|
||||||
bohrUpgrade = make(map[string]*Upgrade)
|
bohrUpgrade = make(map[string]*Upgrade)
|
||||||
|
|
||||||
|
pascalUpgrade = make(map[string]*Upgrade)
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -773,18 +776,275 @@ func init() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
bohrUpgrade[rialtoNet] = &Upgrade{
|
pascalUpgrade[mainNet] = &Upgrade{
|
||||||
UpgradeName: "bohr",
|
UpgradeName: "pascal",
|
||||||
Configs: []*UpgradeConfig{
|
Configs: []*UpgradeConfig{
|
||||||
{
|
{
|
||||||
ContractAddr: common.HexToAddress(ValidatorContract),
|
ContractAddr: common.HexToAddress(ValidatorContract),
|
||||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/398c9364aad5261c1ecd90ac3ab2df89b65c45e3",
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
Code: bohr.RialtoValidatorContract,
|
Code: pascal.MainnetValidatorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SlashContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetSlashContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SystemRewardContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetSystemRewardContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(LightClientContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetLightClientContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetTokenHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerIncentivizeContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetRelayerIncentivizeContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetRelayerHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetGovHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenManagerContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetTokenManagerContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(CrossChainContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetCrossChainContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakingContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetStakingContract,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ContractAddr: common.HexToAddress(StakeHubContract),
|
ContractAddr: common.HexToAddress(StakeHubContract),
|
||||||
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/398c9364aad5261c1ecd90ac3ab2df89b65c45e3",
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
Code: bohr.RialtoStakeHubContract,
|
Code: pascal.MainnetStakeHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeCreditContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetStakeCreditContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovernorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetGovernorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovTokenContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetGovTokenContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TimelockContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetTimelockContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenRecoverPortalContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.MainnetTokenRecoverPortalContract,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
pascalUpgrade[chapelNet] = &Upgrade{
|
||||||
|
UpgradeName: "pascal",
|
||||||
|
Configs: []*UpgradeConfig{
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(ValidatorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelValidatorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SlashContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelSlashContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SystemRewardContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelSystemRewardContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(LightClientContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelLightClientContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelTokenHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerIncentivizeContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelRelayerIncentivizeContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelRelayerHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelGovHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenManagerContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelTokenManagerContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(CrossChainContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelCrossChainContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakingContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelStakingContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelStakeHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeCreditContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelStakeCreditContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovernorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelGovernorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovTokenContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelGovTokenContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TimelockContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelTimelockContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenRecoverPortalContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.ChapelTokenRecoverPortalContract,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
pascalUpgrade[rialtoNet] = &Upgrade{
|
||||||
|
UpgradeName: "pascal",
|
||||||
|
Configs: []*UpgradeConfig{
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(ValidatorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoValidatorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SlashContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoSlashContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SystemRewardContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoSystemRewardContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(LightClientContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoLightClientContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoTokenHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerIncentivizeContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoRelayerIncentivizeContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoRelayerHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoGovHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenManagerContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoTokenManagerContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(CrossChainContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoCrossChainContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakingContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoStakingContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoStakeHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeCreditContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoStakeCreditContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovernorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoGovernorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovTokenContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoGovTokenContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TimelockContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoTimelockContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenRecoverPortalContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/020c0459e37d1f9d635c1cff86dd1099ab1383fa",
|
||||||
|
Code: pascal.RialtoTokenRecoverPortalContract,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -873,6 +1133,10 @@ func UpgradeBuildInSystemContract(config *params.ChainConfig, blockNumber *big.I
|
|||||||
applySystemContractUpgrade(bohrUpgrade[network], blockNumber, statedb, logger)
|
applySystemContractUpgrade(bohrUpgrade[network], blockNumber, statedb, logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.IsOnPascal(blockNumber, lastBlockTime, blockTime) {
|
||||||
|
applySystemContractUpgrade(pascalUpgrade[network], blockNumber, statedb, logger)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
apply other upgrades
|
apply other upgrades
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package legacypool
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -103,6 +104,7 @@ var (
|
|||||||
queuedGauge = metrics.NewRegisteredGauge("txpool/queued", nil)
|
queuedGauge = metrics.NewRegisteredGauge("txpool/queued", nil)
|
||||||
localGauge = metrics.NewRegisteredGauge("txpool/local", nil)
|
localGauge = metrics.NewRegisteredGauge("txpool/local", nil)
|
||||||
slotsGauge = metrics.NewRegisteredGauge("txpool/slots", nil)
|
slotsGauge = metrics.NewRegisteredGauge("txpool/slots", nil)
|
||||||
|
OverflowPoolGauge = metrics.NewRegisteredGauge("txpool/overflowpool", nil)
|
||||||
|
|
||||||
reheapTimer = metrics.NewRegisteredTimer("txpool/reheap", nil)
|
reheapTimer = metrics.NewRegisteredTimer("txpool/reheap", nil)
|
||||||
)
|
)
|
||||||
@@ -137,6 +139,7 @@ type Config struct {
|
|||||||
GlobalSlots uint64 // Maximum number of executable transaction slots for all accounts
|
GlobalSlots uint64 // Maximum number of executable transaction slots for all accounts
|
||||||
AccountQueue uint64 // Maximum number of non-executable transaction slots permitted per account
|
AccountQueue uint64 // Maximum number of non-executable transaction slots permitted per account
|
||||||
GlobalQueue uint64 // Maximum number of non-executable transaction slots for all accounts
|
GlobalQueue uint64 // Maximum number of non-executable transaction slots for all accounts
|
||||||
|
OverflowPoolSlots uint64 // Maximum number of transaction slots in overflow pool
|
||||||
|
|
||||||
Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
|
Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
|
||||||
ReannounceTime time.Duration // Duration for announcing local pending transactions again
|
ReannounceTime time.Duration // Duration for announcing local pending transactions again
|
||||||
@@ -154,6 +157,7 @@ var DefaultConfig = Config{
|
|||||||
GlobalSlots: 4096 + 1024, // urgent + floating queue capacity with 4:1 ratio
|
GlobalSlots: 4096 + 1024, // urgent + floating queue capacity with 4:1 ratio
|
||||||
AccountQueue: 64,
|
AccountQueue: 64,
|
||||||
GlobalQueue: 1024,
|
GlobalQueue: 1024,
|
||||||
|
OverflowPoolSlots: 0,
|
||||||
|
|
||||||
Lifetime: 3 * time.Hour,
|
Lifetime: 3 * time.Hour,
|
||||||
ReannounceTime: 10 * 365 * 24 * time.Hour,
|
ReannounceTime: 10 * 365 * 24 * time.Hour,
|
||||||
@@ -235,6 +239,8 @@ type LegacyPool struct {
|
|||||||
all *lookup // All transactions to allow lookups
|
all *lookup // All transactions to allow lookups
|
||||||
priced *pricedList // All transactions sorted by price
|
priced *pricedList // All transactions sorted by price
|
||||||
|
|
||||||
|
localBufferPool *TxOverflowPool // Local buffer transactions
|
||||||
|
|
||||||
reqResetCh chan *txpoolResetRequest
|
reqResetCh chan *txpoolResetRequest
|
||||||
reqPromoteCh chan *accountSet
|
reqPromoteCh chan *accountSet
|
||||||
queueTxEventCh chan *types.Transaction
|
queueTxEventCh chan *types.Transaction
|
||||||
@@ -272,6 +278,7 @@ func New(config Config, chain BlockChain) *LegacyPool {
|
|||||||
reorgDoneCh: make(chan chan struct{}),
|
reorgDoneCh: make(chan chan struct{}),
|
||||||
reorgShutdownCh: make(chan struct{}),
|
reorgShutdownCh: make(chan struct{}),
|
||||||
initDoneCh: make(chan struct{}),
|
initDoneCh: make(chan struct{}),
|
||||||
|
localBufferPool: NewTxOverflowPoolHeap(config.OverflowPoolSlots),
|
||||||
}
|
}
|
||||||
pool.locals = newAccountSet(pool.signer)
|
pool.locals = newAccountSet(pool.signer)
|
||||||
for _, addr := range config.Locals {
|
for _, addr := range config.Locals {
|
||||||
@@ -408,7 +415,6 @@ func (pool *LegacyPool) loop() {
|
|||||||
if !pool.locals.contains(addr) {
|
if !pool.locals.contains(addr) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tx := range list.Flatten() {
|
for _, tx := range list.Flatten() {
|
||||||
// Default ReannounceTime is 10 years, won't announce by default.
|
// Default ReannounceTime is 10 years, won't announce by default.
|
||||||
if time.Since(tx.Time()) < pool.config.ReannounceTime {
|
if time.Since(tx.Time()) < pool.config.ReannounceTime {
|
||||||
@@ -517,6 +523,17 @@ func (pool *LegacyPool) Stats() (int, int) {
|
|||||||
return pool.stats()
|
return pool.stats()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pool *LegacyPool) statsOverflowPool() int {
|
||||||
|
pool.mu.RLock()
|
||||||
|
defer pool.mu.RUnlock()
|
||||||
|
|
||||||
|
if pool.localBufferPool == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return pool.localBufferPool.Size()
|
||||||
|
}
|
||||||
|
|
||||||
// stats retrieves the current pool stats, namely the number of pending and the
|
// stats retrieves the current pool stats, namely the number of pending and the
|
||||||
// number of queued (non-executable) transactions.
|
// number of queued (non-executable) transactions.
|
||||||
func (pool *LegacyPool) stats() (int, int) {
|
func (pool *LegacyPool) stats() (int, int) {
|
||||||
@@ -831,6 +848,8 @@ func (pool *LegacyPool) add(tx *types.Transaction, local bool) (replaced bool, e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pool.addToOverflowPool(drop, isLocal)
|
||||||
|
|
||||||
// Kick out the underpriced remote transactions.
|
// Kick out the underpriced remote transactions.
|
||||||
for _, tx := range drop {
|
for _, tx := range drop {
|
||||||
log.Trace("Discarding freshly underpriced transaction", "hash", tx.Hash(), "gasTipCap", tx.GasTipCap(), "gasFeeCap", tx.GasFeeCap())
|
log.Trace("Discarding freshly underpriced transaction", "hash", tx.Hash(), "gasTipCap", tx.GasTipCap(), "gasFeeCap", tx.GasFeeCap())
|
||||||
@@ -887,6 +906,29 @@ func (pool *LegacyPool) add(tx *types.Transaction, local bool) (replaced bool, e
|
|||||||
return replaced, nil
|
return replaced, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pool *LegacyPool) addToOverflowPool(drop types.Transactions, isLocal bool) {
|
||||||
|
// calculate total number of slots in drop. Accordingly add them to OverflowPool (if there is space)
|
||||||
|
availableSlotsOverflowPool := pool.availableSlotsOverflowPool()
|
||||||
|
if availableSlotsOverflowPool > 0 {
|
||||||
|
// transfer availableSlotsOverflowPool number of transactions slots from drop to OverflowPool
|
||||||
|
currentSlotsUsed := 0
|
||||||
|
for i, tx := range drop {
|
||||||
|
txSlots := numSlots(tx)
|
||||||
|
if currentSlotsUsed+txSlots <= availableSlotsOverflowPool {
|
||||||
|
from, _ := types.Sender(pool.signer, tx)
|
||||||
|
pool.localBufferPool.Add(tx)
|
||||||
|
log.Debug("adding to OverflowPool", "transaction", tx.Hash().String(), "from", from.String())
|
||||||
|
currentSlotsUsed += txSlots
|
||||||
|
} else {
|
||||||
|
log.Debug("not all got added to OverflowPool", "totalAdded", i+1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Debug("adding to OverflowPool unsuccessful", "availableSlotsOverflowPool", availableSlotsOverflowPool)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// isGapped reports whether the given transaction is immediately executable.
|
// isGapped reports whether the given transaction is immediately executable.
|
||||||
func (pool *LegacyPool) isGapped(from common.Address, tx *types.Transaction) bool {
|
func (pool *LegacyPool) isGapped(from common.Address, tx *types.Transaction) bool {
|
||||||
// Short circuit if transaction falls within the scope of the pending list
|
// Short circuit if transaction falls within the scope of the pending list
|
||||||
@@ -1333,7 +1375,6 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest,
|
|||||||
reorgDurationTimer.Update(time.Since(t0))
|
reorgDurationTimer.Update(time.Since(t0))
|
||||||
}(time.Now())
|
}(time.Now())
|
||||||
defer close(done)
|
defer close(done)
|
||||||
|
|
||||||
var promoteAddrs []common.Address
|
var promoteAddrs []common.Address
|
||||||
if dirtyAccounts != nil && reset == nil {
|
if dirtyAccounts != nil && reset == nil {
|
||||||
// Only dirty accounts need to be promoted, unless we're resetting.
|
// Only dirty accounts need to be promoted, unless we're resetting.
|
||||||
@@ -1391,6 +1432,9 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest,
|
|||||||
pool.changesSinceReorg = 0 // Reset change counter
|
pool.changesSinceReorg = 0 // Reset change counter
|
||||||
pool.mu.Unlock()
|
pool.mu.Unlock()
|
||||||
|
|
||||||
|
// Transfer transactions from OverflowPool to MainPool for new block import
|
||||||
|
pool.transferTransactions()
|
||||||
|
|
||||||
// Notify subsystems for newly added transactions
|
// Notify subsystems for newly added transactions
|
||||||
for _, tx := range promoted {
|
for _, tx := range promoted {
|
||||||
addr, _ := types.Sender(pool.signer, tx)
|
addr, _ := types.Sender(pool.signer, tx)
|
||||||
@@ -2038,3 +2082,50 @@ func (t *lookup) RemotesBelowTip(threshold *big.Int) types.Transactions {
|
|||||||
func numSlots(tx *types.Transaction) int {
|
func numSlots(tx *types.Transaction) int {
|
||||||
return int((tx.Size() + txSlotSize - 1) / txSlotSize)
|
return int((tx.Size() + txSlotSize - 1) / txSlotSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// transferTransactions moves transactions from OverflowPool to MainPool
|
||||||
|
func (pool *LegacyPool) transferTransactions() {
|
||||||
|
// Fail fast if the overflow pool is empty
|
||||||
|
if pool.localBufferPool.Size() == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
maxMainPoolSize := int(pool.config.GlobalSlots + pool.config.GlobalQueue)
|
||||||
|
// Use pool.all.Slots() to get the total slots used by all transactions
|
||||||
|
currentMainPoolSize := pool.all.Slots()
|
||||||
|
if currentMainPoolSize >= maxMainPoolSize {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
extraSlots := maxMainPoolSize - currentMainPoolSize
|
||||||
|
extraTransactions := (extraSlots + 3) / 4 // Since a transaction can take up to 4 slots
|
||||||
|
log.Debug("Will attempt to transfer from OverflowPool to MainPool", "transactions", extraTransactions)
|
||||||
|
txs := pool.localBufferPool.Flush(extraTransactions)
|
||||||
|
if len(txs) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pool.Add(txs, true, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *LegacyPool) availableSlotsOverflowPool() int {
|
||||||
|
maxOverflowPoolSize := int(pool.config.OverflowPoolSlots)
|
||||||
|
availableSlots := maxOverflowPoolSize - pool.localBufferPool.Size()
|
||||||
|
if availableSlots > 0 {
|
||||||
|
return availableSlots
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *LegacyPool) PrintTxStats() {
|
||||||
|
for _, l := range pool.pending {
|
||||||
|
for _, transaction := range l.txs.items {
|
||||||
|
from, _ := types.Sender(pool.signer, transaction)
|
||||||
|
fmt.Println("from: ", from, " Pending:", transaction.Hash().String(), transaction.GasFeeCap(), transaction.GasTipCap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pool.localBufferPool.PrintTxStats()
|
||||||
|
fmt.Println("length of all: ", pool.all.Slots())
|
||||||
|
fmt.Println("----------------------------------------------------")
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -1739,6 +1740,7 @@ func TestRepricingKeepsLocals(t *testing.T) {
|
|||||||
// Note, local transactions are never allowed to be dropped.
|
// Note, local transactions are never allowed to be dropped.
|
||||||
func TestUnderpricing(t *testing.T) {
|
func TestUnderpricing(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
testTxPoolConfig.OverflowPoolSlots = 5
|
||||||
|
|
||||||
// Create the pool to test the pricing enforcement with
|
// Create the pool to test the pricing enforcement with
|
||||||
statedb, _ := state.New(types.EmptyRootHash, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
|
statedb, _ := state.New(types.EmptyRootHash, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
|
||||||
@@ -1931,6 +1933,8 @@ func TestUnderpricingDynamicFee(t *testing.T) {
|
|||||||
pool.config.GlobalSlots = 2
|
pool.config.GlobalSlots = 2
|
||||||
pool.config.GlobalQueue = 2
|
pool.config.GlobalQueue = 2
|
||||||
|
|
||||||
|
pool.config.OverflowPoolSlots = 0
|
||||||
|
|
||||||
// Keep track of transaction events to ensure all executables get announced
|
// Keep track of transaction events to ensure all executables get announced
|
||||||
events := make(chan core.NewTxsEvent, 32)
|
events := make(chan core.NewTxsEvent, 32)
|
||||||
sub := pool.txFeed.Subscribe(events)
|
sub := pool.txFeed.Subscribe(events)
|
||||||
@@ -1955,7 +1959,6 @@ func TestUnderpricingDynamicFee(t *testing.T) {
|
|||||||
// Import the batch and that both pending and queued transactions match up
|
// Import the batch and that both pending and queued transactions match up
|
||||||
pool.addRemotes(txs) // Pend K0:0, K0:1; Que K1:1
|
pool.addRemotes(txs) // Pend K0:0, K0:1; Que K1:1
|
||||||
pool.addLocal(ltx) // +K2:0 => Pend K0:0, K0:1, K2:0; Que K1:1
|
pool.addLocal(ltx) // +K2:0 => Pend K0:0, K0:1, K2:0; Que K1:1
|
||||||
|
|
||||||
pending, queued := pool.Stats()
|
pending, queued := pool.Stats()
|
||||||
if pending != 3 {
|
if pending != 3 {
|
||||||
t.Fatalf("pending transactions mismatched: have %d, want %d", pending, 3)
|
t.Fatalf("pending transactions mismatched: have %d, want %d", pending, 3)
|
||||||
@@ -1995,9 +1998,9 @@ func TestUnderpricingDynamicFee(t *testing.T) {
|
|||||||
t.Fatalf("pending transactions mismatched: have %d, want %d", pending, 2)
|
t.Fatalf("pending transactions mismatched: have %d, want %d", pending, 2)
|
||||||
}
|
}
|
||||||
if queued != 2 {
|
if queued != 2 {
|
||||||
t.Fatalf("queued transactions mismatched: have %d, want %d", queued, 2)
|
t.Fatalf("queued transactions mismatched: have %d, want %d", queued, 1)
|
||||||
}
|
}
|
||||||
if err := validateEvents(events, 2); err != nil {
|
if err := validateEvents(events, 2); err != nil { // todo make it 4...After this validateEvents the pending becomes 3?!
|
||||||
t.Fatalf("additional event firing failed: %v", err)
|
t.Fatalf("additional event firing failed: %v", err)
|
||||||
}
|
}
|
||||||
if err := validatePoolInternals(pool); err != nil {
|
if err := validatePoolInternals(pool); err != nil {
|
||||||
@@ -2012,11 +2015,12 @@ func TestUnderpricingDynamicFee(t *testing.T) {
|
|||||||
if err := pool.addLocal(ltx); err != nil {
|
if err := pool.addLocal(ltx); err != nil {
|
||||||
t.Fatalf("failed to add new underpriced local transaction: %v", err)
|
t.Fatalf("failed to add new underpriced local transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pending, queued = pool.Stats()
|
pending, queued = pool.Stats()
|
||||||
if pending != 3 {
|
if pending != 3 { // 3
|
||||||
t.Fatalf("pending transactions mismatched: have %d, want %d", pending, 3)
|
t.Fatalf("pending transactions mismatched: have %d, want %d", pending, 3)
|
||||||
}
|
}
|
||||||
if queued != 1 {
|
if queued != 1 { // 1
|
||||||
t.Fatalf("queued transactions mismatched: have %d, want %d", queued, 1)
|
t.Fatalf("queued transactions mismatched: have %d, want %d", queued, 1)
|
||||||
}
|
}
|
||||||
if err := validateEvents(events, 2); err != nil {
|
if err := validateEvents(events, 2); err != nil {
|
||||||
@@ -2032,41 +2036,51 @@ func TestUnderpricingDynamicFee(t *testing.T) {
|
|||||||
func TestDualHeapEviction(t *testing.T) {
|
func TestDualHeapEviction(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
testTxPoolConfig.OverflowPoolSlots = 1
|
||||||
pool, _ := setupPoolWithConfig(eip1559Config)
|
pool, _ := setupPoolWithConfig(eip1559Config)
|
||||||
defer pool.Close()
|
defer pool.Close()
|
||||||
|
|
||||||
pool.config.GlobalSlots = 10
|
pool.config.GlobalSlots = 2
|
||||||
pool.config.GlobalQueue = 10
|
pool.config.GlobalQueue = 2
|
||||||
|
pool.config.OverflowPoolSlots = 1
|
||||||
|
|
||||||
var (
|
var (
|
||||||
highTip, highCap *types.Transaction
|
highTip, highCap *types.Transaction
|
||||||
baseFee int
|
baseFee int
|
||||||
|
highCapValue int64
|
||||||
|
highTipValue int64
|
||||||
)
|
)
|
||||||
|
|
||||||
check := func(tx *types.Transaction, name string) {
|
check := func(tx *types.Transaction, name string) {
|
||||||
if pool.all.GetRemote(tx.Hash()) == nil {
|
if pool.all.GetRemote(tx.Hash()) == nil {
|
||||||
t.Fatalf("highest %s transaction evicted from the pool", name)
|
t.Fatalf("highest %s transaction evicted from the pool, gasTip: %s, gasFeeCap: %s, hash: %s", name, highTip.GasTipCap().String(), highCap.GasFeeCap().String(), tx.Hash().String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add := func(urgent bool) {
|
add := func(urgent bool) {
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 4; i++ {
|
||||||
var tx *types.Transaction
|
var tx *types.Transaction
|
||||||
// Create a test accounts and fund it
|
// Create a test accounts and fund it
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
testAddBalance(pool, crypto.PubkeyToAddress(key.PublicKey), big.NewInt(1000000000000))
|
testAddBalance(pool, crypto.PubkeyToAddress(key.PublicKey), big.NewInt(1000000000000))
|
||||||
if urgent {
|
if urgent {
|
||||||
tx = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+1+i)), big.NewInt(int64(1+i)), key)
|
tx = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+1+i)), big.NewInt(int64(1+i)), key)
|
||||||
|
if int64(1+i) > highTipValue || (int64(1+i) == highTipValue && int64(baseFee+1+i) > highTip.GasFeeCap().Int64()) {
|
||||||
|
highTipValue = int64(1 + i)
|
||||||
highTip = tx
|
highTip = tx
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tx = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+200+i)), big.NewInt(1), key)
|
tx = dynamicFeeTx(0, 100000, big.NewInt(int64(baseFee+200+i)), big.NewInt(1), key)
|
||||||
|
if int64(baseFee+200+i) > highCapValue {
|
||||||
|
highCapValue = int64(baseFee + 200 + i)
|
||||||
highCap = tx
|
highCap = tx
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pool.addRemotesSync([]*types.Transaction{tx})
|
pool.addRemotesSync([]*types.Transaction{tx})
|
||||||
}
|
}
|
||||||
pending, queued := pool.Stats()
|
pending, queued := pool.Stats()
|
||||||
if pending+queued != 20 {
|
if pending+queued != 4 {
|
||||||
t.Fatalf("transaction count mismatch: have %d, want %d", pending+queued, 10)
|
t.Fatalf("transaction count mismatch: have %d, want %d, pending %d, queued %d, OverflowPool %d", pending+queued, 5, pending, queued, pool.localBufferPool.Size())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2231,6 +2245,50 @@ func TestReplacement(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTransferTransactions(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
testTxPoolConfig.OverflowPoolSlots = 1
|
||||||
|
pool, _ := setupPoolWithConfig(eip1559Config)
|
||||||
|
defer pool.Close()
|
||||||
|
|
||||||
|
pool.config.GlobalSlots = 1
|
||||||
|
pool.config.GlobalQueue = 2
|
||||||
|
|
||||||
|
// Create a number of test accounts and fund them
|
||||||
|
keys := make([]*ecdsa.PrivateKey, 5)
|
||||||
|
for i := 0; i < len(keys); i++ {
|
||||||
|
keys[i], _ = crypto.GenerateKey()
|
||||||
|
testAddBalance(pool, crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(1000000))
|
||||||
|
}
|
||||||
|
|
||||||
|
tx := dynamicFeeTx(0, 100000, big.NewInt(3), big.NewInt(2), keys[0])
|
||||||
|
from, _ := types.Sender(pool.signer, tx)
|
||||||
|
pool.addToOverflowPool([]*types.Transaction{tx}, true)
|
||||||
|
pending, queue := pool.Stats()
|
||||||
|
|
||||||
|
assert.Equal(t, 0, pending, "pending transactions mismatched")
|
||||||
|
assert.Equal(t, 0, queue, "queued transactions mismatched")
|
||||||
|
assert.Equal(t, 1, pool.statsOverflowPool(), "OverflowPool size unexpected")
|
||||||
|
|
||||||
|
tx2 := dynamicFeeTx(0, 100000, big.NewInt(3), big.NewInt(2), keys[1])
|
||||||
|
pool.addToOverflowPool([]*types.Transaction{tx2}, true)
|
||||||
|
assert.Equal(t, 1, pool.statsOverflowPool(), "OverflowPool size unexpected")
|
||||||
|
<-pool.requestPromoteExecutables(newAccountSet(pool.signer, from))
|
||||||
|
pending, queue = pool.Stats()
|
||||||
|
|
||||||
|
assert.Equal(t, 0, pending, "pending transactions mismatched")
|
||||||
|
assert.Equal(t, 1, queue, "queued transactions mismatched")
|
||||||
|
assert.Equal(t, 0, pool.statsOverflowPool(), "OverflowPool size unexpected")
|
||||||
|
|
||||||
|
tx3 := dynamicFeeTx(0, 100000, big.NewInt(3), big.NewInt(2), keys[2])
|
||||||
|
pool.addToOverflowPool([]*types.Transaction{tx3}, true)
|
||||||
|
pending, queue = pool.Stats()
|
||||||
|
|
||||||
|
assert.Equal(t, 1, pending, "pending transactions mismatched")
|
||||||
|
assert.Equal(t, 0, queue, "queued transactions mismatched")
|
||||||
|
assert.Equal(t, 1, pool.statsOverflowPool(), "OverflowPool size unexpected")
|
||||||
|
}
|
||||||
|
|
||||||
// Tests that the pool rejects replacement dynamic fee transactions that don't
|
// Tests that the pool rejects replacement dynamic fee transactions that don't
|
||||||
// meet the minimum price bump required.
|
// meet the minimum price bump required.
|
||||||
func TestReplacementDynamicFee(t *testing.T) {
|
func TestReplacementDynamicFee(t *testing.T) {
|
||||||
|
|||||||
171
core/txpool/legacypool/tx_overflowpool.go
Normal file
171
core/txpool/legacypool/tx_overflowpool.go
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
package legacypool
|
||||||
|
|
||||||
|
import (
|
||||||
|
"container/heap"
|
||||||
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// txHeapItem implements the Interface interface (https://pkg.go.dev/container/heap#Interface) of heap so that it can be heapified
|
||||||
|
type txHeapItem struct {
|
||||||
|
tx *types.Transaction
|
||||||
|
timestamp int64 // Unix timestamp (nanoseconds) of when the transaction was added
|
||||||
|
index int
|
||||||
|
}
|
||||||
|
|
||||||
|
type txHeap []*txHeapItem
|
||||||
|
|
||||||
|
func (h txHeap) Len() int { return len(h) }
|
||||||
|
func (h txHeap) Less(i, j int) bool {
|
||||||
|
return h[i].timestamp < h[j].timestamp
|
||||||
|
}
|
||||||
|
func (h txHeap) Swap(i, j int) {
|
||||||
|
if i < 0 || j < 0 || i >= len(h) || j >= len(h) {
|
||||||
|
return // Silently fail if indices are out of bounds
|
||||||
|
}
|
||||||
|
h[i], h[j] = h[j], h[i]
|
||||||
|
if h[i] != nil {
|
||||||
|
h[i].index = i
|
||||||
|
}
|
||||||
|
if h[j] != nil {
|
||||||
|
h[j].index = j
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *txHeap) Push(x interface{}) {
|
||||||
|
item, ok := x.(*txHeapItem)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
n := len(*h)
|
||||||
|
item.index = n
|
||||||
|
*h = append(*h, item)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *txHeap) Pop() interface{} {
|
||||||
|
old := *h
|
||||||
|
n := len(old)
|
||||||
|
if n == 0 {
|
||||||
|
return nil // Return nil if the heap is empty
|
||||||
|
}
|
||||||
|
item := old[n-1]
|
||||||
|
old[n-1] = nil // avoid memory leak
|
||||||
|
*h = old[0 : n-1]
|
||||||
|
if item != nil {
|
||||||
|
item.index = -1 // for safety
|
||||||
|
}
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
|
||||||
|
type TxOverflowPool struct {
|
||||||
|
txHeap txHeap
|
||||||
|
index map[common.Hash]*txHeapItem
|
||||||
|
mu sync.RWMutex
|
||||||
|
maxSize uint64
|
||||||
|
totalSize int
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTxOverflowPoolHeap(estimatedMaxSize uint64) *TxOverflowPool {
|
||||||
|
return &TxOverflowPool{
|
||||||
|
txHeap: make(txHeap, 0, estimatedMaxSize),
|
||||||
|
index: make(map[common.Hash]*txHeapItem, estimatedMaxSize),
|
||||||
|
maxSize: estimatedMaxSize,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tp *TxOverflowPool) Add(tx *types.Transaction) {
|
||||||
|
tp.mu.Lock()
|
||||||
|
defer tp.mu.Unlock()
|
||||||
|
|
||||||
|
if _, exists := tp.index[tx.Hash()]; exists {
|
||||||
|
// Transaction already in pool, ignore
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if uint64(len(tp.txHeap)) >= tp.maxSize {
|
||||||
|
// Remove the oldest transaction to make space
|
||||||
|
oldestItem, ok := heap.Pop(&tp.txHeap).(*txHeapItem)
|
||||||
|
if !ok || oldestItem == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
delete(tp.index, oldestItem.tx.Hash())
|
||||||
|
tp.totalSize -= numSlots(oldestItem.tx)
|
||||||
|
OverflowPoolGauge.Dec(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
item := &txHeapItem{
|
||||||
|
tx: tx,
|
||||||
|
timestamp: time.Now().UnixNano(),
|
||||||
|
}
|
||||||
|
heap.Push(&tp.txHeap, item)
|
||||||
|
tp.index[tx.Hash()] = item
|
||||||
|
tp.totalSize += numSlots(tx)
|
||||||
|
OverflowPoolGauge.Inc(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tp *TxOverflowPool) Get(hash common.Hash) (*types.Transaction, bool) {
|
||||||
|
tp.mu.RLock()
|
||||||
|
defer tp.mu.RUnlock()
|
||||||
|
if item, ok := tp.index[hash]; ok {
|
||||||
|
return item.tx, true
|
||||||
|
}
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tp *TxOverflowPool) Remove(hash common.Hash) {
|
||||||
|
tp.mu.Lock()
|
||||||
|
defer tp.mu.Unlock()
|
||||||
|
if item, ok := tp.index[hash]; ok {
|
||||||
|
heap.Remove(&tp.txHeap, item.index)
|
||||||
|
delete(tp.index, hash)
|
||||||
|
tp.totalSize -= numSlots(item.tx)
|
||||||
|
OverflowPoolGauge.Dec(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tp *TxOverflowPool) Flush(n int) []*types.Transaction {
|
||||||
|
tp.mu.Lock()
|
||||||
|
defer tp.mu.Unlock()
|
||||||
|
if n > tp.txHeap.Len() {
|
||||||
|
n = tp.txHeap.Len()
|
||||||
|
}
|
||||||
|
txs := make([]*types.Transaction, n)
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
item, ok := heap.Pop(&tp.txHeap).(*txHeapItem)
|
||||||
|
if !ok || item == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
txs[i] = item.tx
|
||||||
|
delete(tp.index, item.tx.Hash())
|
||||||
|
tp.totalSize -= numSlots(item.tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
OverflowPoolGauge.Dec(int64(n))
|
||||||
|
return txs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tp *TxOverflowPool) Len() int {
|
||||||
|
tp.mu.RLock()
|
||||||
|
defer tp.mu.RUnlock()
|
||||||
|
return tp.txHeap.Len()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tp *TxOverflowPool) Size() int {
|
||||||
|
tp.mu.RLock()
|
||||||
|
defer tp.mu.RUnlock()
|
||||||
|
return tp.totalSize
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tp *TxOverflowPool) PrintTxStats() {
|
||||||
|
tp.mu.RLock()
|
||||||
|
defer tp.mu.RUnlock()
|
||||||
|
for _, item := range tp.txHeap {
|
||||||
|
tx := item.tx
|
||||||
|
fmt.Printf("Hash: %s, Timestamp: %d, GasFeeCap: %s, GasTipCap: %s\n",
|
||||||
|
tx.Hash().String(), item.timestamp, tx.GasFeeCap().String(), tx.GasTipCap().String())
|
||||||
|
}
|
||||||
|
}
|
||||||
266
core/txpool/legacypool/tx_overflowpool_test.go
Normal file
266
core/txpool/legacypool/tx_overflowpool_test.go
Normal file
@@ -0,0 +1,266 @@
|
|||||||
|
package legacypool
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/big"
|
||||||
|
rand2 "math/rand"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/cometbft/cometbft/libs/rand"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Helper function to create a test transaction
|
||||||
|
func createTestTx(nonce uint64, gasPrice *big.Int) *types.Transaction {
|
||||||
|
to := common.HexToAddress("0x1234567890123456789012345678901234567890")
|
||||||
|
return types.NewTransaction(nonce, to, big.NewInt(1000), 21000, gasPrice, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewTxOverflowPoolHeap(t *testing.T) {
|
||||||
|
pool := NewTxOverflowPoolHeap(0)
|
||||||
|
if pool == nil {
|
||||||
|
t.Fatal("NewTxOverflowPoolHeap returned nil")
|
||||||
|
}
|
||||||
|
if pool.Len() != 0 {
|
||||||
|
t.Errorf("New pool should be empty, got length %d", pool.Len())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTxOverflowPoolHeapAdd(t *testing.T) {
|
||||||
|
pool := NewTxOverflowPoolHeap(1)
|
||||||
|
tx := createTestTx(1, big.NewInt(1000))
|
||||||
|
|
||||||
|
pool.Add(tx)
|
||||||
|
if pool.Len() != 1 {
|
||||||
|
t.Errorf("Pool should have 1 transaction, got %d", pool.Len())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the same transaction again
|
||||||
|
pool.Add(tx)
|
||||||
|
if pool.Len() != 1 {
|
||||||
|
t.Errorf("Pool should still have 1 transaction after adding duplicate, got %d", pool.Len())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTxOverflowPoolHeapGet(t *testing.T) {
|
||||||
|
pool := NewTxOverflowPoolHeap(1)
|
||||||
|
tx := createTestTx(1, big.NewInt(1000))
|
||||||
|
pool.Add(tx)
|
||||||
|
|
||||||
|
gotTx, exists := pool.Get(tx.Hash())
|
||||||
|
if !exists {
|
||||||
|
t.Fatal("Get returned false for existing transaction")
|
||||||
|
}
|
||||||
|
if gotTx.Hash() != tx.Hash() {
|
||||||
|
t.Errorf("Get returned wrong transaction. Want %v, got %v", tx.Hash(), gotTx.Hash())
|
||||||
|
}
|
||||||
|
|
||||||
|
_, exists = pool.Get(common.Hash{})
|
||||||
|
if exists {
|
||||||
|
t.Error("Get returned true for non-existent transaction")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTxOverflowPoolHeapRemove(t *testing.T) {
|
||||||
|
pool := NewTxOverflowPoolHeap(1)
|
||||||
|
tx := createTestTx(1, big.NewInt(1000))
|
||||||
|
pool.Add(tx)
|
||||||
|
|
||||||
|
pool.Remove(tx.Hash())
|
||||||
|
if pool.Len() != 0 {
|
||||||
|
t.Errorf("Pool should be empty after removing the only transaction, got length %d", pool.Len())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to remove non-existent transaction
|
||||||
|
pool.Remove(common.Hash{})
|
||||||
|
if pool.Len() != 0 {
|
||||||
|
t.Error("Removing non-existent transaction should not affect pool size")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTxOverflowPoolHeapPopN(t *testing.T) {
|
||||||
|
pool := NewTxOverflowPoolHeap(3)
|
||||||
|
tx1 := createTestTx(1, big.NewInt(1000))
|
||||||
|
tx2 := createTestTx(2, big.NewInt(2000))
|
||||||
|
tx3 := createTestTx(3, big.NewInt(3000))
|
||||||
|
|
||||||
|
pool.Add(tx1)
|
||||||
|
time.Sleep(time.Millisecond) // Ensure different timestamps
|
||||||
|
pool.Add(tx2)
|
||||||
|
time.Sleep(time.Millisecond)
|
||||||
|
pool.Add(tx3)
|
||||||
|
|
||||||
|
popped := pool.Flush(2)
|
||||||
|
if len(popped) != 2 {
|
||||||
|
t.Fatalf("PopN(2) should return 2 transactions, got %d", len(popped))
|
||||||
|
}
|
||||||
|
if popped[0].Hash() != tx1.Hash() || popped[1].Hash() != tx2.Hash() {
|
||||||
|
t.Error("PopN returned transactions in wrong order")
|
||||||
|
}
|
||||||
|
if pool.Len() != 1 {
|
||||||
|
t.Errorf("Pool should have 1 transaction left, got %d", pool.Len())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pop more than available
|
||||||
|
popped = pool.Flush(2)
|
||||||
|
if len(popped) != 1 {
|
||||||
|
t.Fatalf("PopN(2) should return 1 transaction when only 1 is left, got %d", len(popped))
|
||||||
|
}
|
||||||
|
if popped[0].Hash() != tx3.Hash() {
|
||||||
|
t.Error("PopN returned wrong transaction")
|
||||||
|
}
|
||||||
|
if pool.Len() != 0 {
|
||||||
|
t.Errorf("Pool should be empty, got length %d", pool.Len())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTxOverflowPoolHeapOrdering(t *testing.T) {
|
||||||
|
pool := NewTxOverflowPoolHeap(3)
|
||||||
|
tx1 := createTestTx(1, big.NewInt(1000))
|
||||||
|
tx2 := createTestTx(2, big.NewInt(2000))
|
||||||
|
tx3 := createTestTx(3, big.NewInt(3000))
|
||||||
|
|
||||||
|
pool.Add(tx2)
|
||||||
|
time.Sleep(time.Millisecond) // Ensure different timestamps
|
||||||
|
pool.Add(tx1)
|
||||||
|
pool.Add(tx3) // Added immediately after tx1, should have same timestamp but higher sequence
|
||||||
|
|
||||||
|
popped := pool.Flush(3)
|
||||||
|
if len(popped) != 3 {
|
||||||
|
t.Fatalf("PopN(3) should return 3 transactions, got %d", len(popped))
|
||||||
|
}
|
||||||
|
if popped[0].Hash() != tx2.Hash() || popped[1].Hash() != tx1.Hash() || popped[2].Hash() != tx3.Hash() {
|
||||||
|
t.Error("Transactions not popped in correct order (earliest timestamp first, then by sequence)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTxOverflowPoolHeapLen(t *testing.T) {
|
||||||
|
pool := NewTxOverflowPoolHeap(2)
|
||||||
|
if pool.Len() != 0 {
|
||||||
|
t.Errorf("New pool should have length 0, got %d", pool.Len())
|
||||||
|
}
|
||||||
|
|
||||||
|
pool.Add(createTestTx(1, big.NewInt(1000)))
|
||||||
|
if pool.Len() != 1 {
|
||||||
|
t.Errorf("Pool should have length 1 after adding a transaction, got %d", pool.Len())
|
||||||
|
}
|
||||||
|
|
||||||
|
pool.Add(createTestTx(2, big.NewInt(2000)))
|
||||||
|
if pool.Len() != 2 {
|
||||||
|
t.Errorf("Pool should have length 2 after adding another transaction, got %d", pool.Len())
|
||||||
|
}
|
||||||
|
|
||||||
|
pool.Flush(1)
|
||||||
|
if pool.Len() != 1 {
|
||||||
|
t.Errorf("Pool should have length 1 after popping a transaction, got %d", pool.Len())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to create a random test transaction
|
||||||
|
func createRandomTestTx() *types.Transaction {
|
||||||
|
nonce := uint64(rand.Intn(1000000))
|
||||||
|
to := common.BytesToAddress(rand.Bytes(20))
|
||||||
|
amount := new(big.Int).Rand(rand2.New(rand2.NewSource(rand.Int63())), big.NewInt(1e18))
|
||||||
|
gasLimit := uint64(21000)
|
||||||
|
gasPrice := new(big.Int).Rand(rand2.New(rand2.NewSource(rand.Int63())), big.NewInt(1e9))
|
||||||
|
data := rand.Bytes(100)
|
||||||
|
return types.NewTransaction(nonce, to, amount, gasLimit, gasPrice, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createRandomTestTxs(n int) []*types.Transaction {
|
||||||
|
txs := make([]*types.Transaction, n)
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
txs[i] = createRandomTestTx()
|
||||||
|
}
|
||||||
|
return txs
|
||||||
|
}
|
||||||
|
|
||||||
|
// goos: darwin
|
||||||
|
// goarch: arm64
|
||||||
|
// pkg: github.com/ethereum/go-ethereum/core/txpool/legacypool
|
||||||
|
// BenchmarkTxOverflowPoolHeapAdd-8 813326 2858 ns/op
|
||||||
|
func BenchmarkTxOverflowPoolHeapAdd(b *testing.B) {
|
||||||
|
pool := NewTxOverflowPoolHeap(uint64(b.N))
|
||||||
|
txs := createRandomTestTxs(b.N)
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
pool.Add(txs[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BenchmarkTxOverflowPoolHeapGet-8 32613938 35.63 ns/op
|
||||||
|
func BenchmarkTxOverflowPoolHeapGet(b *testing.B) {
|
||||||
|
pool := NewTxOverflowPoolHeap(1000)
|
||||||
|
txs := createRandomTestTxs(1000)
|
||||||
|
for _, tx := range txs {
|
||||||
|
pool.Add(tx)
|
||||||
|
}
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
pool.Get(txs[i%1000].Hash())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BenchmarkTxOverflowPoolHeapRemove-8 3020841 417.8 ns/op
|
||||||
|
func BenchmarkTxOverflowPoolHeapRemove(b *testing.B) {
|
||||||
|
pool := NewTxOverflowPoolHeap(uint64(b.N))
|
||||||
|
txs := createRandomTestTxs(b.N)
|
||||||
|
for _, tx := range txs {
|
||||||
|
pool.Add(tx)
|
||||||
|
}
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
pool.Remove(txs[i].Hash())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BenchmarkTxOverflowPoolHeapFlush-8 42963656 29.90 ns/op
|
||||||
|
func BenchmarkTxOverflowPoolHeapFlush(b *testing.B) {
|
||||||
|
pool := NewTxOverflowPoolHeap(1000)
|
||||||
|
txs := createRandomTestTxs(1000)
|
||||||
|
for _, tx := range txs {
|
||||||
|
pool.Add(tx)
|
||||||
|
}
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
pool.Flush(10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BenchmarkTxOverflowPoolHeapLen-8 79147188 20.07 ns/op
|
||||||
|
func BenchmarkTxOverflowPoolHeapLen(b *testing.B) {
|
||||||
|
pool := NewTxOverflowPoolHeap(1000)
|
||||||
|
txs := createRandomTestTxs(1000)
|
||||||
|
for _, tx := range txs {
|
||||||
|
pool.Add(tx)
|
||||||
|
}
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
pool.Len()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BenchmarkTxOverflowPoolHeapAddRemove-8 902896 1546 ns/op
|
||||||
|
func BenchmarkTxOverflowPoolHeapAddRemove(b *testing.B) {
|
||||||
|
pool := NewTxOverflowPoolHeap(uint64(b.N))
|
||||||
|
txs := createRandomTestTxs(b.N)
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
pool.Add(txs[i])
|
||||||
|
pool.Remove(txs[i].Hash())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BenchmarkTxOverflowPoolHeapAddFlush-8 84417 14899 ns/op
|
||||||
|
func BenchmarkTxOverflowPoolHeapAddFlush(b *testing.B) {
|
||||||
|
pool := NewTxOverflowPoolHeap(uint64(b.N * 10))
|
||||||
|
txs := createRandomTestTxs(b.N * 10)
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
for j := 0; j < 10; j++ {
|
||||||
|
pool.Add(txs[i*10+j])
|
||||||
|
}
|
||||||
|
pool.Flush(10)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
||||||
|
|
||||||
package ethapi
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
43
core/types/transaction_options.go
Normal file
43
core/types/transaction_options.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AccountStorage struct {
|
||||||
|
StorageRoot *common.Hash
|
||||||
|
StorageSlots map[common.Hash]common.Hash
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AccountStorage) UnmarshalJSON(data []byte) error {
|
||||||
|
var hash common.Hash
|
||||||
|
if err := json.Unmarshal(data, &hash); err == nil {
|
||||||
|
a.StorageRoot = &hash
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return json.Unmarshal(data, &a.StorageSlots)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a AccountStorage) MarshalJSON() ([]byte, error) {
|
||||||
|
if a.StorageRoot != nil {
|
||||||
|
return json.Marshal(*a.StorageRoot)
|
||||||
|
}
|
||||||
|
return json.Marshal(a.StorageSlots)
|
||||||
|
}
|
||||||
|
|
||||||
|
type KnownAccounts map[common.Address]AccountStorage
|
||||||
|
|
||||||
|
// It is known that marshaling is broken
|
||||||
|
// https://github.com/golang/go/issues/55890
|
||||||
|
|
||||||
|
//go:generate go run github.com/fjl/gencodec -type TransactionOpts -out gen_tx_opts_json.go
|
||||||
|
type TransactionOpts struct {
|
||||||
|
KnownAccounts KnownAccounts `json:"knownAccounts"`
|
||||||
|
BlockNumberMin *hexutil.Uint64 `json:"blockNumberMin,omitempty"`
|
||||||
|
BlockNumberMax *hexutil.Uint64 `json:"blockNumberMax,omitempty"`
|
||||||
|
TimestampMin *hexutil.Uint64 `json:"timestampMin,omitempty"`
|
||||||
|
TimestampMax *hexutil.Uint64 `json:"timestampMax,omitempty"`
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ethapi_test
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func ptr(hash common.Hash) *common.Hash {
|
func ptr(hash common.Hash) *common.Hash {
|
||||||
@@ -23,15 +22,15 @@ func TestTransactionOptsJSONUnMarshalTrip(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
input string
|
input string
|
||||||
mustFail bool
|
mustFail bool
|
||||||
expected ethapi.TransactionOpts
|
expected TransactionOpts
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"StateRoot",
|
"StateRoot",
|
||||||
`{"knownAccounts":{"0x6b3A8798E5Fb9fC5603F3aB5eA2e8136694e55d0":"0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563"}}`,
|
`{"knownAccounts":{"0x6b3A8798E5Fb9fC5603F3aB5eA2e8136694e55d0":"0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563"}}`,
|
||||||
false,
|
false,
|
||||||
ethapi.TransactionOpts{
|
TransactionOpts{
|
||||||
KnownAccounts: map[common.Address]ethapi.AccountStorage{
|
KnownAccounts: map[common.Address]AccountStorage{
|
||||||
common.HexToAddress("0x6b3A8798E5Fb9fC5603F3aB5eA2e8136694e55d0"): ethapi.AccountStorage{
|
common.HexToAddress("0x6b3A8798E5Fb9fC5603F3aB5eA2e8136694e55d0"): AccountStorage{
|
||||||
StorageRoot: ptr(common.HexToHash("0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563")),
|
StorageRoot: ptr(common.HexToHash("0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563")),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -41,9 +40,9 @@ func TestTransactionOptsJSONUnMarshalTrip(t *testing.T) {
|
|||||||
"StorageSlots",
|
"StorageSlots",
|
||||||
`{"knownAccounts":{"0x6b3A8798E5Fb9fC5603F3aB5eA2e8136694e55d0":{"0xc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8":"0x0000000000000000000000000000000000000000000000000000000000000000"}}}`,
|
`{"knownAccounts":{"0x6b3A8798E5Fb9fC5603F3aB5eA2e8136694e55d0":{"0xc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8":"0x0000000000000000000000000000000000000000000000000000000000000000"}}}`,
|
||||||
false,
|
false,
|
||||||
ethapi.TransactionOpts{
|
TransactionOpts{
|
||||||
KnownAccounts: map[common.Address]ethapi.AccountStorage{
|
KnownAccounts: map[common.Address]AccountStorage{
|
||||||
common.HexToAddress("0x6b3A8798E5Fb9fC5603F3aB5eA2e8136694e55d0"): ethapi.AccountStorage{
|
common.HexToAddress("0x6b3A8798E5Fb9fC5603F3aB5eA2e8136694e55d0"): AccountStorage{
|
||||||
StorageRoot: nil,
|
StorageRoot: nil,
|
||||||
StorageSlots: map[common.Hash]common.Hash{
|
StorageSlots: map[common.Hash]common.Hash{
|
||||||
common.HexToHash("0xc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8"): common.HexToHash("0x"),
|
common.HexToHash("0xc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8"): common.HexToHash("0x"),
|
||||||
@@ -56,15 +55,15 @@ func TestTransactionOptsJSONUnMarshalTrip(t *testing.T) {
|
|||||||
"EmptyObject",
|
"EmptyObject",
|
||||||
`{"knownAccounts":{}}`,
|
`{"knownAccounts":{}}`,
|
||||||
false,
|
false,
|
||||||
ethapi.TransactionOpts{
|
TransactionOpts{
|
||||||
KnownAccounts: make(map[common.Address]ethapi.AccountStorage),
|
KnownAccounts: make(map[common.Address]AccountStorage),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"EmptyStrings",
|
"EmptyStrings",
|
||||||
`{"knownAccounts":{"":""}}`,
|
`{"knownAccounts":{"":""}}`,
|
||||||
true,
|
true,
|
||||||
ethapi.TransactionOpts{
|
TransactionOpts{
|
||||||
KnownAccounts: nil,
|
KnownAccounts: nil,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -72,7 +71,7 @@ func TestTransactionOptsJSONUnMarshalTrip(t *testing.T) {
|
|||||||
"BlockNumberMin",
|
"BlockNumberMin",
|
||||||
`{"blockNumberMin":"0x1"}`,
|
`{"blockNumberMin":"0x1"}`,
|
||||||
false,
|
false,
|
||||||
ethapi.TransactionOpts{
|
TransactionOpts{
|
||||||
BlockNumberMin: u64Ptr(1),
|
BlockNumberMin: u64Ptr(1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -80,7 +79,7 @@ func TestTransactionOptsJSONUnMarshalTrip(t *testing.T) {
|
|||||||
"BlockNumberMax",
|
"BlockNumberMax",
|
||||||
`{"blockNumberMin":"0x1", "blockNumberMax":"0x2"}`,
|
`{"blockNumberMin":"0x1", "blockNumberMax":"0x2"}`,
|
||||||
false,
|
false,
|
||||||
ethapi.TransactionOpts{
|
TransactionOpts{
|
||||||
BlockNumberMin: u64Ptr(1),
|
BlockNumberMin: u64Ptr(1),
|
||||||
BlockNumberMax: u64Ptr(2),
|
BlockNumberMax: u64Ptr(2),
|
||||||
},
|
},
|
||||||
@@ -89,7 +88,7 @@ func TestTransactionOptsJSONUnMarshalTrip(t *testing.T) {
|
|||||||
"TimestampMin",
|
"TimestampMin",
|
||||||
`{"timestampMin":"0xffff"}`,
|
`{"timestampMin":"0xffff"}`,
|
||||||
false,
|
false,
|
||||||
ethapi.TransactionOpts{
|
TransactionOpts{
|
||||||
TimestampMin: u64Ptr(0xffff),
|
TimestampMin: u64Ptr(0xffff),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -97,7 +96,7 @@ func TestTransactionOptsJSONUnMarshalTrip(t *testing.T) {
|
|||||||
"TimestampMax",
|
"TimestampMax",
|
||||||
`{"timestampMax":"0xffffff"}`,
|
`{"timestampMax":"0xffffff"}`,
|
||||||
false,
|
false,
|
||||||
ethapi.TransactionOpts{
|
TransactionOpts{
|
||||||
TimestampMax: u64Ptr(0xffffff),
|
TimestampMax: u64Ptr(0xffffff),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -105,7 +104,7 @@ func TestTransactionOptsJSONUnMarshalTrip(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
var opts ethapi.TransactionOpts
|
var opts TransactionOpts
|
||||||
err := json.Unmarshal([]byte(test.input), &opts)
|
err := json.Unmarshal([]byte(test.input), &opts)
|
||||||
if test.mustFail && err == nil {
|
if test.mustFail && err == nil {
|
||||||
t.Errorf("Test %s should fail", test.name)
|
t.Errorf("Test %s should fail", test.name)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package bn256
|
package bn256
|
||||||
|
|
||||||
// For details of the algorithms used, see "Multiplication and Squaring on
|
// For details of the algorithms used, see "Multiplication and Squaring on
|
||||||
// Pairing-Friendly Fields, Devegili et al.
|
// Pairing-Friendly Fields", Devegili et al.
|
||||||
// http://eprint.iacr.org/2006/471.pdf.
|
// http://eprint.iacr.org/2006/471.pdf.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package bn256
|
package bn256
|
||||||
|
|
||||||
// For details of the algorithms used, see "Multiplication and Squaring on
|
// For details of the algorithms used, see "Multiplication and Squaring on
|
||||||
// Pairing-Friendly Fields, Devegili et al.
|
// Pairing-Friendly Fields", Devegili et al.
|
||||||
// http://eprint.iacr.org/2006/471.pdf.
|
// http://eprint.iacr.org/2006/471.pdf.
|
||||||
|
|
||||||
// gfP2 implements a field of size p² as a quadratic extension of the base field
|
// gfP2 implements a field of size p² as a quadratic extension of the base field
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package bn256
|
package bn256
|
||||||
|
|
||||||
// For details of the algorithms used, see "Multiplication and Squaring on
|
// For details of the algorithms used, see "Multiplication and Squaring on
|
||||||
// Pairing-Friendly Fields, Devegili et al.
|
// Pairing-Friendly Fields", Devegili et al.
|
||||||
// http://eprint.iacr.org/2006/471.pdf.
|
// http://eprint.iacr.org/2006/471.pdf.
|
||||||
|
|
||||||
// gfP6 implements the field of size p⁶ as a cubic extension of gfP2 where τ³=ξ
|
// gfP6 implements the field of size p⁶ as a cubic extension of gfP2 where τ³=ξ
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
package bn256
|
package bn256
|
||||||
|
|
||||||
// For details of the algorithms used, see "Multiplication and Squaring on
|
// For details of the algorithms used, see "Multiplication and Squaring on
|
||||||
// Pairing-Friendly Fields, Devegili et al.
|
// Pairing-Friendly Fields", Devegili et al.
|
||||||
// http://eprint.iacr.org/2006/471.pdf.
|
// http://eprint.iacr.org/2006/471.pdf.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
package bn256
|
package bn256
|
||||||
|
|
||||||
// For details of the algorithms used, see "Multiplication and Squaring on
|
// For details of the algorithms used, see "Multiplication and Squaring on
|
||||||
// Pairing-Friendly Fields, Devegili et al.
|
// Pairing-Friendly Fields", Devegili et al.
|
||||||
// http://eprint.iacr.org/2006/471.pdf.
|
// http://eprint.iacr.org/2006/471.pdf.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
package bn256
|
package bn256
|
||||||
|
|
||||||
// For details of the algorithms used, see "Multiplication and Squaring on
|
// For details of the algorithms used, see "Multiplication and Squaring on
|
||||||
// Pairing-Friendly Fields, Devegili et al.
|
// Pairing-Friendly Fields", Devegili et al.
|
||||||
// http://eprint.iacr.org/2006/471.pdf.
|
// http://eprint.iacr.org/2006/471.pdf.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
# - A constraint describing the requirements of the law, called "require"
|
# - A constraint describing the requirements of the law, called "require"
|
||||||
# * Implementations are transliterated into functions that operate as well on
|
# * Implementations are transliterated into functions that operate as well on
|
||||||
# algebraic input points, and are called once per combination of branches
|
# algebraic input points, and are called once per combination of branches
|
||||||
# exectured. Each execution returns:
|
# executed. Each execution returns:
|
||||||
# - A constraint describing the assumptions this implementation requires
|
# - A constraint describing the assumptions this implementation requires
|
||||||
# (such as Z1=1), called "assumeFormula"
|
# (such as Z1=1), called "assumeFormula"
|
||||||
# - A constraint describing the assumptions this specific branch requires,
|
# - A constraint describing the assumptions this specific branch requires,
|
||||||
|
|||||||
@@ -193,11 +193,16 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||||||
chainConfig.CancunTime = config.OverridePassedForkTime
|
chainConfig.CancunTime = config.OverridePassedForkTime
|
||||||
chainConfig.HaberTime = config.OverridePassedForkTime
|
chainConfig.HaberTime = config.OverridePassedForkTime
|
||||||
chainConfig.HaberFixTime = config.OverridePassedForkTime
|
chainConfig.HaberFixTime = config.OverridePassedForkTime
|
||||||
|
chainConfig.BohrTime = config.OverridePassedForkTime
|
||||||
overrides.OverridePassedForkTime = config.OverridePassedForkTime
|
overrides.OverridePassedForkTime = config.OverridePassedForkTime
|
||||||
}
|
}
|
||||||
if config.OverrideBohr != nil {
|
if config.OverridePascal != nil {
|
||||||
chainConfig.BohrTime = config.OverrideBohr
|
chainConfig.PascalTime = config.OverridePascal
|
||||||
overrides.OverrideBohr = config.OverrideBohr
|
overrides.OverridePascal = config.OverridePascal
|
||||||
|
}
|
||||||
|
if config.OverridePrague != nil {
|
||||||
|
chainConfig.PragueTime = config.OverridePrague
|
||||||
|
overrides.OverridePrague = config.OverridePrague
|
||||||
}
|
}
|
||||||
if config.OverrideVerkle != nil {
|
if config.OverrideVerkle != nil {
|
||||||
chainConfig.VerkleTime = config.OverrideVerkle
|
chainConfig.VerkleTime = config.OverrideVerkle
|
||||||
|
|||||||
114
eth/blacklist.go
114
eth/blacklist.go
@@ -1,114 +0,0 @@
|
|||||||
package eth
|
|
||||||
|
|
||||||
import (
|
|
||||||
"container/heap"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Implements the heap.Interface for *BlackListPeer based on LastSeen
|
|
||||||
type PeerHeap []*BlackListPeer
|
|
||||||
|
|
||||||
func (h PeerHeap) Len() int { return len(h) }
|
|
||||||
func (h PeerHeap) Less(i, j int) bool { return h[i].LastSeen.Before(h[j].LastSeen) }
|
|
||||||
func (h PeerHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i]; h[i].index = i; h[j].index = j }
|
|
||||||
|
|
||||||
func (h *PeerHeap) Push(x interface{}) {
|
|
||||||
n := len(*h)
|
|
||||||
item := x.(*BlackListPeer)
|
|
||||||
item.index = n
|
|
||||||
*h = append(*h, item)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *PeerHeap) Pop() interface{} {
|
|
||||||
old := *h
|
|
||||||
n := len(old)
|
|
||||||
item := old[n-1]
|
|
||||||
item.index = -1 // for safety
|
|
||||||
*h = old[0 : n-1]
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
|
|
||||||
// Peer represents the state of a peer in the network.
|
|
||||||
type BlackListPeer struct {
|
|
||||||
ID string // Unique identifier for the peer
|
|
||||||
HeadBlock int64 // Current head block of the peer
|
|
||||||
LastSeen time.Time // Timestamp of the last head block update
|
|
||||||
BlacklistCount int // Counter for failed head block updates
|
|
||||||
index int // Index of the peer in the heap
|
|
||||||
}
|
|
||||||
|
|
||||||
// blackList manages peers, both active and blacklisted.
|
|
||||||
type blackList struct {
|
|
||||||
mu sync.Mutex // To handle concurrent access
|
|
||||||
peers map[string]*BlackListPeer
|
|
||||||
peerHeap PeerHeap
|
|
||||||
maxPeers int
|
|
||||||
expiryTime time.Duration
|
|
||||||
blacklistedCount int
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewBlackList creates a new instance of blackList.
|
|
||||||
func NewBlackList(maxPeers int, expiryTime time.Duration, blacklistedCount int) *blackList {
|
|
||||||
bl := &blackList{
|
|
||||||
peers: make(map[string]*BlackListPeer),
|
|
||||||
peerHeap: make(PeerHeap, 0, maxPeers),
|
|
||||||
maxPeers: maxPeers,
|
|
||||||
expiryTime: expiryTime,
|
|
||||||
blacklistedCount: blacklistedCount,
|
|
||||||
}
|
|
||||||
heap.Init(&bl.peerHeap)
|
|
||||||
return bl
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddOrUpdatePeer adds or updates a peer in the map, rejecting invalid IDs.
|
|
||||||
func (bl *blackList) AddOrUpdatePeer(id string, headBlock int64) {
|
|
||||||
if id == "" {
|
|
||||||
return // Reject empty ID
|
|
||||||
}
|
|
||||||
|
|
||||||
bl.mu.Lock()
|
|
||||||
defer bl.mu.Unlock()
|
|
||||||
|
|
||||||
peer, exists := bl.peers[id]
|
|
||||||
if exists {
|
|
||||||
if peer.HeadBlock != headBlock {
|
|
||||||
peer.HeadBlock = headBlock
|
|
||||||
peer.LastSeen = time.Now()
|
|
||||||
peer.BlacklistCount = 0
|
|
||||||
heap.Fix(&bl.peerHeap, peer.index)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if len(bl.peers) >= bl.maxPeers {
|
|
||||||
oldest := heap.Pop(&bl.peerHeap).(*BlackListPeer)
|
|
||||||
delete(bl.peers, oldest.ID) // Corrected to use ID
|
|
||||||
}
|
|
||||||
newPeer := &BlackListPeer{
|
|
||||||
ID: id, HeadBlock: headBlock, LastSeen: time.Now(), BlacklistCount: 0,
|
|
||||||
}
|
|
||||||
bl.peers[id] = newPeer
|
|
||||||
heap.Push(&bl.peerHeap, newPeer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// BlacklistStalePeers updates the blacklist count of stale peers.
|
|
||||||
func (bl *blackList) BlacklistStalePeers() {
|
|
||||||
bl.mu.Lock()
|
|
||||||
defer bl.mu.Unlock()
|
|
||||||
|
|
||||||
now := time.Now()
|
|
||||||
for _, peer := range bl.peers {
|
|
||||||
if now.Sub(peer.LastSeen) > bl.expiryTime {
|
|
||||||
peer.BlacklistCount++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsBlacklisted checks if a peer is blacklisted.
|
|
||||||
func (bl *blackList) IsBlacklisted(id string) bool {
|
|
||||||
bl.mu.Lock()
|
|
||||||
defer bl.mu.Unlock()
|
|
||||||
|
|
||||||
peer, exists := bl.peers[id]
|
|
||||||
return exists && peer.BlacklistCount >= bl.blacklistedCount
|
|
||||||
}
|
|
||||||
@@ -1,161 +0,0 @@
|
|||||||
package eth
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sync"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TestAddOrUpdatePeer tests adding new peers and updating existing ones.
|
|
||||||
func TestAddOrUpdatePeer(t *testing.T) {
|
|
||||||
bl := NewBlackList(2, 10*time.Minute, 3)
|
|
||||||
bl.AddOrUpdatePeer("peer1", 100)
|
|
||||||
if len(bl.peers) != 1 {
|
|
||||||
t.Errorf("Expected 1 peer, got %d", len(bl.peers))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test updating the same peer
|
|
||||||
bl.AddOrUpdatePeer("peer1", 101)
|
|
||||||
if bl.peers["peer1"].HeadBlock != 101 {
|
|
||||||
t.Errorf("Expected head block 101, got %d", bl.peers["peer1"].HeadBlock)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test adding another peer and triggering the maxPeers limit
|
|
||||||
bl.AddOrUpdatePeer("peer2", 102)
|
|
||||||
bl.AddOrUpdatePeer("peer3", 103) // This should remove the oldest (peer1)
|
|
||||||
if len(bl.peers) != 2 {
|
|
||||||
t.Errorf("Expected 2 peers, got %d", len(bl.peers))
|
|
||||||
}
|
|
||||||
if _, exists := bl.peers["peer1"]; exists {
|
|
||||||
t.Errorf("Expected peer1 to be removed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestBlacklistStalePeers tests the automatic blacklisting of stale peers.
|
|
||||||
func TestBlacklistStalePeers(t *testing.T) {
|
|
||||||
bl := NewBlackList(2, 1*time.Minute, 1)
|
|
||||||
bl.AddOrUpdatePeer("peer1", 100)
|
|
||||||
time.Sleep(2 * time.Minute) // simulate time passing
|
|
||||||
bl.BlacklistStalePeers()
|
|
||||||
|
|
||||||
if bl.peers["peer1"].BlacklistCount != 1 {
|
|
||||||
t.Errorf("Expected BlacklistCount of 1, got %d", bl.peers["peer1"].BlacklistCount)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestIsBlacklisted tests checking if a peer is blacklisted.
|
|
||||||
func TestIsBlacklisted(t *testing.T) {
|
|
||||||
bl := NewBlackList(2, 1*time.Minute, 1)
|
|
||||||
bl.AddOrUpdatePeer("peer1", 100)
|
|
||||||
bl.peers["peer1"].LastSeen = time.Now().Add(-2 * time.Minute) // make peer stale
|
|
||||||
bl.BlacklistStalePeers()
|
|
||||||
|
|
||||||
if !bl.IsBlacklisted("peer1") {
|
|
||||||
t.Errorf("Expected peer1 to be blacklisted")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestEdgeCases tests handling of edge cases such as invalid IDs.
|
|
||||||
func TestEdgeCases(t *testing.T) {
|
|
||||||
bl := NewBlackList(2, 1*time.Minute, 1)
|
|
||||||
bl.AddOrUpdatePeer("", 100) // testing with empty ID
|
|
||||||
if len(bl.peers) != 0 {
|
|
||||||
t.Errorf("Expected 0 peers, got %d", len(bl.peers))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestAddOrUpdatePeer_MaxPeers tests behavior when adding peers up to and beyond the maximum limit.
|
|
||||||
func TestAddOrUpdatePeer_MaxPeers(t *testing.T) {
|
|
||||||
bl := NewBlackList(3, 10*time.Minute, 3)
|
|
||||||
|
|
||||||
bl.AddOrUpdatePeer("peer1", 100)
|
|
||||||
bl.AddOrUpdatePeer("peer2", 101)
|
|
||||||
bl.AddOrUpdatePeer("peer3", 102)
|
|
||||||
bl.AddOrUpdatePeer("peer4", 103) // This should remove peer1
|
|
||||||
|
|
||||||
if len(bl.peers) != 3 {
|
|
||||||
t.Errorf("Expected 3 peers, got %d", len(bl.peers))
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, exists := bl.peers["peer1"]; exists {
|
|
||||||
t.Errorf("Expected peer1 to be removed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestBlacklistCountOverflow checks how the system handles when a peer's BlacklistCount exceeds the threshold.
|
|
||||||
func TestBlacklistCountOverflow(t *testing.T) {
|
|
||||||
bl := NewBlackList(2, 1*time.Second, 2)
|
|
||||||
bl.AddOrUpdatePeer("peer1", 100)
|
|
||||||
|
|
||||||
// Simulate multiple blacklist increments
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
bl.BlacklistStalePeers()
|
|
||||||
bl.BlacklistStalePeers()
|
|
||||||
|
|
||||||
if !bl.IsBlacklisted("peer1") {
|
|
||||||
t.Errorf("Expected peer1 to be blacklisted after exceeding blacklist count")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestExpiryTimeBoundary tests behavior when a peer's LastSeen is exactly at the expiry boundary.
|
|
||||||
func TestExpiryTimeBoundary(t *testing.T) {
|
|
||||||
bl := NewBlackList(2, 1*time.Second, 2)
|
|
||||||
bl.AddOrUpdatePeer("peer1", 100)
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
|
|
||||||
bl.BlacklistStalePeers() // Should increment blacklist count but not blacklisted yet
|
|
||||||
|
|
||||||
if bl.peers["peer1"].BlacklistCount != 1 {
|
|
||||||
t.Errorf("Expected BlacklistCount of 1, got %d", bl.peers["peer1"].BlacklistCount)
|
|
||||||
}
|
|
||||||
|
|
||||||
if bl.IsBlacklisted("peer1") {
|
|
||||||
t.Errorf("Peer1 should not be blacklisted yet")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestConcurrentAccess tests concurrent access to the blackList.
|
|
||||||
func TestConcurrentAccess(t *testing.T) {
|
|
||||||
bl := NewBlackList(100, 10*time.Minute, 3)
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
|
|
||||||
for i := 0; i < 50; i++ {
|
|
||||||
wg.Add(1)
|
|
||||||
go func(id string) {
|
|
||||||
defer wg.Done()
|
|
||||||
bl.AddOrUpdatePeer(id, int64(i))
|
|
||||||
}(string(rune('a' + i)))
|
|
||||||
}
|
|
||||||
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
if len(bl.peers) != 50 {
|
|
||||||
t.Errorf("Expected 50 peers, got %d", len(bl.peers))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestReaddingBlacklistedPeer tests the behavior when a blacklisted peer is re-added.
|
|
||||||
func TestReaddingBlacklistedPeer(t *testing.T) {
|
|
||||||
bl := NewBlackList(2, 1*time.Second, 1)
|
|
||||||
bl.AddOrUpdatePeer("peer1", 100)
|
|
||||||
|
|
||||||
// Simulate time passing to trigger blacklist
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
bl.BlacklistStalePeers()
|
|
||||||
|
|
||||||
// Ensure peer1 is blacklisted
|
|
||||||
if !bl.IsBlacklisted("peer1") {
|
|
||||||
t.Errorf("Expected peer1 to be blacklisted")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Re-add the same peer
|
|
||||||
bl.AddOrUpdatePeer("peer1", 101)
|
|
||||||
|
|
||||||
if bl.peers["peer1"].BlacklistCount != 0 {
|
|
||||||
t.Errorf("Expected BlacklistCount to be reset, got %d", bl.peers["peer1"].BlacklistCount)
|
|
||||||
}
|
|
||||||
|
|
||||||
if bl.IsBlacklisted("peer1") {
|
|
||||||
t.Errorf("Peer1 should not be blacklisted after re-adding with updated information")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -191,8 +191,11 @@ type Config struct {
|
|||||||
// OverridePassedForkTime
|
// OverridePassedForkTime
|
||||||
OverridePassedForkTime *uint64 `toml:",omitempty"`
|
OverridePassedForkTime *uint64 `toml:",omitempty"`
|
||||||
|
|
||||||
// OverrideBohr (TODO: remove after the fork)
|
// OverridePascal (TODO: remove after the fork)
|
||||||
OverrideBohr *uint64 `toml:",omitempty"`
|
OverridePascal *uint64 `toml:",omitempty"`
|
||||||
|
|
||||||
|
// OverridePrague (TODO: remove after the fork)
|
||||||
|
OverridePrague *uint64 `toml:",omitempty"`
|
||||||
|
|
||||||
// OverrideVerkle (TODO: remove after the fork)
|
// OverrideVerkle (TODO: remove after the fork)
|
||||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||||||
RPCEVMTimeout time.Duration
|
RPCEVMTimeout time.Duration
|
||||||
RPCTxFeeCap float64
|
RPCTxFeeCap float64
|
||||||
OverridePassedForkTime *uint64 `toml:",omitempty"`
|
OverridePassedForkTime *uint64 `toml:",omitempty"`
|
||||||
OverrideBohr *uint64 `toml:",omitempty"`
|
OverridePascal *uint64 `toml:",omitempty"`
|
||||||
|
OverridePrague *uint64 `toml:",omitempty"`
|
||||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||||
BlobExtraReserve uint64
|
BlobExtraReserve uint64
|
||||||
}
|
}
|
||||||
@@ -130,7 +131,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||||||
enc.RPCEVMTimeout = c.RPCEVMTimeout
|
enc.RPCEVMTimeout = c.RPCEVMTimeout
|
||||||
enc.RPCTxFeeCap = c.RPCTxFeeCap
|
enc.RPCTxFeeCap = c.RPCTxFeeCap
|
||||||
enc.OverridePassedForkTime = c.OverridePassedForkTime
|
enc.OverridePassedForkTime = c.OverridePassedForkTime
|
||||||
enc.OverrideBohr = c.OverrideBohr
|
enc.OverridePascal = c.OverridePascal
|
||||||
|
enc.OverridePrague = c.OverridePrague
|
||||||
enc.OverrideVerkle = c.OverrideVerkle
|
enc.OverrideVerkle = c.OverrideVerkle
|
||||||
enc.BlobExtraReserve = c.BlobExtraReserve
|
enc.BlobExtraReserve = c.BlobExtraReserve
|
||||||
return &enc, nil
|
return &enc, nil
|
||||||
@@ -193,7 +195,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||||||
RPCEVMTimeout *time.Duration
|
RPCEVMTimeout *time.Duration
|
||||||
RPCTxFeeCap *float64
|
RPCTxFeeCap *float64
|
||||||
OverridePassedForkTime *uint64 `toml:",omitempty"`
|
OverridePassedForkTime *uint64 `toml:",omitempty"`
|
||||||
OverrideBohr *uint64 `toml:",omitempty"`
|
OverridePascal *uint64 `toml:",omitempty"`
|
||||||
|
OverridePrague *uint64 `toml:",omitempty"`
|
||||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||||
BlobExtraReserve *uint64
|
BlobExtraReserve *uint64
|
||||||
}
|
}
|
||||||
@@ -363,8 +366,11 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||||||
if dec.OverridePassedForkTime != nil {
|
if dec.OverridePassedForkTime != nil {
|
||||||
c.OverridePassedForkTime = dec.OverridePassedForkTime
|
c.OverridePassedForkTime = dec.OverridePassedForkTime
|
||||||
}
|
}
|
||||||
if dec.OverrideBohr != nil {
|
if dec.OverridePascal != nil {
|
||||||
c.OverrideBohr = dec.OverrideBohr
|
c.OverridePascal = dec.OverridePascal
|
||||||
|
}
|
||||||
|
if dec.OverridePrague != nil {
|
||||||
|
c.OverridePrague = dec.OverridePrague
|
||||||
}
|
}
|
||||||
if dec.OverrideVerkle != nil {
|
if dec.OverrideVerkle != nil {
|
||||||
c.OverrideVerkle = dec.OverrideVerkle
|
c.OverrideVerkle = dec.OverrideVerkle
|
||||||
|
|||||||
@@ -868,9 +868,9 @@ func (f *BlockFetcher) importHeaders(op *blockOrHeaderInject) {
|
|||||||
parent := f.getHeader(header.ParentHash)
|
parent := f.getHeader(header.ParentHash)
|
||||||
if parent == nil {
|
if parent == nil {
|
||||||
log.Debug("Unknown parent of propagated header", "peer", peer, "number", header.Number, "hash", hash, "parent", header.ParentHash)
|
log.Debug("Unknown parent of propagated header", "peer", peer, "number", header.Number, "hash", hash, "parent", header.ParentHash)
|
||||||
time.Sleep(reQueueBlockTimeout)
|
|
||||||
// forget block first, then re-queue
|
// forget block first, then re-queue
|
||||||
f.done <- hash
|
f.done <- hash
|
||||||
|
time.Sleep(reQueueBlockTimeout)
|
||||||
f.requeue <- op
|
f.requeue <- op
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -909,9 +909,9 @@ func (f *BlockFetcher) importBlocks(op *blockOrHeaderInject) {
|
|||||||
parent := f.getBlock(block.ParentHash())
|
parent := f.getBlock(block.ParentHash())
|
||||||
if parent == nil {
|
if parent == nil {
|
||||||
log.Debug("Unknown parent of propagated block", "peer", peer, "number", block.Number(), "hash", hash, "parent", block.ParentHash())
|
log.Debug("Unknown parent of propagated block", "peer", peer, "number", block.Number(), "hash", hash, "parent", block.ParentHash())
|
||||||
time.Sleep(reQueueBlockTimeout)
|
|
||||||
// forget block first, then re-queue
|
// forget block first, then re-queue
|
||||||
f.done <- hash
|
f.done <- hash
|
||||||
|
time.Sleep(reQueueBlockTimeout)
|
||||||
f.requeue <- op
|
f.requeue <- op
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,8 +172,6 @@ type handler struct {
|
|||||||
|
|
||||||
handlerStartCh chan struct{}
|
handlerStartCh chan struct{}
|
||||||
handlerDoneCh chan struct{}
|
handlerDoneCh chan struct{}
|
||||||
|
|
||||||
blackList *blackList
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// newHandler returns a handler for all Ethereum chain management protocol.
|
// newHandler returns a handler for all Ethereum chain management protocol.
|
||||||
@@ -323,21 +321,14 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
|||||||
|
|
||||||
broadcastBlockWithCheck := func(block *types.Block, propagate bool) {
|
broadcastBlockWithCheck := func(block *types.Block, propagate bool) {
|
||||||
if propagate {
|
if propagate {
|
||||||
checkErrs := make(chan error, 2)
|
if !(block.Header().WithdrawalsHash == nil && block.Withdrawals() == nil) &&
|
||||||
|
!(block.Header().EmptyWithdrawalsHash() && block.Withdrawals() != nil && len(block.Withdrawals()) == 0) {
|
||||||
go func() {
|
log.Error("Propagated block has invalid withdrawals")
|
||||||
checkErrs <- core.ValidateListsInBody(block)
|
|
||||||
}()
|
|
||||||
go func() {
|
|
||||||
checkErrs <- core.IsDataAvailable(h.chain, block)
|
|
||||||
}()
|
|
||||||
|
|
||||||
for i := 0; i < cap(checkErrs); i++ {
|
|
||||||
err := <-checkErrs
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Propagating invalid block", "number", block.Number(), "hash", block.Hash(), "err", err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if err := core.IsDataAvailable(h.chain, block); err != nil {
|
||||||
|
log.Error("Propagating block with invalid sidecars", "number", block.Number(), "hash", block.Hash(), "err", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h.BroadcastBlock(block, propagate)
|
h.BroadcastBlock(block, propagate)
|
||||||
@@ -704,7 +695,6 @@ func (h *handler) unregisterPeer(id string) {
|
|||||||
func (h *handler) Start(maxPeers int, maxPeersPerIP int) {
|
func (h *handler) Start(maxPeers int, maxPeersPerIP int) {
|
||||||
h.maxPeers = maxPeers
|
h.maxPeers = maxPeers
|
||||||
h.maxPeersPerIP = maxPeersPerIP
|
h.maxPeersPerIP = maxPeersPerIP
|
||||||
h.blackList = NewBlackList(maxPeers, 1*time.Hour, 3)
|
|
||||||
// broadcast and announce transactions (only new ones, not resurrected ones)
|
// broadcast and announce transactions (only new ones, not resurrected ones)
|
||||||
h.wg.Add(1)
|
h.wg.Add(1)
|
||||||
h.txsCh = make(chan core.NewTxsEvent, txChanSize)
|
h.txsCh = make(chan core.NewTxsEvent, txChanSize)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/forkid"
|
"github.com/ethereum/go-ethereum/core/forkid"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ var ProtocolVersions = []uint{ETH68}
|
|||||||
var protocolLengths = map[uint]uint64{ETH68: 17}
|
var protocolLengths = map[uint]uint64{ETH68: 17}
|
||||||
|
|
||||||
// maxMessageSize is the maximum cap on the size of a protocol message.
|
// maxMessageSize is the maximum cap on the size of a protocol message.
|
||||||
const maxMessageSize = 10 * 1024 * 1024
|
var maxMessageSize = params.MaxMessageSize
|
||||||
|
|
||||||
const (
|
const (
|
||||||
StatusMsg = 0x00
|
StatusMsg = 0x00
|
||||||
|
|||||||
@@ -248,6 +248,9 @@ func (h *handler) doSync(op *chainSyncOp) error {
|
|||||||
// degenerate connectivity, but it should be healthy for the mainnet too to
|
// degenerate connectivity, but it should be healthy for the mainnet too to
|
||||||
// more reliably update peers or the local TD state.
|
// more reliably update peers or the local TD state.
|
||||||
if block := h.chain.GetBlock(head.Hash(), head.Number.Uint64()); block != nil {
|
if block := h.chain.GetBlock(head.Hash(), head.Number.Uint64()); block != nil {
|
||||||
|
if h.chain.Config().IsCancun(block.Number(), block.Time()) {
|
||||||
|
block = block.WithSidecars(h.chain.GetSidecarsByHash(block.Hash()))
|
||||||
|
}
|
||||||
h.BroadcastBlock(block, false)
|
h.BroadcastBlock(block, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -737,7 +736,7 @@ func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) er
|
|||||||
//
|
//
|
||||||
// If the transaction was a contract creation use the TransactionReceipt method to get the
|
// If the transaction was a contract creation use the TransactionReceipt method to get the
|
||||||
// contract address after the transaction has been mined.
|
// contract address after the transaction has been mined.
|
||||||
func (ec *Client) SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts ethapi.TransactionOpts) error {
|
func (ec *Client) SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts types.TransactionOpts) error {
|
||||||
data, err := tx.MarshalBinary()
|
data, err := tx.MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
@@ -770,9 +769,9 @@ func sendTransactionConditional(ec *Client) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
root := common.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
|
root := common.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
|
||||||
return ec.SendTransactionConditional(context.Background(), tx, ethapi.TransactionOpts{
|
return ec.SendTransactionConditional(context.Background(), tx, types.TransactionOpts{
|
||||||
KnownAccounts: map[common.Address]ethapi.AccountStorage{
|
KnownAccounts: map[common.Address]types.AccountStorage{
|
||||||
testAddr: ethapi.AccountStorage{
|
testAddr: types.AccountStorage{
|
||||||
StorageRoot: &root,
|
StorageRoot: &root,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
"github.com/ethereum/go-ethereum/eth/filters"
|
"github.com/ethereum/go-ethereum/eth/filters"
|
||||||
"github.com/ethereum/go-ethereum/ethclient"
|
"github.com/ethereum/go-ethereum/ethclient"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
@@ -39,7 +38,7 @@ import (
|
|||||||
|
|
||||||
// TransactionConditionalSender injects the conditional transaction into the pending pool for execution after verification.
|
// TransactionConditionalSender injects the conditional transaction into the pending pool for execution after verification.
|
||||||
type TransactionConditionalSender interface {
|
type TransactionConditionalSender interface {
|
||||||
SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts ethapi.TransactionOpts) error
|
SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts types.TransactionOpts) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client exposes the methods provided by the Ethereum RPC client.
|
// Client exposes the methods provided by the Ethereum RPC client.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user