Skip to content

MNT Part 2: feat(state): add MNT state support - #28

Open
ping-ke wants to merge 2 commits into
feature/mnt-core-typesfrom
feature/mnt-state
Open

MNT Part 2: feat(state): add MNT state support#28
ping-ke wants to merge 2 commits into
feature/mnt-core-typesfrom
feature/mnt-state

Conversation

@ping-ke

@ping-ke ping-ke commented Jul 5, 2026

Copy link
Copy Markdown

Summary

  • Add MNT balance read and write support to StateDB and state objects.
  • Support journaling, revert, state copy, and empty-account checks for MNT balances.
  • Propagate FullShardKey when creating accounts.
  • Preserve QKC account encoding across MPT/UBT commits and pathdb history recovery.

Notes

This PR is based on feature/mnt-core-types. The default QKC token continues to use the existing balance APIs, while other native tokens use the new MNT APIs.

Comment thread core/state/statedb.go
Comment thread core/state/database_mpt.go Outdated
Comment thread core/state/state_object.go
@blockchaindevsh

Copy link
Copy Markdown

This PR is stacked on #24, so the base shouldn't be gobase/base.

Comment thread tools/verify_state/main.go Outdated
Comment thread triedb/pathdb/execute.go Outdated
@ping-ke
ping-ke changed the base branch from goshard/base to feature/mnt-core-types July 10, 2026 03:20
@ping-ke
ping-ke force-pushed the feature/mnt-state branch from 1f8eff7 to c4a732c Compare July 17, 2026 02:10
@ping-ke
ping-ke force-pushed the feature/mnt-core-types branch from 53e97c4 to 56fa444 Compare July 24, 2026 04:05
@ping-ke
ping-ke force-pushed the feature/mnt-core-types branch from 56fa444 to 61adf84 Compare August 3, 2026 04:12
@ping-ke
ping-ke force-pushed the feature/mnt-state branch from fb5eb96 to 2623b83 Compare August 3, 2026 08:17
@ping-ke
ping-ke force-pushed the feature/mnt-core-types branch from ceef3d7 to 7ef2bab Compare August 5, 2026 10:19
@ping-ke
ping-ke force-pushed the feature/mnt-state branch 2 times, most recently from d9ea7ce to d514d05 Compare August 6, 2026 03:39
@ping-ke ping-ke changed the title feat(state): add MNT state layer, common token codec, tools feat(state): add MNT state layer, common token codec Aug 10, 2026
@ping-ke
ping-ke force-pushed the feature/mnt-state branch from d514d05 to 94486d4 Compare August 10, 2026 09:55
@ping-ke ping-ke changed the title feat(state): add MNT state layer, common token codec feat(state): add MNT state support Aug 10, 2026
@ping-ke ping-ke changed the title feat(state): add MNT state support MNT Part 2: feat(state): add MNT state support Aug 10, 2026
@ping-ke
ping-ke force-pushed the feature/mnt-state branch 4 times, most recently from 87ce75f to 3357d5b Compare August 14, 2026 05:35
@ping-ke
ping-ke force-pushed the feature/mnt-state branch from 88f8ef4 to a3d68df Compare August 19, 2026 08:11
@ping-ke
ping-ke force-pushed the feature/mnt-state branch from a3d68df to d31d1a2 Compare August 24, 2026 07:04
Carry QuarkChain multi-native-token (MNT) balances through the state
layer so accounts can hold per-token balances alongside the native
Ether balance.

- state_object_qkc.go / statedb_qkc.go: MNT balance accessors on
  stateObject and StateDB (Get/Add/Sub/Set), guarding the per-account
  token count against the MNT limit.
- journal.go: journal entries for MNT balance changes so they revert
  correctly with snapshots.
- state_object.go: deep-copy MntBalances in newObject and on copy, so
  a mutation through one object cannot leak into another.
- reader.go: decode MntBalances and FullShardKey out of the slim
  account served by the flat reader.
- database_mpt.go / database_ubt.go: re-encode AccountsOrigin from
  slim-RLP to full QKC account RLP before handing it to pathdb, which
  needs it to match the trie leaf format for history verification.
- pathdb/execute.go: decode AccountsOrigin as a full QKC StateAccount
  instead of slim-RLP, matching the invariant the commit paths now
  establish.

mnt_test.go covers the accessors, journal revert, and copy isolation.
The in-package test adaptations (state_test.go, statedb_fuzz_test.go)
follow the account encoding change.
@ping-ke
ping-ke force-pushed the feature/mnt-state branch from d31d1a2 to a1791e3 Compare August 27, 2026 10:13
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.

3 participants