mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-02 15:24:01 +00:00
bump nim-eth and accompanying fixes
This commit is contained in:
parent
742759e607
commit
cbd593f514
@ -305,6 +305,10 @@ func isLondon*(com: CommonRef, number: BlockNumber): bool =
|
|||||||
# TODO: Fixme, use only London comparator
|
# TODO: Fixme, use only London comparator
|
||||||
com.toHardFork(number.blockNumberToForkDeterminationInfo) >= London
|
com.toHardFork(number.blockNumberToForkDeterminationInfo) >= London
|
||||||
|
|
||||||
|
func isLondon*(com: CommonRef, number: BlockNumber, timestamp: EthTime): bool =
|
||||||
|
# TODO: Fixme, use only London comparator
|
||||||
|
com.toHardFork(forkDeterminationInfo(number, timestamp)) >= London
|
||||||
|
|
||||||
func forkGTE*(com: CommonRef, fork: HardFork): bool =
|
func forkGTE*(com: CommonRef, fork: HardFork): bool =
|
||||||
com.currentFork >= fork
|
com.currentFork >= fork
|
||||||
|
|
||||||
|
@ -12,13 +12,8 @@ import
|
|||||||
eth/rlp, stew/io2,
|
eth/rlp, stew/io2,
|
||||||
./chain,
|
./chain,
|
||||||
../db/select_backend,
|
../db/select_backend,
|
||||||
../common/common
|
../common/common,
|
||||||
|
../utils/utils
|
||||||
type
|
|
||||||
# trick the rlp decoder
|
|
||||||
# so we can separate the body and header
|
|
||||||
EthHeader = object
|
|
||||||
header: BlockHeader
|
|
||||||
|
|
||||||
proc importRlpBlock*(blocksRlp: openArray[byte]; com: CommonRef; importFile: string = ""): bool =
|
proc importRlpBlock*(blocksRlp: openArray[byte]; com: CommonRef; importFile: string = ""): bool =
|
||||||
var
|
var
|
||||||
@ -26,14 +21,14 @@ proc importRlpBlock*(blocksRlp: openArray[byte]; com: CommonRef; importFile: str
|
|||||||
rlp = rlpFromBytes(blocksRlp)
|
rlp = rlpFromBytes(blocksRlp)
|
||||||
chain = newChain(com, extraValidation = true)
|
chain = newChain(com, extraValidation = true)
|
||||||
errorCount = 0
|
errorCount = 0
|
||||||
|
header: BlockHeader
|
||||||
|
body: BlockBody
|
||||||
let
|
let
|
||||||
head = com.db.getCanonicalHead()
|
head = com.db.getCanonicalHead()
|
||||||
|
|
||||||
while rlp.hasData:
|
while rlp.hasData:
|
||||||
try:
|
try:
|
||||||
let
|
rlp.decompose(header, body)
|
||||||
header = rlp.read(EthHeader).header
|
|
||||||
body = rlp.readRecordType(BlockBody, false)
|
|
||||||
if header.blockNumber > head.blockNumber:
|
if header.blockNumber > head.blockNumber:
|
||||||
if chain.persistBlocks([header], [body]) == ValidationResult.Error:
|
if chain.persistBlocks([header], [body]) == ValidationResult.Error:
|
||||||
# register one more error and continue
|
# register one more error and continue
|
||||||
|
@ -144,9 +144,10 @@ proc update(dh: TxChainRef; parent: BlockHeader)
|
|||||||
{.gcsafe,raises: [CatchableError].} =
|
{.gcsafe,raises: [CatchableError].} =
|
||||||
|
|
||||||
let
|
let
|
||||||
|
timestamp = dh.getTimestamp(parent)
|
||||||
db = dh.com.db
|
db = dh.com.db
|
||||||
acc = AccountsCache.init(db.db, parent.stateRoot, dh.com.pruneTrie)
|
acc = AccountsCache.init(db.db, parent.stateRoot, dh.com.pruneTrie)
|
||||||
fee = if dh.com.isLondon(parent.blockNumber + 1):
|
fee = if dh.com.isLondon(parent.blockNumber + 1, timestamp):
|
||||||
some(dh.com.baseFeeGet(parent).uint64.u256)
|
some(dh.com.baseFeeGet(parent).uint64.u256)
|
||||||
else:
|
else:
|
||||||
UInt256.none()
|
UInt256.none()
|
||||||
|
@ -63,3 +63,19 @@ proc short*(h: Hash256): string =
|
|||||||
bytes[0..2] = h.data[0..2]
|
bytes[0..2] = h.data[0..2]
|
||||||
bytes[^3..^1] = h.data[^3..^1]
|
bytes[^3..^1] = h.data[^3..^1]
|
||||||
bytes.toHex
|
bytes.toHex
|
||||||
|
|
||||||
|
proc decompose*(rlp: var Rlp,
|
||||||
|
header: var BlockHeader,
|
||||||
|
body: var BlockBody) {.gcsafe, raises: [RlpError].} =
|
||||||
|
var blk = rlp.read(EthBlock)
|
||||||
|
header = system.move(blk.header)
|
||||||
|
body.transactions = system.move(blk.txs)
|
||||||
|
body.uncles = system.move(blk.uncles)
|
||||||
|
body.withdrawals = system.move(blk.withdrawals)
|
||||||
|
|
||||||
|
proc decompose*(rlpBytes: openArray[byte],
|
||||||
|
header: var BlockHeader,
|
||||||
|
body: var BlockBody) {.gcsafe, raises: [RlpError].} =
|
||||||
|
var rlp = rlpFromBytes(rlpBytes)
|
||||||
|
rlp.decompose(header, body)
|
||||||
|
|
@ -25,11 +25,6 @@ import
|
|||||||
../nimbus/common/common
|
../nimbus/common/common
|
||||||
|
|
||||||
type
|
type
|
||||||
# trick the rlp decoder
|
|
||||||
# so we can separate the body and header
|
|
||||||
EthHeader = object
|
|
||||||
header: BlockHeader
|
|
||||||
|
|
||||||
SealEngine = enum
|
SealEngine = enum
|
||||||
NoProof
|
NoProof
|
||||||
Ethash
|
Ethash
|
||||||
@ -229,9 +224,7 @@ proc importBlock(tester: var Tester, com: CommonRef,
|
|||||||
|
|
||||||
proc applyFixtureBlockToChain(tester: var Tester, tb: var TestBlock,
|
proc applyFixtureBlockToChain(tester: var Tester, tb: var TestBlock,
|
||||||
com: CommonRef, checkSeal, validation: bool) =
|
com: CommonRef, checkSeal, validation: bool) =
|
||||||
var rlp = rlpFromBytes(tb.blockRLP)
|
decompose(tb.blockRLP, tb.header, tb.body)
|
||||||
tb.header = rlp.read(EthHeader).header
|
|
||||||
tb.body = rlp.readRecordType(BlockBody, false)
|
|
||||||
tester.importBlock(com, tb, checkSeal, validation)
|
tester.importBlock(com, tb, checkSeal, validation)
|
||||||
|
|
||||||
func shouldCheckSeal(tester: Tester): bool =
|
func shouldCheckSeal(tester: Tester): bool =
|
||||||
|
2
vendor/nim-eth
vendored
2
vendor/nim-eth
vendored
@ -1 +1 @@
|
|||||||
Subproject commit e639dc1e145722ec137639ee040eddc524f853dd
|
Subproject commit 91b2b9d2ed6daa14107c9ee84ffac71c2ccd5dd4
|
Loading…
x
Reference in New Issue
Block a user