Commit graph

13979 commits

Author SHA1 Message Date
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
80db09613e
internal/ethapi: refactor RPC tx formatter #33582 (#1940) 2026-01-16 15:52:48 +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
7267895b82
params: improve function BuildConfigIndex() (#1935) 2026-01-16 15:49:03 +05:30
Daniel Liu
09e8b0b812
Dockerfile: remove unused docker files (#1933) 2026-01-16 15:48:31 +05:30
Daniel Liu
bc9bd0cbee
containers/docker: nuke the old docker containers #19164 (#1932) 2026-01-16 15:47:57 +05:30
Daniel Liu
84de57cadc
cicd: store git commit hash into docker image (#1931) 2026-01-16 15:47:16 +05:30
Daniel Liu
0c9fc2b882
params: fix V2 compare issue (#1926) 2026-01-16 15:46:28 +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
wit liu
71f929d990
build: upgrade golangci-lint to v2.7.2 (#1906) 2026-01-06 11:02:56 +05:30
wit liu
3147cf7835
ethapi: fix receiver name warning (#1908) 2026-01-06 11:01:48 +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
Daniel Liu
b6b1c4b779
internal/ethapi: fix recover sender of pending transaction #23765 (#1898) 2026-01-05 15:42:23 +05:30
Daniel Liu
51b99e40a8
miner: fix block number extraction for BlockSigner tx (#1894)
Previously, the code used binary.BigEndian.Uint64(data[8:40]), which incorrectly read the index and only extracted the highest 8 bytes of the 32-byte left-padded block number, resulting in wrong values (often zero).
Now, the code uses new(big.Int).SetBytes(data[4:36]).Uint64() to correctly extract the block number from the proper 32-byte field.
This change fixes both the incorrect index and the parsing logic, ensuring accurate block number extraction and correct validation for special transactions.
2026-01-05 15:41:43 +05:30
Daniel Liu
84ac794e22
consensus: fix missing block header error in vote verification, fix #1850 (#1891)
Previously, vote verification would log errors and fail when the referenced block header was not yet available locally, especially when nodes in the same round processed votes before receiving the block header. This commit changes the logic to defer verification and log at debug level if the header is missing, preventing unnecessary error logs and aligning with upstream geth behavior for out-of-order message arrival during consensus voting.
2026-01-05 15:40:49 +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
adcc0d3652
miner: fix overflow when compare block number (#1895) 2026-01-05 12:15:04 +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
3fb8b87a87
eth/filters: terminate pending tx subscription on error #32794 (#1901) 2026-01-04 17:31:29 +05:30
wit liu
acd3eb93e8
core: use max to simplify function CalcGasLimit (#1902) 2026-01-04 17:30:47 +05:30
wit liu
267222d4a5
all: fix goimports warning (#1903) 2026-01-04 17:22:26 +05:30
Daniel Liu
ca9e69c924
miner: log commit and finalize time for new block (#1904) 2026-01-04 17:21:49 +05:30
Daniel Liu
be5cfd9756
core, miner: log gas limit error when pack transactions (#1905) 2026-01-04 17:21:34 +05:30
wit liu
51e3c866c8
ethapi: fix ineffassign warning (#1907) 2026-01-04 17:21:09 +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
wit liu
1394ea09f0
node: fix error condition in gzipResponseWriter.init() #32896 (#1888) 2025-12-25 09:27:11 +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
Wanwiset Peerapatanapokin
4f89e3fb24
cmd/puppeth: increase gaslimit during genesis block creation (#1851)
* increase gaslimit during genesis block creation for puppeth command

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-23 16:27:03 +05:30
Wanwiset Peerapatanapokin
9a61a4958d
consensus: verify timeout from epochInfo instead of snap.NextEpochCandidates, close XFN-62 (#1850)
* use epochInfo.Masternodes instead of snap.NextEpochCandidates

* remove missing snapshot test (now irrelevant)

* add masternodes length check in getEpochSwitchInfo

* get blockhash directly from vote object
2025-12-23 16:24:54 +05:30
Anil Chinchawale
0f682a8356
Add GitHub Copilot instructions for XDC Network client (#1869)
Added instructions for code review and best practices.
2025-12-23 16:24:36 +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