nimbus-eth1/fluffy/network/state/experimental/state_proof_generation.nim
web3-developer 32e1f94d78
Portal State Proof Verification with Tests (#1951)
* Initial implementation of account and storage proof verification for the portal state network.

* Completed initial state proof verification loop test.

* Completed proof verification tests.

* Minor updates based on PR feedback and comments.

* Add state proof verification test to test runner.
2023-12-21 17:05:53 +08:00

31 lines
985 B
Nim

# Nimbus
# Copyright (c) 2023 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [].}
import
stint,
eth/[common, trie],
./state_proof_verification
type
AccountState* = HexaryTrie
StorageState* = HexaryTrie
proc generateAccountProof*(
state: AccountState,
address: EthAddress): AccountProof {.raises: [RlpError].} =
let key = keccakHash(address).data
state.getBranch(key).AccountProof
proc generateStorageProof*(
state: StorageState,
slotKey: UInt256): StorageProof {.raises: [RlpError].} =
let key = keccakHash(toBytesBE(slotKey)).data
state.getBranch(key).StorageProof