Skip to content

trie: remove prover parameter 'fromLevel' #27512#1165

Merged
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:simplify-trie-prover
Jan 29, 2026
Merged

trie: remove prover parameter 'fromLevel' #27512#1165
AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:simplify-trie-prover

Conversation

@gzliudan
Copy link
Copy Markdown
Collaborator

Proposed changes

Ref: ethereum#27512

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

This removes the feature where top nodes of the proof can be elided.
It was intended to be used by the LES server, to save bandwidth
when the client had already fetched parts of the state and only needed
some extra nodes to complete the proof. Alas, it never got implemented
in the client.
@gzliudan gzliudan force-pushed the simplify-trie-prover branch from 99bd8b0 to a244527 Compare January 26, 2026 07:31
Copilot AI review requested due to automatic review settings January 26, 2026 07:31
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gzliudan gzliudan changed the title [WIP] trie: remove prover parameter 'fromLevel' #27512 trie: remove prover parameter 'fromLevel' #27512 Jan 26, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the now-unused fromLevel parameter from the core trie proof API and updates all direct call sites to the new signature. The goal is to simplify trie proof generation while keeping existing behavior the same (all previous callers used fromLevel = 0).

Changes:

  • Update (*trie.Trie).Prove and (*trie.StateTrie).Prove to drop the fromLevel argument and simplify the proof construction loop.
  • Adjust the core state.Trie interface and all internal callers (tests, benchmarks, and ethapi code) to use the new Prove(key []byte, proofDb ethdb.KeyValueWriter) signature.
  • Update XDCx/XDCxlending trie wrappers to call the new core Prove signature, though they still expose a deprecated fromLevel parameter in their own APIs.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
trie/trie_test.go Updates randomized trie tests to call Prove without the fromLevel parameter.
trie/tracer_test.go Adjusts tracer-related tests to use the new Prove signature.
trie/proof_test.go Updates proof and range-proof tests and benchmarks to remove the fromLevel argument when calling Prove.
trie/proof.go Removes the fromLevel parameter from Trie.Prove and StateTrie.Prove, simplifying the proof node iteration and updating comments.
internal/ethapi/trie_proof_test.go Aligns transaction and receipt proof tests with the new Prove API.
internal/ethapi/api.go Updates GetTransactionAndReceiptProof to use Prove(key, proofDb) for both transaction and receipt tries.
core/state/database.go Updates the core state.Trie interface so Prove now takes only key and proofDb, matching the new trie API.
XDCxlending/lendingstate/XDCx_trie.go Updates the XDCx lending trie wrapper to delegate to the new core Prove signature, but leaves a now-unused fromLevel parameter in its own method.
XDCx/tradingstate/XDCx_trie.go Updates the XDCx trading trie wrapper to call the new core Prove signature while still exposing an unused fromLevel parameter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -216,5 +216,5 @@ func (t *XDCXTrie) getSecKeyCache() map[string][]byte {
// nodes of the longest existing prefix of the key (at least the root node), ending
// with the node that proves the absence of the key.
func (t *XDCXTrie) Prove(key []byte, fromLevel uint, proofDb ethdb.KeyValueWriter) error {
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XDCXTrie.Prove still exposes a fromLevel parameter even though the underlying trie.Trie.Prove method (and the core state.Trie interface) no longer take it, and the argument is ignored in the body. To fully remove the now-dead fromLevel concept and keep the APIs consistent, consider dropping this parameter from XDCXTrie.Prove and updating the corresponding Trie interface in lendingstate accordingly.

Suggested change
func (t *XDCXTrie) Prove(key []byte, fromLevel uint, proofDb ethdb.KeyValueWriter) error {
func (t *XDCXTrie) Prove(key []byte, proofDb ethdb.KeyValueWriter) error {

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this unused fromLevel be also removed? @gzliudan

@@ -220,5 +220,5 @@ func (t *XDCXTrie) getSecKeyCache() map[string][]byte {
// nodes of the longest existing prefix of the key (at least the root node), ending
// with the node that proves the absence of the key.
func (t *XDCXTrie) Prove(key []byte, fromLevel uint, proofDb ethdb.KeyValueWriter) error {
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XDCXTrie.Prove in the tradingstate package still has a fromLevel parameter that is no longer supported by the underlying trie.Trie.Prove implementation and is effectively ignored here. To avoid confusion and keep the local Trie interface aligned with the core trie API, it would be better to remove this parameter from the method signature and from the tradingstate Trie interface.

Suggested change
func (t *XDCXTrie) Prove(key []byte, fromLevel uint, proofDb ethdb.KeyValueWriter) error {
func (t *XDCXTrie) Prove(key []byte, proofDb ethdb.KeyValueWriter) error {

Copilot uses AI. Check for mistakes.
@AnilChinchawale AnilChinchawale merged commit d12f980 into XinFinOrg:dev-upgrade Jan 29, 2026
19 checks passed
@gzliudan gzliudan deleted the simplify-trie-prover branch January 29, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants