Skip to content

Conversation

@gzliudan
Copy link
Collaborator

@gzliudan gzliudan commented Apr 1, 2025

Proposed changes

pick the following PRs from geth:

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

gzliudan and others added 15 commits April 1, 2025 17:16
* trie: update tests to check commit integrity

* trie: polish committer

* trie: fix typo

* trie: remove hasvalue notion

According to the benchmarks, type assertion between the pointer and
interface is extremely fast.

BenchmarkIntmethod-12           1000000000               1.91 ns/op
BenchmarkInterface-12           1000000000               2.13 ns/op
BenchmarkTypeSwitch-12          1000000000               1.81 ns/op
BenchmarkTypeAssertion-12       2000000000               1.78 ns/op

So the overhead for asserting whether the shortnode has "valuenode"
child is super tiny. No necessary to have another field.

* trie: linter nitpicks

Co-authored-by: Martin Holst Swende <[email protected]>
* trie: polish commit function

* trie: fix typo
* trie: fix error in stacktrie not committing small roots

* trie: improved tests

* trie: fix error in stacktrie with small nodes

* trie: add (skipped) testcase for stacktrie

* trie: fix docs in stacktrie
The stacktrie is a bit un-untuitive, API-wise: since it mutates input values.
Such behaviour is dangerous, and easy to get wrong if the calling code 'forgets' this quirk. The behaviour is fixed by this PR, so that the input values are not modified by the stacktrie.

Note: just as with the Trie, the stacktrie still references the live input objects, so it's still _not_ safe to mutate the values form the callsite.
* Add missing copyright header

* Update stacktrie_test.go

Co-authored-by: Péter Szilágyi <[email protected]>
Trim the search key from head as it's being pushed deeper into the trie. Previously the search key was never modified but each node kept information how to slice and compare it in keyOffset. Now the keyOffset is not needed as this information is included in the slice of the search key. This way the keyOffset can be removed and key manipulation
simplified.
@gzliudan gzliudan changed the title trie: Stacktrie trie: implement stacktrie and upgrade package trie Apr 1, 2025
@gzliudan gzliudan changed the title trie: implement stacktrie and upgrade package trie trie, core/types: implement stacktrie and DerivableList interface Apr 1, 2025
@gzliudan gzliudan merged commit 5328a63 into XinFinOrg:dev-upgrade Apr 7, 2025
13 checks passed
@gzliudan gzliudan deleted the stacktrie branch April 7, 2025 08:44
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Apr 8, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Apr 12, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jun 6, 2025
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