Skip to content

Fix: add hash verification for OnImport#3070

Merged
shargon merged 2 commits intoneo-project:masterfrom
Jim8y:fix-onimport
Jan 9, 2024
Merged

Fix: add hash verification for OnImport#3070
shargon merged 2 commits intoneo-project:masterfrom
Jim8y:fix-onimport

Conversation

@Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jan 8, 2024

Same as #3061 but more clear what is the problem

@shargon shargon merged commit 7b92845 into neo-project:master Jan 9, 2024
Jim8y added a commit to Jim8y/neo that referenced this pull request Jan 10, 2024
* master:
  Fixed asp.net core project (neo-project#3067)
  Updated BLS12_381 (neo-project#3074)
  avoid nonsense exception messages. (neo-project#3063)
  Removed `MyGet` (neo-project#3071)
  Updated unit-test (neo-project#3073)
  add hash verification for OnImport (neo-project#3070)
  Make public ReadUserInput (neo-project#3068)
  Removed asp.net core (neo-project#3065)
  Enforce Line Endings in `.editorconfig` (neo-project#3060)
  Remove some warnings (neo-project#3057)
  Fixed workflow  timeout-minutes (neo-project#3048)
  Fix: specify the error message (neo-project#3030)
  Removes `WebSocket`s from the network layer (neo-project#3039)
  set timeout for tests (neo-project#3046)
  Fix: Editconfig (neo-project#3023)
  Set project as nullable (neo-project#3042)
  Fix: fix equal (neo-project#3028)

# Conflicts:
#	src/Neo.CLI/CLI/MainService.cs
#	src/Neo.CLI/Settings.cs
#	src/Neo/ProtocolSettings.cs
TrimmedBlock prev = NativeContract.Ledger.GetTrimmedBlock(snapshot, prevHash);
if (prev is null) return false;
if (prev.Index + 1 != index) return false;
if (prev.Hash != prevHash) return false;
Copy link
Member

Choose a reason for hiding this comment

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

@shargon, what is the purpose of adding this check? Consensus nodes agree on parent block hash during dBFT process, so it can't be wrong if block witness is OK. And two lines below we check consensus nodes witness, so we're sure that block data are correct.

Copy link
Contributor Author

@Jim8y Jim8y Jan 11, 2024

Choose a reason for hiding this comment

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

@AnnaShaleva No special purpose, just make it align with the check below. It wont hurt to add, it wont hurt to remove all checks as well.

        internal bool Verify(ProtocolSettings settings, DataCache snapshot, HeaderCache headerCache)
        {
            Header prev = headerCache.Last;
            if (prev is null) return Verify(settings, snapshot);
            if (primaryIndex >= settings.ValidatorsCount)
                return false;
            if (prev.Hash != prevHash) return false;
            if (prev.index + 1 != index) return false;
            if (prev.timestamp >= timestamp) return false;
            return this.VerifyWitness(settings, snapshot, prev.nextConsensus, Witness, 3_00000000L, out _);
        }

Copy link
Member

Choose a reason for hiding this comment

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

Good, thanks!

@Jim8y Jim8y deleted the fix-onimport branch January 11, 2024 12:04
Jim8y added a commit to Jim8y/neo that referenced this pull request Jan 12, 2024
* master:
  Made `MemoryStore` the default whithout `config.json` for `neo-cli` (neo-project#3085)
  Adding Devcontainer and link to codespace (neo-project#3075)
  Update & Consolidate nugets (neo-project#3083)
  Adding NNS to `neo-cli` (neo-project#3032)
  Add: add pull request template (neo-project#3081)
  Move to monorepo: Neo.Cryptography.BLS12_381 (neo-project#3077)
  Add: add a new verify result status code (neo-project#3076)
  Convert to Neo.Json and Neo.ConsoleService to `dotnet` standard 2.1 (neo-project#3044)
  Avoid IsExternalInit  (neo-project#3079)
  Clean usings (neo-project#3078)
  Fixed asp.net core project (neo-project#3067)
  Updated BLS12_381 (neo-project#3074)
  avoid nonsense exception messages. (neo-project#3063)
  Removed `MyGet` (neo-project#3071)
  Updated unit-test (neo-project#3073)
  add hash verification for OnImport (neo-project#3070)
  Make public ReadUserInput (neo-project#3068)
  Removed asp.net core (neo-project#3065)
  Enforce Line Endings in `.editorconfig` (neo-project#3060)

# Conflicts:
#	src/Neo.CLI/CLI/MainService.cs
@roman-khimov roman-khimov added this to the v3.7.0 milestone Feb 27, 2024
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.

5 participants