Make staterootinheader a proper block version 1#3566
Conversation
|
Work for 4-node network as well: |
|
Logic related to |
|
Don't forget to update |
Required to test nspcc-dev/neo-go#3566 and neo-project/neo#4161. Includes nspcc-dev/neo-go#4001. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
048779c to
db46d19
Compare
898699e to
b3132e4
Compare
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
b3132e4 to
cbf59dd
Compare
cbf59dd to
2fd6ac2
Compare
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2fd6ac2 to
bd4cecb
Compare
|
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 |
| if pr, ok := msg.(*prepareRequest); ok { | ||
| pr.prevHash = s.dbft.PrevHash | ||
| pr.version = coreb.VersionInitial | ||
| pr.version = coreb.VersionInitial // TODO: ? |
There was a problem hiding this comment.
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 |
| recoveryMessageType, | ||
| } | ||
|
|
||
| func TestS(t *testing.T) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
| p.ValidatorsCount = aux.ValidatorsCount | ||
| p.CommitteeHistory = aux.CommitteeHistory | ||
| p.P2PSigExtensions = aux.P2PSigExtensions | ||
| p.StateRootInHeader = aux.StateRootInHeader |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
But why? Block has everything needed internally (its version), no?
Very dirty, but works for the single node already: