mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 21:34:33 +00:00
fix contract code retrieval from db
This commit is contained in:
parent
4974ca49db
commit
c325ce1863
@ -2,7 +2,8 @@ import
|
||||
randutils, stew/byteutils, random,
|
||||
eth/[common, rlp], eth/trie/[hexary, db, trie_defs],
|
||||
faststreams/input_stream, nimcrypto/[utils, sysrand],
|
||||
../stateless/[witness_from_tree, tree_from_witness]
|
||||
../stateless/[witness_from_tree, tree_from_witness],
|
||||
../nimbus/db/storage_types
|
||||
|
||||
type
|
||||
DB = TrieDatabaseRef
|
||||
@ -22,7 +23,7 @@ proc randCode(db: DB): Hash256 =
|
||||
let codeLen = rand(1..150)
|
||||
let code = randList(byte, rng(0, 255), codeLen, unique = false)
|
||||
result = hexary.keccak(code)
|
||||
db.put(result.data, code)
|
||||
db.put(contractHashKey(result).toOpenArray, code)
|
||||
|
||||
proc randStorage(db: DB): Hash256 =
|
||||
if rand(0..1) == 0:
|
||||
|
@ -3,7 +3,8 @@ import
|
||||
nimcrypto/[keccak, hash], eth/[common, rlp],
|
||||
eth/trie/[trie_defs, nibbles, db],
|
||||
faststreams/output_stream,
|
||||
./witness_types, ../nimbus/constants
|
||||
./witness_types, ../nimbus/constants,
|
||||
../nimbus/db/storage_types
|
||||
|
||||
type
|
||||
DB = TrieDatabaseRef
|
||||
@ -123,7 +124,7 @@ proc writeAccountNode(wb: var WitnessBuilder, acc: Account, nibbles: NibblesSeq,
|
||||
|
||||
if accountType == ExtendedAccountType:
|
||||
if acc.codeHash != blankStringHash:
|
||||
let code = get(wb.db, acc.codeHash.data)
|
||||
let code = get(wb.db, contractHashKey(acc.codeHash).toOpenArray)
|
||||
if code.len > EIP170_CODE_SIZE_LIMIT:
|
||||
raise newException(ValueError, "code len exceed EIP170 code size limit")
|
||||
wb.writeU32(code.len.uint32)
|
||||
|
Loading…
x
Reference in New Issue
Block a user