Skip to content

Conversation

@roman-khimov
Copy link
Member

Very dirty, but works for the single node already:

{
   "result" : {
      "confirmations" : 16,
      "previousblockhash" : "0xdd97476a5dce63960db4165e4319e5bce4bd46387bcb4a98ef5ce0b5b18c0299",
      "nextconsensus" : "NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP",
      "hash" : "0xd5495b7248d3fc32f75413d025898a0c4ee9c082fdf6b21515bd673f1c916f97",
      "nextblockhash" : "0x7c4f827b6aba86b00e2bd92dc05fcb1f816d6563afb0f5a72615152ff70b6b08",
      "merkleroot" : "0x0000000000000000000000000000000000000000000000000000000000000000",
      "time" : 1724964529883,
      "tx" : [],
      "primary" : 0,
      "witnesses" : [
         {
            "verification" : "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEUGe0Nw6",
            "invocation" : "DEDmlzUi0ZN7nhsuNWYVhjBNZPL0zk/8FY99YkO3eL7Q7RVoPrg7TCx1VsIxesj8vOZqDE4ejOd+McS+BHpD6mod"
         }
      ],
      "nonce" : "4D4E17967877AA30",
      "version" : 0,
      "index" : 49,
      "size" : 221
   },
   "jsonrpc" : "2.0",
   "id" : 5
}
{
   "jsonrpc" : "2.0",
   "result" : {
      "hash" : "0x7c4f827b6aba86b00e2bd92dc05fcb1f816d6563afb0f5a72615152ff70b6b08",
      "previousstateroot" : "0xc0914ad1c206e4c042c803402d098d68a81a01360caa79413cd849f028c6e3e9",
      "witnesses" : [
         {
            "invocation" : "DECx6jaOO88kfn9enecBGNoWSOQMkLY71J6Nq0phyUzSy1MTGWGGTem8/0q2QDZEsa39CUPklh4fpP/ZheyGp8aq",
            "verification" : "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEUGe0Nw6"
         }
      ],
      "nextblockhash" : "0x2eca391026670b32532a39a677b1e194faf805ed1d28e0b35fd42f5bf0049399",
      "tx" : [],
      "primary" : 0,
      "confirmations" : 22,
      "index" : 50,
      "nextconsensus" : "NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP",
      "version" : 1,
      "nonce" : "AE8146B4A0BFEE37",
      "previousblockhash" : "0xd5495b7248d3fc32f75413d025898a0c4ee9c082fdf6b21515bd673f1c916f97",
      "size" : 253,
      "time" : 1724964530884,
      "merkleroot" : "0x0000000000000000000000000000000000000000000000000000000000000000"
   },
   "id" : 5
}

@roman-khimov
Copy link
Member Author

Work for 4-node network as well:

{
   "jsonrpc" : "2.0",
   "id" : 5,
   "result" : {
      "primary" : 1,
      "version" : 0,
      "merkleroot" : "0x0000000000000000000000000000000000000000000000000000000000000000",
      "witnesses" : [
         {
            "invocation" : "DEDBml8w5/9idaDbihP3mKBmaGliOkbDFvWcOhGVCP5YOUlLb1ka4+VVAwdxGs3FOXM6QXokO9TAY+7VsC6G9JAjDEBHFrqZN/rJ3HeXWMGkDf6eVDKYrewUQ+09fm21aoRcfUghAQsfKRD8guJh7demST3km0NV8aTZJBRDVUPRtYXpDEC27z2ik6auxppMEVKFjdaTde8BUqVNrSTobqo8GX8BhsbM9/81xAND0iTzPTMr/N2hxOEsCsaGWUH/layWctHt",
            "verification" : "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6"
         }
      ],
      "nextblockhash" : "0x7bc27638b069002f78fece8a723a5af2ef5533a2cf6d64d2ad7aee2d221cf252",
      "size" : 458,
      "previousblockhash" : "0x0f833e56d34a374459a7105ff8fd1a18a8d8935c50be03dbfe24b46e2dc38cde",
      "confirmations" : 4,
      "nonce" : "F7DFBF70A61CE69F",
      "hash" : "0x4c1dfa6739fefeae12a3dab84cf416f750495f648480bb09b9e379cb271142bb",
      "time" : 1724997563173,
      "index" : 9,
      "nextconsensus" : "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq",
      "tx" : []
   }
}
{
   "result" : {
      "time" : 1724997578178,
      "previousblockhash" : "0x4c1dfa6739fefeae12a3dab84cf416f750495f648480bb09b9e379cb271142bb",
      "nextconsensus" : "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq",
      "nextblockhash" : "0x20e24491cf6d62de4b278bcfa0be445954f8b4d1d54fef146bed85e9806f45f6",
      "index" : 10,
      "nonce" : "4A9F3B9298800A5E",
      "previousstateroot" : "0xaa74b9978b3cf10a69438e2a31e1a663fcca2bbf50a30a35ecf9a4a4048f12be",
      "merkleroot" : "0x0000000000000000000000000000000000000000000000000000000000000000",
      "primary" : 2,
      "tx" : [],
      "hash" : "0x7bc27638b069002f78fece8a723a5af2ef5533a2cf6d64d2ad7aee2d221cf252",
      "witnesses" : [
         {
            "verification" : "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFEGe0Nw6",
            "invocation" : "DEB2OOHvyzJBbXr7d7UbfDw4IxtlFUhF/gnjx8XNTRQdR3twVEGZZNpBIfGVVoEty7PN7UVn4EyK2HLVANHXs5rJDEARqbjKb3C6Mqex9spnNutO7NClwYj7jKmd/woY5w16rN9O8gM9lhq+Ny+06xEtqvjGGvELgPk37VdKozfeg32LDECq2n4vY6k9nyl5FN5rjsPRSXTB12q4nDI2Q34Mf7SCvPDpL0z+d/NRIGmM0taMk7jV92BC40Np14mgR/DiRZn4"
         }
      ],
      "size" : 490,
      "version" : 1,
      "confirmations" : 3
   },
   "jsonrpc" : "2.0",
   "id" : 5
}

@roman-khimov
Copy link
Member Author

Logic related to expectedHeaderSizeWithEmptyWitness might require some additional care since it's different between versions 0 and 1.

@roman-khimov roman-khimov added the blocked Can't be done because of something label Nov 20, 2024
@AnnaShaleva
Copy link
Member

Don't forget to update neo-go db restore command, ref. #3974 (comment), the list of block versions is extended.

AnnaShaleva added a commit to nspcc-dev/neo-bench that referenced this pull request Sep 5, 2025
@AnnaShaleva AnnaShaleva force-pushed the stateroot-block-version-1 branch 5 times, most recently from 048779c to db46d19 Compare September 16, 2025 13:36
@AnnaShaleva AnnaShaleva force-pushed the stateroot-block-version-1 branch 3 times, most recently from 898699e to b3132e4 Compare October 2, 2025 14:48
@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 68.75000% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.46%. Comparing base (945e210) to head (bd4cecb).
⚠️ Report is 38 commits behind head on master.

Files with missing lines Patch % Lines
pkg/services/blockfetcher/blockfetcher.go 22.22% 26 Missing and 2 partials ⚠️
pkg/consensus/consensus.go 69.69% 6 Missing and 4 partials ⚠️
pkg/core/block/block.go 40.00% 2 Missing and 1 partial ⚠️
pkg/core/statesync/module.go 50.00% 2 Missing ⚠️
pkg/core/dao/dao.go 85.71% 1 Missing ⚠️
pkg/network/tcp_peer.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3566      +/-   ##
==========================================
- Coverage   72.50%   72.46%   -0.04%     
==========================================
  Files         364      364              
  Lines       56750    56715      -35     
