Skip to content

Conversation

@LukaszRozmej
Copy link
Member

@LukaszRozmej LukaszRozmej commented Jul 10, 2025

Changes

  • Better null-ckecks in TryGetCanonicalTransaction

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

@benaadams benaadams requested a review from Copilot July 11, 2025 02:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the TryGetCanonicalTransaction method by introducing safer transaction lookups and adding boundary checks for receipts.

  • Introduced GetTransactionIndex extension to find a transaction’s index by hash.
  • Updated TryGetCanonicalTransaction to use the new index lookup and guard against missing transactions/receipts.
  • Adapted unit tests to use arrays, assign explicit hashes, and leverage C# collection expressions.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/Nethermind/Nethermind.Facade/BlockchainBridge.cs Use GetTransactionIndex and add checks to prevent null-index errors.
src/Nethermind/Nethermind.Facade.Test/BlockchainBridgeTests.cs Update tests to use arrays, set Hash fields, and match new lookup logic.
src/Nethermind/Nethermind.Core/BlockExtensions.cs Add GetTransactionIndex extension and required crypto import.

.WithTransactionHash(t.Hash)
.TestObject
).ToArray();
;
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

[nitpick] Stray semicolon on its own line; it can be removed to improve clarity.

Suggested change
;

Copilot uses AI. Check for mistakes.
.Select(static i => Build.A.Transaction.WithNonce((UInt256)i).WithHash(TestItem.Keccaks[i]).TestObject)
.ToArray();
Block block = Build.A.Block
.WithTransactions(transactions.ToArray())
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

[nitpick] The transactions variable is already an array, so the ToArray() call is redundant. Consider passing transactions directly.

Suggested change
.WithTransactions(transactions.ToArray())
.WithTransactions(transactions)

Copilot uses AI. Check for mistakes.
@LukaszRozmej LukaszRozmej merged commit f415499 into master Jul 11, 2025
135 of 137 checks passed
@LukaszRozmej LukaszRozmej deleted the fix/better-null-checking-in-get-transaction branch July 11, 2025 08:50
Demuirgos pushed a commit that referenced this pull request Jul 16, 2025
* Update CLZ gas cost for devnet3 (#8953)

* Update tx gas cap for devnet3 (#8954)

* Don't block background tasks when syncing (#8971)

* Don't block background tasks when syncing

* fix test

* fix compile warning

* Concurrency 2

* Rename blob metrics (#8972)

* Fix Taiko Engine Api (#8974)

* Fix call opcode

* Better null-ckecks in TryGetCanonicalTransaction (#8969)

* Better null-ckecks in TryGetCanonicalTransaction

* fix test

* fix whitespace

* fix test

* Revise JSON-RPC docs generation (#8967)

* Fix/OOM when downloading from genesis. (#8975)

* Slight change in constructor

* Stop putting more request when queue is high

* Add unit test

* Set budget as memory

* Whitespace

* Fix test

* Cache PropertyInfo lookups for JsonRpc (#8976)

* Auto-update fast sync settings (#8978)

Co-authored-by: rubo <rubo@users.noreply.github.com>

* Update OP Superchain chains (#8979)

Co-authored-by: emlautarom1 <emlautarom1@users.noreply.github.com>

* Remove use of Linq.Sum from hot paths (#8977)

* Remove use of Linq.Sum from hot paths

* Simplify

* Fix sstore

* Notice execution only if code length  > 0

* Isolate Tracer in Proof Module and remove IVisitingWorldState (#8981)

* Scope the tracer

* Use state reader in Tracer

* Inline dump state

* Remove accept

* Delete IVisitingWorldState

* Move dump state to state reader

* Whitespace

* More hot code in ConnectNodes (#8982)

* Only access "warmup" hashtable once per warmup (#8983)

* Only access "warm" up hashtable once per warmup

* Update src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.cs

Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>

---------

Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>

* EIP-7594: Constant maxBlobsPerTx  (#8940)

* Const maxBlobsPerTx

* WS

* Add tests(improve for the Gnosis case); add link

* Fail fast on Db corruption (#8986)

* Fail fast on Db corruption

* Fix tests

* Update src/Nethermind/Nethermind.Db.Rocks/DbOnTheRocks.cs

Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>

---------

Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>

* Fix extcodecopy & extcodehash

* Formatting

---------

Co-authored-by: Ben {chmark} Adams <thundercat@illyriad.co.uk>
Co-authored-by: Alexey <me@flcl.me>
Co-authored-by: Amirul Ashraf <asdacap@gmail.com>
Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
Co-authored-by: core-repository-dispatch-app[bot] <173070810+core-repository-dispatch-app[bot]@users.noreply.github.com>
Co-authored-by: emlautarom1 <emlautarom1@users.noreply.github.com>
Demuirgos pushed a commit that referenced this pull request Jul 17, 2025
* Update CLZ gas cost for devnet3 (#8953)

* Update tx gas cap for devnet3 (#8954)

* Don't block background tasks when syncing (#8971)

* Don't block background tasks when syncing

* fix test

* fix compile warning

* Concurrency 2

* Rename blob metrics (#8972)

* Fix Taiko Engine Api (#8974)

* Fix call opcode

* Better null-ckecks in TryGetCanonicalTransaction (#8969)

* Better null-ckecks in TryGetCanonicalTransaction

* fix test

* fix whitespace

* fix test

* Revise JSON-RPC docs generation (#8967)

* Fix/OOM when downloading from genesis. (#8975)

* Slight change in constructor

* Stop putting more request when queue is high

* Add unit test

* Set budget as memory

* Whitespace

* Fix test

* Cache PropertyInfo lookups for JsonRpc (#8976)

* Auto-update fast sync settings (#8978)

Co-authored-by: rubo <rubo@users.noreply.github.com>

* Update OP Superchain chains (#8979)

Co-authored-by: emlautarom1 <emlautarom1@users.noreply.github.com>

* Remove use of Linq.Sum from hot paths (#8977)

* Remove use of Linq.Sum from hot paths

* Simplify

* Fix sstore

* Notice execution only if code length  > 0

* Isolate Tracer in Proof Module and remove IVisitingWorldState (#8981)

* Scope the tracer

* Use state reader in Tracer

* Inline dump state

* Remove accept

* Delete IVisitingWorldState

* Move dump state to state reader

* Whitespace

* More hot code in ConnectNodes (#8982)

* Only access "warmup" hashtable once per warmup (#8983)

* Only access "warm" up hashtable once per warmup

* Update src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.cs

Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>

---------

Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>

* EIP-7594: Constant maxBlobsPerTx  (#8940)

* Const maxBlobsPerTx

* WS

* Add tests(improve for the Gnosis case); add link

* Fail fast on Db corruption (#8986)

* Fail fast on Db corruption

* Fix tests

* Update src/Nethermind/Nethermind.Db.Rocks/DbOnTheRocks.cs

Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>

---------

Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>

* Fix extcodecopy & extcodehash

* Formatting

* Configure EWC Zurich hard fork (#8985)

* feat: Add RegexOptions.Compiled flag to NewPayloadJsonRpcValidator (#8984)

* Check for null code hash

* Improve locking when looking up RlpDecoders (#8987)

* Remove locking in RlpDecoder fast path

* Feedback

* Opt in no_ilevm mode in tests

* Fix ilevm executes only when not tracing

* Fix ilevm tracing check

* Fix tracing check that allows ilevm analysis & execution

* Formatting

* Fix spelling

---------

Co-authored-by: Ben {chmark} Adams <thundercat@illyriad.co.uk>
Co-authored-by: Alexey <me@flcl.me>
Co-authored-by: Amirul Ashraf <asdacap@gmail.com>
Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
Co-authored-by: core-repository-dispatch-app[bot] <173070810+core-repository-dispatch-app[bot]@users.noreply.github.com>
Co-authored-by: emlautarom1 <emlautarom1@users.noreply.github.com>
Co-authored-by: Micke <155267459+reallesee@users.noreply.github.com>
Demuirgos pushed a commit that referenced this pull request Jul 21, 2025
* Update CLZ gas cost for devnet3 (#8953)

* Update tx gas cap for devnet3 (#8954)

* Don't block background tasks when syncing (#8971)

* Don't block background tasks when syncing

* fix test

* fix compile warning

* Concurrency 2

* Rename blob metrics (#8972)

* Fix Taiko Engine Api (#8974)

* Better null-ckecks in TryGetCanonicalTransaction (#8969)

* Better null-ckecks in TryGetCanonicalTransaction

* fix test

* fix whitespace

* fix test

* Revise JSON-RPC docs generation (#8967)

* Fix/OOM when downloading from genesis. (#8975)

* Slight change in constructor

* Stop putting more request when queue is high

* Add unit test

* Set budget as memory

* Whitespace

* Fix test

* Cache PropertyInfo lookups for JsonRpc (#8976)

* Auto-update fast sync settings (#8978)

Co-authored-by: rubo <rubo@users.noreply.github.com>

* Update OP Superchain chains (#8979)

Co-authored-by: emlautarom1 <emlautarom1@users.noreply.github.com>

* Remove use of Linq.Sum from hot paths (#8977)

* Remove use of Linq.Sum from hot paths

* Simplify

* Isolate Tracer in Proof Module and remove IVisitingWorldState (#8981)

* Scope the tracer

* Use state reader in Tracer

* Inline dump state

* Remove accept

* Delete IVisitingWorldState

* Move dump state to state reader

* Whitespace

* More hot code in ConnectNodes (#8982)

* Only access "warmup" hashtable once per warmup (#8983)

* Only access "warm" up hashtable once per warmup

* Update src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.cs

Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>

---------

Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>

* EIP-7594: Constant maxBlobsPerTx  (#8940)

* Const maxBlobsPerTx

* WS

* Add tests(improve for the Gnosis case); add link

* Fail fast on Db corruption (#8986)

* Fail fast on Db corruption

* Fix tests

* Update src/Nethermind/Nethermind.Db.Rocks/DbOnTheRocks.cs

Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>

---------

Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>

* Configure EWC Zurich hard fork (#8985)

* feat: Add RegexOptions.Compiled flag to NewPayloadJsonRpcValidator (#8984)

* Improve locking when looking up RlpDecoders (#8987)

* Remove locking in RlpDecoder fast path

* Feedback

* Fix naming of data cost in ExecutePrecompile (#8994)

fix naming of data cost

* Move precompiles (#8962)

* Move precompiles

* Fix build

* Fix formating

* EthereumCodeInfoRepository

* Remove EthereumPrecompiles class

* Move precompiles into separate project

* Fix build

* Add EIP-7910: Add eth_config (#8956)

* Add eth_config
* Update systemContracts, refactor
* Fix next/last hash to be null

* Replace `eth_pairings` with `mcl` (#8992)

* Unify BN254 naming (#9004)

* Refactor/Move init DB to DI (#8997)

* Wait to read channel before reading

* Fix BN254 point deserialization (#9009)

* Optimize ModExp (#9008)

* Optimize ModExp

* Faaster

* Moar

* work as nuint

* use nint

* cast via int

* Remove unneeded casts

* Move OldRuns to tests

* fix benchmarks

* Feedback

* Less branches

* Less branches

* fixed invalid

* Remove last orphan readonly tx processing scope. (#9005)

* Fix workerloop

* Replace read all with try read

* Update config for tests

* Update winget command (#9011)

* Auto-update fast sync settings (#9013)

Co-authored-by: rubo <rubo@users.noreply.github.com>

* Update OP Superchain chains (#9014)

Co-authored-by: emlautarom1 <emlautarom1@users.noreply.github.com>

* Tidy up ecdsa overloads (#9015)

* Tidy up ecdsa overloads

* put back the increase

* Tracing check to allow ilevm to be enabled for node and tests

* Update verified

* ..

---------

Co-authored-by: Ben {chmark} Adams <thundercat@illyriad.co.uk>
Co-authored-by: Alexey <me@flcl.me>
Co-authored-by: Amirul Ashraf <asdacap@gmail.com>
Co-authored-by: Lukasz Rozmej <lukasz.rozmej@gmail.com>
Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
Co-authored-by: core-repository-dispatch-app[bot] <173070810+core-repository-dispatch-app[bot]@users.noreply.github.com>
Co-authored-by: emlautarom1 <emlautarom1@users.noreply.github.com>
Co-authored-by: Micke <155267459+reallesee@users.noreply.github.com>
Co-authored-by: Marcin Sobczak <77129288+marcindsobczak@users.noreply.github.com>
Co-authored-by: Nikita Mescheryakov <root@nikitam.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants