Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8690c40
extend ReadContext to handle huge tx quota
fatcat22 Aug 19, 2025
2a3aa9f
add huge tx config
fatcat22 Aug 19, 2025
97b2a62
add test
fatcat22 Aug 21, 2025
8bd5b0d
Merge branch 'dev' into yz/fat_tx
fatcat22 Aug 25, 2025
8a9ecc2
e2e test(in progress)
fatcat22 Aug 26, 2025
f1bcc66
Merge branch 'dev' into yz/fat_tx
googgoog Aug 26, 2025
2fb4c64
Update hugetx e2e test
googgoog Aug 28, 2025
7b401c5
Merge branch 'dev' into yz/fat_tx
googgoog Aug 28, 2025
2f795a6
Update ci file and apollo config file
googgoog Aug 28, 2025
66878b5
Remove set_hugetx_cfg
googgoog Aug 28, 2025
ea7c583
Fix ci
googgoog Aug 28, 2025
635f553
Revert "Fix ci"
googgoog Aug 28, 2025
5fc9a92
Remove platform limit for mysql container
googgoog Aug 28, 2025
a13cab6
Add more tests
googgoog Aug 28, 2025
2c2dfee
Fix tests
googgoog Aug 28, 2025
b20939a
Add huge tx locaiton check and update kafka image
googgoog Aug 29, 2025
7445d60
Update apollo config file
googgoog Sep 1, 2025
d7acce3
fix: assign p.readContext
fatcat22 Sep 4, 2025
0aa0f83
Update e2e test
googgoog Sep 5, 2025
76bbeab
Update
googgoog Sep 8, 2025
3063df9
fix: skip tx only if it was truely chosen
fatcat22 Sep 9, 2025
d8750f4
Revert "fix: assign p.readContext"
fatcat22 Sep 9, 2025
5495a77
Update test 14
googgoog Sep 11, 2025
c7b3799
Merge remote-tracking branch 'origin/yz/fat_tx_fix2' into cloud/fat_tx
googgoog Sep 11, 2025
e5ca732
Update
googgoog Sep 11, 2025
d386718
Remove useless codes
googgoog Sep 15, 2025
a031cec
Add new tests for tx exceeding block gaslimit
googgoog Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci_zkevm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,31 @@ jobs:
run: sudo -E make test-realtime-e2e
working-directory: test

test-hugetx-e2e:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Make Foundry available to sudo
run: |
FOUNDRY_DIR=$(dirname $(which cast))
sudo ln -sf "$FOUNDRY_DIR/cast" /usr/local/bin/cast
sudo ln -sf "$FOUNDRY_DIR/forge" /usr/local/bin/forge
sudo ln -sf "$FOUNDRY_DIR/anvil" /usr/local/bin/anvil
sudo cast --version

- name: Checkout code
uses: actions/checkout@v3

- name: Build Docker
run: make build-docker

- name: Test
run: sudo -E make test-hugetx-e2e
working-directory: test

# For X Layer
check-chinese-chars:
name: Check Chinese Characters
Expand Down
32 changes: 32 additions & 0 deletions cmd/utils/flags_xlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ var (
Usage: "EnableTimsort enable timsort to instead of built-in sorting",
Value: false,
}
TxPoolHugeTxThresholdRatio = cli.Uint64Flag{
Name: "txpool.huge-tx-threshold-ratio",
Usage: "Percentage threshold of block gas limit to identify huge transactions (0-100)",
Value: 100,
}
TxPoolHugeTxQuotaRatio = cli.Uint64Flag{
Name: "txpool.huge-tx-quota-ratio",
Usage: "Maximum percentage of block gas limit that can be consumed by huge transactions (0-100)",
Value: 100,
}
TxPoolIgnoreHugeTxQuotaInterval = cli.Uint64Flag{
Name: "txpool.ignore-huge-tx-quota-interval",
Usage: "Block interval to ignore huge transaction quota restrictions. Set to 0 to disable huge tx quota entirely",
Value: 0,
}
// OkPay
OkPaySenderAccountsList = cli.StringFlag{
Name: "okpay.sender-accounts-list",
Expand Down Expand Up @@ -602,6 +617,23 @@ func setTxPoolXLayer(ctx *cli.Context, cfg *ethconfig.DeprecatedTxPoolConfig) {
if ctx.IsSet(TxPoolEnableTimsort.Name) {
cfg.EnableTimsort = ctx.Bool(TxPoolEnableTimsort.Name)
}
if ctx.IsSet(TxPoolHugeTxThresholdRatio.Name) {
ratio := ctx.Uint64(TxPoolHugeTxThresholdRatio.Name)
if ratio > 100 {
panic(fmt.Sprintf("huge tx threshold ratio must be less than 100, but got %d", ratio))
}
cfg.HugeTxConfig.HugeTxThresholdRatio = ratio
}
if ctx.IsSet(TxPoolHugeTxQuotaRatio.Name) {
ratio := ctx.Uint64(TxPoolHugeTxQuotaRatio.Name)
if ratio > 100 {
panic(fmt.Sprintf("huge tx quota ratio must be less than 100, but got %d", ratio))
}
cfg.HugeTxConfig.HugeTxQuotaRatio = ratio
}
if ctx.IsSet(TxPoolIgnoreHugeTxQuotaInterval.Name) {
cfg.HugeTxConfig.IgnoreHugeTxQuotaInterval = ctx.Uint64(TxPoolIgnoreHugeTxQuotaInterval.Name)
}

// For OkPay
setOkPayXLayer(ctx, cfg)
Expand Down
11 changes: 11 additions & 0 deletions eth/ethconfig/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ import (
"github.com/ledgerwatch/erigon-lib/txpool/txpoolcfg"
)

type HugeTxConfig struct {
HugeTxThresholdRatio uint64
HugeTxQuotaRatio uint64
IgnoreHugeTxQuotaInterval uint64

// for huge tx e2e test
HugeTxE2EYieldEnabled bool
}

// DeprecatedTxPoolConfig are the configuration parameters of the transaction pool.
type DeprecatedTxPoolConfig struct {
Disable bool
Expand Down Expand Up @@ -69,6 +78,8 @@ type DeprecatedTxPoolConfig struct {
FreeGasList []FreeGasInfo
// EnableTimsort is the switch to use timsort on the best slice of txpool
EnableTimsort bool // For X Layer, optimize the txpool
// HugeTxConfig is the config for huge tx
HugeTxConfig HugeTxConfig

// For X Layer, OkPay config
// OkPaySenderAccountsList is the list of OkPay sender accounts
Expand Down
2 changes: 1 addition & 1 deletion eth/stagedsync/stage_mining_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func getNextTransactions(
remainingBlobGas = cfg.chainConfig.GetMaxBlobGasPerBlock() - *header.BlobGasUsed
}

if _, count, err = cfg.txPool2.YieldBest(amount, &txSlots, poolTx, executionAt, remainingGas, remainingBlobGas, alreadyYielded); err != nil {
if _, count, err = cfg.txPool2.YieldBest(amount, &txSlots, poolTx, executionAt, header.Number.Uint64(), remainingGas, remainingBlobGas, alreadyYielded); err != nil {
return err
}

Expand Down
33 changes: 33 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ DOCKER_APOLLO_ADMINSERVICE := apollo-adminservice
DOCKER_APOLLO_PORTAL := apollo-portal
DOCKER_APOLLO_MYSQL := mysql

# Configuration file for huge transaction tests
HUGETX_CFG_FILE := config/apollo.seq.config.yaml

RUN_DOCKER_BRIDGE_DB := $(DOCKER_COMPOSE) up -d $(DOCKER_BRIDGE_DB)
RUN_DOCKER_BRIDGE_SERVICE := $(DOCKER_COMPOSE) up -d $(DOCKER_BRIDGE_SERVICE)
RUN_DOCKER_BRIDGE_UI := $(DOCKER_COMPOSE) up -d $(DOCKER_BRIDGE_UI)
Expand Down Expand Up @@ -232,6 +235,36 @@ lint:
cd ../docs/endpoints && make check-doc
echo "Lint passed"

PHONY: test-hugetx-e2e
test-hugetx-e2e: stop
$(call set_seal_time,5s)
make apollo
trap '$(STOP) git checkout -- config/apollo.seq.config.yaml; rm -rf ./e2e/tmp' EXIT; MallocNanoZone=0 go test -tags hugetx -count=1 -failfast -race -v -p 1 -timeout 600s ./e2e/huge_tx_test.go
echo "HugeTx E2E tests passed"

.PHONY: set_seal_time
define set_seal_time
@file=$(HUGETX_CFG_FILE); \
key="zkevm.sequencer-block-seal-time"; \
key2="zkevm.sequencer-max-block-seal-time"; \
key3="zkevm.sequencer-batch-seal-time"; \
val="$(1)"; \
num=$${val%[a-zA-Z]*}; \
unit=$${val#$$num}; \
max="$$(($$num*2))$$unit"; \
batch="$$(($$num*3))$$unit"; \
if grep -q "^$$key:" $$file; then :; else echo "$$key: \"$$val\"" >> $$file; fi; \
if grep -q "^$$key2:" $$file; then :; else echo "$$key2: \"$$max\"" >> $$file; fi; \
if grep -q "^$$key3:" $$file; then :; else echo "$$key3: \"$$batch\"" >> $$file; fi; \
sed -i.bak \
-e "s/^$$key:.*/$$key: \"$$val\"/" \
-e "s/^$$key2:.*/$$key2: \"$$max\"/" \
-e "s/^$$key3:.*/$$key3: \"$$batch\"/" $$file; \
rm -f $$file.bak; \
echo "Set $$key=$$val, $$key2=$$max, $$key3=$$batch in $$file"; \
tail -n 15 $$file
endef

.PHONY: test-e2e
test-e2e: stop all ## Runs group xlayer feature e2e tests checking race conditions
sleep 3
Expand Down
6 changes: 2 additions & 4 deletions test/config/apollo.rpc.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ zkevm.datastream-version: 2

log.console.verbosity: info

zkevm.sequencer-block-seal-time: "400ms"
zkevm.sequencer-batch-seal-time: "60s"
zkevm.sequencer-block-seal-time: "6s"
zkevm.sequencer-batch-seal-time: "12s"
zkevm.sequencer-batch-sleep-duration: "0s"

zkevm.data-stream-host: "localhost"
Expand Down Expand Up @@ -71,8 +71,6 @@ txpool.globalslots: 100000
networkid: 195

zkevm.pool-manager-url: http://xlayer-pool-manager:8545

# http.methodratelimit: "{\"methods\":[\"eth_syncing\"],\"count\":10,\"bucket\":1}"
#http.apikeys: |
# {"project":"project1","key":"944cd2a6939eb23053289d9b91d6c498","timeout":"2033-12-12","methods":["eth_syncing"],"count":5,"bucket":1}

Expand Down
24 changes: 13 additions & 11 deletions test/config/apollo.seq.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ zkevm.datastream-version: 2

log.console.verbosity: info

zkevm.sequencer-block-seal-time: "400ms"
zkevm.sequencer-max-block-seal-time: "400ms"
zkevm.sequencer-batch-seal-time: "60s"
zkevm.sequencer-block-seal-time: "1s"
zkevm.sequencer-max-block-seal-time: "3s"
zkevm.sequencer-batch-seal-time: "10s"
zkevm.sequencer-batch-sleep-duration: "0s"

zkevm.data-stream-host: "localhost"
Expand Down Expand Up @@ -69,7 +69,7 @@ db.read.concurrency: 20000
txpool.globalslots: 1000000
txpool.globalbasefeeslots: 1000000
txpool.globalqueue: 1000000
txpool.packbatchspeciallist : ["0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", "0x8f8E2d6cF621f30e9a11309D6A56A876281Fd534", "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"]
txpool.packbatchspeciallist : ["0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"]

txpool.gaspricemultiple : 2
txpool.blockedlist: ["0xdD2FD4581271e230360230F9337D5c0430Bf44C0"]
Expand Down Expand Up @@ -102,31 +102,33 @@ zkevm.seal-batch-immediately-on-overflow: true
zkevm.sequencer-timeout-on-empty-tx-pool: 5ms
zkevm.pre-run-address-list: [""]
zkevm.block-info-concurrent: true
# zkevm.standalone-smt-db: true # true: enable split smt db, false: not split
# zkevm.enable-async-commit: true
zkevm.standalone-smt-db: true # true: enable split smt db, false: not split
zkevm.enable-async-commit: true

# to reduce lock race in stress test
txpool.enabletimsort: true
zkevm.bulk-add-txs: true
zkevm.enable-add-tx-notify: true
zkevm.initial-batch.config: /usr/src/app/first-batch-config.json


zkevm.verification-batch-delay: 2
zkevm.skip-analysis-group-api: true
# zkevm.analysis-group-nacos-urls: "url1:80,url2:80"
# zkevm.analysis-group-nacos-namespace: "ns-global"
# zkevm.analysis-group-service-name: "analysis-group"
# zkevm.analysis-group-api-path: "api/v1/196/validHeight"

# realtime.enable-flag: true
# realtime.enable-subscribe-flag: false
realtime.enable-flag: true
realtime.enable-subscribe-flag: false
realtime.cache-height-threshold: 10
realtime.kafka-sync-bootstrap-servers: "xlayer-kafka:9092"
realtime.kafka-sync-tx-topic: xlayer-tx
realtime.kafka-sync-block-topic: xlayer-header
realtime.kafka-sync-error-topic: xlayer-error
realtime.kafka-sync-client-id: "xlayer-producer"

bridgeIntercept.bridge-contract-address: "0x4B24266C13AFEf2bb60e2C69A4C08A482d81e3CA"
bridgeIntercept.target-token-address: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
bridgeIntercept.max-bridge-amount: "1000000000000000000000"
bridgeIntercept.whitelist-enabled: true
bridgeIntercept.whitelist-addresses: "0x8f8E2d6cF621f30e9a11309D6A56A876281Fd534,0xDE282DC882bbB5100b8A24E30D38a2D5B3080c15"
bridgeIntercept.whitelist-enabled: false
bridgeIntercept.whitelist-addresses: "0x8f8E2d6cF621f30e9a11309D6A56A876281Fd534,0xDE282DC882bbB5100b8A24E30D38a2D5B3080c15"
1 change: 0 additions & 1 deletion test/docker-compose-apollo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ services:

mysql:
container_name: mysql
platform: linux/arm64
image: mysql:8.0
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-password}
Expand Down
2 changes: 1 addition & 1 deletion test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ services:
cdk-erigon --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml

xlayer-kafka:
image: bitnami/kafka:latest
image: bitnamilegacy/kafka:4.0.0-debian-12-r10
container_name: xlayer-kafka
ports:
- 9095:9094
Expand Down
Loading