==========================================
- Hits        41146    41099      -47     
- Misses      13873    13886      +13     
+ Partials     1731     1730       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AnnaShaleva AnnaShaleva force-pushed the stateroot-block-version-1 branch from b3132e4 to cbf59dd Compare October 2, 2025 14:56
@AnnaShaleva AnnaShaleva removed the blocked Can't be done because of something label Oct 2, 2025
@AnnaShaleva AnnaShaleva added this to the v0.114.0 milestone Oct 2, 2025
@AnnaShaleva AnnaShaleva force-pushed the stateroot-block-version-1 branch from cbf59dd to 2fd6ac2 Compare October 2, 2025 15:27
@AnnaShaleva AnnaShaleva force-pushed the stateroot-block-version-1 branch from 2fd6ac2 to bd4cecb Compare October 2, 2025 15:29
@AnnaShaleva AnnaShaleva marked this pull request as ready for review October 2, 2025 15:29
@AnnaShaleva AnnaShaleva self-requested a review as a code owner October 2, 2025 15:29
@AnnaShaleva
Copy link
Member

Still a couple of TODOs left, will finish them. @roman-khimov, let's perform some initial review.

Basilisk: 10
Cockatrice: 15
Domovoi: 20
Echidna: 50
Copy link
Member Author

Choose a reason for hiding this comment

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

Why this change?

if pr, ok := msg.(*prepareRequest); ok {
pr.prevHash = s.dbft.PrevHash
pr.version = coreb.VersionInitial
pr.version = coreb.VersionInitial // TODO: ?
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure why we doing it here at all, newPrepareRequest should be handling all this. It's HF-dependent anyway.

if req.version != coreb.VersionInitial {
return errInvalidVersion
var (
f = config.HFFaun
Copy link
Member Author

Choose a reason for hiding this comment

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

s/f/faun/ maybe?

recoveryMessageType,
}

func TestS(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Some better name needed for sure.

// New creates a new blank block with proper state root setting.
func New(stateRootEnabled bool) *Block {
// New creates a new blank block of appropriate version.
func New(version uint32) *Block {
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure this parameter is useful.

return fmt.Errorf("%w: %s != %s",
ErrHdrInvalidStateRoot, currHeader.PrevStateRoot.StringLE(), sr.StringLE())
}
if currHeader.Version > block.VersionInitial && bc.stateRoot.CurrentLocalHeight() == prevHeader.Index {
Copy link
Member Author

Choose a reason for hiding this comment

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

You need to check that it's legal to have version 1 at this height as well.

P2PSigExtensions bool
// StateRootInHeader is true if state root is contained in block header.
// Deprecated: this setting is left for compatibility with old NeoGo nodes
// and
Copy link
Member Author

Choose a reason for hiding this comment

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

and?

p.ValidatorsCount = aux.ValidatorsCount
p.CommitteeHistory = aux.CommitteeHistory
p.P2PSigExtensions = aux.P2PSigExtensions
p.StateRootInHeader = aux.StateRootInHeader
Copy link
Member Author

Choose a reason for hiding this comment

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

But it should be unmarshaled for as long as we have it all, no?

defer c.cacheLock.Unlock()

c.cache.network = version.Protocol.Network
c.cache.stateRootInHeader = version.Protocol.StateRootInHeader
Copy link
Member Author

Choose a reason for hiding this comment

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

Init() decription is outdated now, in fact it can be safely omitted. Same goes for other methods (block/header getters) that reference it.

if bfs.chain.IsHardforkEnabled(&hf, index) {
v = block.VersionFaun
}
b := block.New(v)
Copy link
Member Author

Choose a reason for hiding this comment

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

But why? Block has everything needed internally (its version), no?

@roman-khimov roman-khimov removed this from the v0.114.0 milestone Nov 11, 2025
@roman-khimov roman-khimov added the blocked Can't be done because of something label Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Can't be done because of something

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants