Commit graph

2165 commits

Author SHA1 Message Date
Daniel Liu
7c5cd0a0f9
core/vm: improved stack swap performance #30249 (#1970) 2026-01-27 08:52:42 +05:30
Daniel Liu
3ce9a1980a
core/vm: fix typo (#1963) 2026-01-27 08:46:49 +05:30
Daniel Liu
3518be8c8b
core/state: move slot RLP encoding into the MPT implementation #27000 (#1162)
Continuing with a series of PRs to make the Trie interface more generic, this PR moves
the RLP encoding of storage slots inside the StateTrie and light.Trie implementations,
as other types of tries don't use RLP.

Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
2026-01-26 18:04:50 +05:30
Daniel Liu
e40208f3db
trie: new empty trie with types.EmptyRootHash instead of null #27230 (#1160) 2026-01-26 18:04:14 +05:30
Daniel Liu
3d194d4303
all: port boring changes from pbss #27176 (#1158)
* all: port boring changes from pbss

* core, trie: address comments from martin

* trie: minor fixes

* core/rawdb: update comment

* core, eth, tests, trie: address comments

* tests, trie: add extra check when update trie database

* trie/triedb/hashdb: degrade the error to warning

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2026-01-26 11:21:46 +05:30
Daniel Liu
43b005c479
txpool: make unreserve idempotent to avoid false non-reserved errors, fix #1975 (#1976) 2026-01-26 11:20:33 +05:30
Daniel Liu
a1b0d5476d
core/txpool: add 7702 protection to blobpool #31526 (#1930) 2026-01-26 11:20:02 +05:30
Daniel Liu
48b6063261
core/txpool/legacypool: reject gapped tx from delegated account #31430 (#1928) 2026-01-21 13:28:23 +05:30
Daniel Liu
96a9c89aa6
core/txpool: move setcode tx validation into legacyPool #31209 (#1927) 2026-01-21 11:13:10 +05:30
Daniel Liu
1f3faa5184
all: set gas limit dynamically (#1945) 2026-01-21 10:49:20 +05:30
Daniel Liu
c27d49c03e
core/txpool/legacypool: add setCodeTx reorg test #31206 (#1924) 2026-01-21 10:48:47 +05:30
Daniel Liu
217b069ec0
core/txpool, types: add support for SetCode transactions #31073 (#1922) 2026-01-19 14:19:34 +05:30
Daniel Liu
3742ed7f2f
core/vm: check if read-only in gas handlers #33281 (#1960) 2026-01-19 14:05:27 +05:30
Daniel Liu
fcd9685c87
core/vm: return early in selfdestruct gas calculation #33450 (#1959) 2026-01-19 14:04:58 +05:30
Daniel Liu
cb48e25ccf
core/txpool: declare address already reserved error #29095 (#1920) 2026-01-19 12:18:08 +05:30
Daniel Liu
f0b523d635
core/vm: remove a redundant zero check in opAddmod #29672 (#1954)
Co-authored-by: Aaron Chen <aaronchen.lisp@gmail.com>
2026-01-19 12:16:20 +05:30
Daniel Liu
6aaad7b72f
core/vm: avoid escape to heap #33537 (#1944) 2026-01-19 11:25:04 +05:30
Daniel Liu
3e1f75eafb
core, eth, miner: 4844 blob transaction pool #26940 (#1911) 2026-01-19 11:24:01 +05:30
Daniel Liu
583338686f
all: expose block number information to statedb #27753 (#1936) 2026-01-16 15:55:04 +05:30
Daniel Liu
283d208fa3
common, core: use min to simplify code (#1939) 2026-01-16 15:53:39 +05:30
Daniel Liu
e764d842da
core/txpool/legacypool: narrow down the scope of the variable #27471 (#1910) 2026-01-16 15:52:12 +05:30
Daniel Liu
6d4670a4ec
core, trie: refactor trie API #26995 (#1147)
In this PR, all TryXXX(e.g. TryGet) APIs of trie are renamed to XXX(e.g. Get) with an error returned.

The original XXX(e.g. Get) APIs are renamed to MustXXX(e.g. MustGet) and does not return any error -- they print a log output. A future PR will change the behaviour to panic on errorrs.

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2026-01-16 15:51:13 +05:30
Daniel Liu
b743f7c61f
core/state: print db failure in case of mismatched hash root #26870 (#1938) 2026-01-16 15:49:27 +05:30
Daniel Liu
939225bd87
core/txpool: improve transaction validate (#1921) 2026-01-16 15:45:07 +05:30
Daniel Liu
86cbf4a897
core/txpool/legacypool: handle genesis state missing #28171 (#1919) 2026-01-16 15:43:43 +05:30
Daniel Liu
dee0e37564
core/txpool/legacypool: remove outdated tests #27662 (#1916) 2026-01-16 15:43:13 +05:30
Daniel Liu
b736bd6967
core/txpool: fix typos (#1915) 2026-01-16 15:42:04 +05:30
Daniel Liu
a7050de4f3
core/txpool: remove use of errors.Join function #27523 (#1914) 2026-01-13 16:51:57 +05:30
Daniel Liu
a7ddd8ac03
core/txpool/legacypool: remove redundant check for floatingRatio #27477 (#1913) 2026-01-13 16:51:21 +05:30
Daniel Liu
4addc980f4
core/txpool/legacypool: reheap the priced list if london fork not enabled #27481 (#1912) 2026-01-13 16:51:02 +05:30
Daniel Liu
d38d746773
core/txpool/legacypool: handle missing head in reset #27479 (#1909) 2026-01-13 16:49:33 +05:30
Daniel Liu
7684d88d3c
core/state, trie: remove Try prefix in Trie accessors #26975 (#1146)
This change renames StateTrie methods to remove the Try* prefix.

We added the Trie methods with prefix 'Try' a long time ago, working
around the problem that most existing methods of Trie did not return the
database error. This weird naming convention has persisted until now.

Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2026-01-05 15:44:42 +05:30
Daniel Liu
b3d354a897
all: move main transaction pool into a subpool #27463 (#1890) 2026-01-05 15:43:50 +05:30
wit liu
2855f1b48c
core, consensus: use slice.Clip capacity to Simplify code (#1892) 2026-01-05 12:16:20 +05:30
Daniel Liu
fb89c95640
core/types: separate special transactions correctly (#1893)
- Refactor NewTransactionsByPriceAndNonce to properly filter and separate special transactions (IsSpecialTransaction)
- Remove account from txs map if it has no normal transactions left
- Update comments for clarity
2026-01-05 12:15:53 +05:30
Daniel Liu
1886219894
core/txpool: use right type for field Txs in NewTxsEvent (#1897)
This commit updates the Txs field in NewTxsEvent to use []*types.Transaction instead of types.Transactions. This ensures type consistency for event broadcasting and handling, improving reliability of transaction propagation across the network. The change also removes unnecessary goroutine usage for txFeed.Send, making event delivery synchronous and safer for downstream consumers.
2026-01-05 12:12:28 +05:30
wit liu
acd3eb93e8
core: use max to simplify function CalcGasLimit (#1902) 2026-01-04 17:30:47 +05:30
Daniel Liu
be5cfd9756
core, miner: log gas limit error when pack transactions (#1905) 2026-01-04 17:21:34 +05:30
Daniel Liu
2a56eccf45
core/types: correct chainId check for pragueSigner #31032 #31054 (#1885) 2025-12-25 10:33:47 +05:30
Daniel Liu
292c0506c0
core/txpool, eth: refactor function IsSigner (#1889) 2025-12-25 09:27:37 +05:30
Daniel Liu
6a3b92b701
core/types: change SetCodeTx.ChainID to uint256 #30982 (#1840) 2025-12-25 09:26:44 +05:30
Daniel Liu
aa8c43caf3
core/txpool: make tx validation reusable across packages/pools #27429 (#1873) 2025-12-23 16:28:30 +05:30
Daniel Liu
3fd03e0814
core, core/types: rename AuthList to SetCodeAuthorizations #30935 (#1884) 2025-12-23 15:40:53 +05:30
Daniel Liu
835579e304
core/txpool: add validation and comprehensive tests for SetGasPrice (#1876)
This commit adds robust input validation to the SetGasPrice method and
implements comprehensive table-driven tests to ensure correct behavior.

Changes in core/txpool/txpool.go:
- Add nil gas price validation with graceful error handling
- Add validation to reject negative gas prices
- Add validation to reject gas prices exceeding 1000 GWei maximum
- Return detailed error messages for each validation failure
- Log warnings when invalid gas prices are rejected

Changes in eth/api_miner.go:
- Update MinerAPI.SetGasPrice to check error return from txPool.SetGasPrice
- Return false when validation fails (when SetGasPrice returns error)
- Return true when validation succeeds (when SetGasPrice returns nil)

New tests in core/txpool/txpool_test.go:
- Implement TestSetGasPrice using table-driven test pattern
- Test 4 invalid cases: nil, negative, exceed max+1, exceed 10000 GWei
- Test 7 valid cases: 0, 1 wei, 1 GWei, 100 GWei, 500 GWei, max-1, max
- Each test case includes expected error value for precise validation
- All 11 test cases verify both error returns and gas price state
- Tests use isolated pool instances to ensure independence
2025-12-23 15:40:24 +05:30
Daniel Liu
3bb3f80f5b
core/state: add account address to Trie slot accessors #26934 (#1140)
This changes the Trie interface to add the plain account address as a
parameter to all storage-related methods.

After the introduction of the TryAccount* functions, TryGet, TryUpdate and
TryDelete are now only meant to read an account's storage. In their current
form, they assume that an account storage is stored in a separate trie, and
that the hashing of the slot is independent of its account's address.

The proposed structure for a stateless storage breaks these two
assumptions: the hashing of a slot key requires the address and all slots
and accounts are stored in a single trie.

This PR therefore adds an address parameter to the interface. It is ignored
in the MPT version, so this change has no functional impact, however it
will reduce the diff size when merging verkle trees.

Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
2025-12-23 15:39:56 +05:30
wit liu
55c2d47c45
all: use 0x-prefix string for type Address in error message (#1835) 2025-12-23 15:39:23 +05:30
wit liu
13b0e39412
core/txpool: remove unused function GetSender (#1886) 2025-12-23 11:56:34 +05:30
Daniel Liu
d78d79add0
core/txpool: allow zero tip transactions with minimum gas price enforcement (#1879)
This commit simplifies the transaction pool's gas price validation logic while
maintaining network security through the existing minimum gas price requirement.

Changes:
- Set default PriceLimit to 0 (was 1), allowing transactions with zero tip
- Remove PriceLimit >= 1 validation in config sanitization
- Simplify Pending() method by using EffectiveGasTipIntCmp consistently
- Unify validateTxBasics() logic to use GasTipCapIntCmp for all transactions

Key Points:
1. Economic Protection: All transactions still require gasPrice >= 12.5 Gwei
   (enforced by GetMinGasPrice check in validateTx), providing sufficient
   protection against DoS attacks even with zero tip.

2. Miner Incentives: Since XDPoSChain includes baseFee in miner rewards
   (unlike standard EIP-1559), miners still earn the full gasPrice even when
   tip is 0. This maintains miner revenue while allowing greater flexibility.

3. Special Transactions: BlockSigner and Randomize contract transactions
   remain exempt from gas price checks, as they are critical for consensus.

4. Code Quality: Reduces complexity by 11 lines and unifies validation logic,
   making the codebase more maintainable.

Security Analysis:
- No nil pointer risks: EffectiveGasTipIntCmp has built-in nil handling
- No DoS vulnerability: 12.5 Gwei minimum ensures economic cost per transaction
- EIP-1559 compatible: Existing minGasPrice check covers all validation needs
- Backward compatible: Only relaxes restrictions, doesn't break existing behavior

This change benefits system transactions and special use cases while maintaining
all existing security guarantees through the network's minimum gas price floor.
2025-12-22 12:51:48 +05:30
Daniel Liu
63783a6b4c
core/state, trie: port changes from PBSS #26763 (#1137)
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-12-22 12:03:56 +05:30
Daniel Liu
8c380e76f5
core, eth/tracers: support debug_traceCall for special tx, fix #1870 (#1872)
- Fix "invalid transaction v, r, s values" error when calling debug_traceCall
  on BlockSigners contract (0x89)
- Fix "nonce too low" error by respecting Message.SkipNonceChecks flag
- ApplySignTransaction now accepts *Message and uses msg.From directly
- Add fallback to signature recovery for real transactions
- Skip nonce validation when SkipNonceChecks=true (for traceCall)
- Add comprehensive unit tests for both scenarios

Root cause: BlockSigners uses special fast-path that calls
ApplySignTransaction directly, which previously attempted signature
recovery on unsigned transactions from debug_traceCall.

Fixes #1870
2025-12-22 12:02:05 +05:30