Skip to content

Commit

Permalink
Client/Monorepo: Use WASM Crypto (keccak256) for Hashing / Consistent…
Browse files Browse the repository at this point in the history
… Hash Function Overwrite (#3192)

* Add @polkadot/wasm crypto dependency

* Use @polkadot/wasm keccak256 for trie key hashing in execution state manager for VM

* Tighten calling for useKeyHashingFunction

* Add customCrypto options dict to Common, first keccak256 usage and test

* Add custom keccak256 usage to EVM keccak256 opcode

* Add wasm based ecrecover option

* export calcSigRecovery

* use customcrypto if available

* add test for custom ecrecover

* Add optional common to trie interface

* Add cli option

* Rebuild package-lock.json

* Add @polkadot/util as a dev dependency to the tx package for testing

* Rebuild package-lock.json

* Pass common into trie instantiations in snap sync fetchers

* Use wasm keccak function if available in bytecodeFetcher

* Use wasm keccak function if available in trienodeFetcher

* Refactor default statemanager trie and keccak256 usage to allow option of WASM version

* Refactor rpc statemanager trie and keccak256 usage to allow option of WASM version

* Refactor verkle statemanager trie and keccak256 usage to allow option of WASM version

* Fix reference to statemanager opts

* Pass common to verifyProof trie instantiation

* Test if trie shallowCopy is using the correct hashing function

* Update packages/tx/src/capabilities/legacy.ts

Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>

* Update packages/tx/src/capabilities/legacy.ts

Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>

* Update packages/tx/src/capabilities/legacy.ts

Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>

* Update packages/tx/src/capabilities/legacy.ts

Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>

* tx: fix double declaration

* Use wasm keccak function if available in block

* Use consistent naming for opts parameter

* Update package-lock

* Use wasm keccak function if available in header

* Use consistent naming for opts parameter

* Explicitly declare return type

* Pass common to tries instantiated in genTrieRoot functions

* Fix tests

* Fix test

* Block: add suggestions from code review

* Add test for Block hash() method with custom crypto

* Some clean-up

* Pass common in vm and testrunner tries

* Update evm usage for customCrypto

* Move wasm crypto tests to client

* add optional wasm keccak in misc uses

* Add polkadot/util

* import util directly

* resolve polkadot/util to fake dep

* Devp2p: Use WASM Crypto

* Devp2p: add keccak function and Common passing structure to RLPx, DPT, DNS

* Client: pass in common along devp2p DPT instantiation

* Devp2p: expand to ECIES, first replacement test

* Devp2p: First full-round replacement (including concatBytes occurrences) for ECIES

* Devp2p: integrate into DPT server and message

* Devp2p: Add to DNS ENR

* Devp2p: remove util keccak256 helper function

* Mock polkadot util module

* try installing peers

* Add custom sha256 support and tests

* Add wasm ecSign

* Passing common in various places

* Fix import

* block/client: minor changes

* Add ecrecover function

---------

Co-authored-by: acolytec3 <17355484+acolytec3@users.noreply.github.com>
Co-authored-by: Amir <indigophi@protonmail.com>
Co-authored-by: Jochem Brouwer <jochembrouwer96@gmail.com>
Co-authored-by: Gabriel Rocheleau <contact@rockwaterweb.com>
  • Loading branch information
5 people authored Jan 18, 2024
1 parent a8f326a commit 54446b1
Show file tree
Hide file tree
Showing 53 changed files with 4,239 additions and 645 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/client-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- run: npm ci --omit=peer
- run: npm ci
working-directory: ${{github.workspace}}

- run: npm run coverage
Expand Down
Loading

0 comments on commit 54446b1

Please sign in to comment.