mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-24 03:00:25 +00:00
switch to Nim v2.0.12 (#2817)
* switch to Nim v2.0.12 * fix LruCache capitalization for styleCheck * KzgProof/KzgCommitment for styleCheck * TxEip4844 for styleCheck * styleCheck issues in nimbus/beacon/payload_conv.nim * ENode for styleCheck * isOk for styleCheck * some more styleCheck fixes * more styleCheck fixes --------- Co-authored-by: jangko <jangko128@gmail.com>
This commit is contained in:
parent
20edc0dcf5
commit
73661fd8a4
@ -155,9 +155,9 @@ type
|
||||
|
||||
PortalProtocolId* = array[2, byte]
|
||||
|
||||
RadiusCache* = LRUCache[NodeId, UInt256]
|
||||
RadiusCache* = LruCache[NodeId, UInt256]
|
||||
|
||||
ContentCache = LRUCache[ContentId, seq[byte]]
|
||||
ContentCache = LruCache[ContentId, seq[byte]]
|
||||
|
||||
ContentKV* = object
|
||||
contentKey*: ContentKeyByteList
|
||||
|
@ -62,17 +62,17 @@ import
|
||||
from beacon_chain/gossip_processing/block_processor import newExecutionPayload
|
||||
from beacon_chain/gossip_processing/eth2_processor import toValidationResult
|
||||
|
||||
template append(w: var RlpWriter, t: TypedTransaction) =
|
||||
w.appendRawBytes(distinctBase t)
|
||||
template append(w: var RlpWriter, typedTransaction: TypedTransaction) =
|
||||
w.appendRawBytes(distinctBase typedTransaction)
|
||||
|
||||
template append(w: var RlpWriter, t: WithdrawalV1) =
|
||||
template append(w: var RlpWriter, withdrawalV1: WithdrawalV1) =
|
||||
# TODO: Since Capella we can also access ExecutionPayloadHeader and thus
|
||||
# could get the Roots through there instead.
|
||||
w.append blocks.Withdrawal(
|
||||
index: distinctBase(t.index),
|
||||
validatorIndex: distinctBase(t.validatorIndex),
|
||||
address: t.address,
|
||||
amount: distinctBase(t.amount),
|
||||
index: distinctBase(withdrawalV1.index),
|
||||
validatorIndex: distinctBase(withdrawalV1.validatorIndex),
|
||||
address: withdrawalV1.address,
|
||||
amount: distinctBase(withdrawalV1.amount),
|
||||
)
|
||||
|
||||
proc asPortalBlockData*(
|
||||
|
@ -25,12 +25,12 @@ type
|
||||
|
||||
BlobCommitment* = object
|
||||
blob*: kzg.KzgBlob
|
||||
commitment*: kzg.KZGCommitment
|
||||
commitment*: kzg.KzgCommitment
|
||||
|
||||
BlobTxWrapData* = object
|
||||
hashes*: seq[Hash32]
|
||||
blobs*: seq[kzg.KzgBlob]
|
||||
commitments*: seq[kzg.KZGCommitment]
|
||||
commitments*: seq[kzg.KzgCommitment]
|
||||
proofs*: seq[kzg.KzgProof]
|
||||
|
||||
func getBlobList*(startId: BlobID, count: int): BlobIDs =
|
||||
@ -147,7 +147,7 @@ proc getVersionedHash*(blobid: BlobID, commitmentVersion: byte): Hash32 =
|
||||
|
||||
proc blobDataGenerator*(startBlobId: BlobID, blobCount: int): BlobTxWrapData =
|
||||
result.blobs = newSeq[kzg.KzgBlob](blobCount)
|
||||
result.commitments = newSeq[kzg.KZGCommitment](blobCount)
|
||||
result.commitments = newSeq[kzg.KzgCommitment](blobCount)
|
||||
result.hashes = newSeq[Hash32](blobCount)
|
||||
result.proofs = newSeq[kzg.KzgProof](blobCount)
|
||||
|
||||
|
@ -539,11 +539,6 @@ func scramble(data: Hash32): Opt[Hash32] =
|
||||
h.data[^1] = byte(255 - h.data[^1])
|
||||
Opt.some(h)
|
||||
|
||||
func scramble(data: Bytes32): Opt[Hash32] =
|
||||
var h = Hash32 data
|
||||
h.data[0] = byte(255 - h.data[0])
|
||||
Opt.some(h)
|
||||
|
||||
# This function generates an invalid payload by taking a base payload and modifying the specified field such that it ends up being invalid.
|
||||
# One small consideration is that the payload needs to contain transactions and specially transactions using the PREVRANDAO opcode for all the fields to be compatible with this function.
|
||||
proc generateInvalidPayload*(sender: TxSender, data: ExecutableData, payloadField: InvalidPayloadBlockField): ExecutableData =
|
||||
|
@ -134,7 +134,7 @@ type
|
||||
BlobWrapData* = object
|
||||
versionedHash*: Hash32
|
||||
blob* : kzg.KzgBlob
|
||||
commitment* : kzg.KZGCommitment
|
||||
commitment* : kzg.KzgCommitment
|
||||
proof* : kzg.KzgProof
|
||||
|
||||
BlobData* = ref object
|
||||
@ -149,7 +149,7 @@ proc getBlobDataInPayload*(pool: TestBlobTxPool, payload: ExecutionPayload): Res
|
||||
# Unmarshal the tx from the payload, which should be the minimal version
|
||||
# of the blob transaction
|
||||
let txData = rlp.decode(distinctBase binaryTx, Transaction)
|
||||
if txData.txType != TxEIP4844:
|
||||
if txData.txType != TxEip4844:
|
||||
continue
|
||||
|
||||
let txHash = rlpHash(txData)
|
||||
|
@ -157,9 +157,9 @@ proc verifyBlobBundle(step: NewPayloads,
|
||||
return false
|
||||
|
||||
for i, blobData in blobDataInPayload:
|
||||
let bundleCommitment = blobBundle.commitments[i].bytes
|
||||
let bundleBlob = blobBundle.blobs[i].bytes
|
||||
let bundleProof = blobBundle.proofs[i].bytes
|
||||
let bundleCommitment = blobBundle.commitments[i].data
|
||||
let bundleBlob = blobBundle.blobs[i].data
|
||||
let bundleProof = blobBundle.proofs[i].data
|
||||
|
||||
if bundleCommitment != blobData.commitment.bytes:
|
||||
error "KZG mismatch at index of the bundle", index=i
|
||||
@ -235,8 +235,8 @@ method execute*(step: NewPayloads, ctx: CancunTestContext): bool =
|
||||
r.expectNoError(step.expectationDescription)
|
||||
r.expectPayloadStatus(expectedStatus)
|
||||
|
||||
if r.get().payloadID.isSome:
|
||||
testCond env.clMock.addPayloadID(env.engine, r.get().payloadID.get())
|
||||
if r.get().payloadId.isSome:
|
||||
testCond env.clMock.addPayloadID(env.engine, r.get().payloadId.get())
|
||||
|
||||
return true
|
||||
,
|
||||
|
@ -1905,7 +1905,7 @@ proc makeCancunTest(): seq[EngineSpec] =
|
||||
|
||||
result.add InvalidPayloadTestCase(
|
||||
mainFork : ForkCancun,
|
||||
txType : Opt.some(TxEIP4844),
|
||||
txType : Opt.some(TxEip4844),
|
||||
invalidField : invalidField,
|
||||
syncing : syncing,
|
||||
invalidDetectedOnSync: invalidDetectedOnSync,
|
||||
@ -1915,26 +1915,26 @@ proc makeCancunTest(): seq[EngineSpec] =
|
||||
# Invalid Transaction ChainID Tests
|
||||
result.add InvalidTxChainIDTest(
|
||||
mainFork: ForkCancun,
|
||||
txType : Opt.some(TxEIP4844),
|
||||
txType : Opt.some(TxEip4844),
|
||||
)
|
||||
|
||||
result.add PayloadBuildAfterInvalidPayloadTest(
|
||||
mainFork: ForkCancun,
|
||||
txType : Opt.some(TxEIP4844),
|
||||
txType : Opt.some(TxEip4844),
|
||||
invalidField: InvalidParentBeaconBlockRoot,
|
||||
)
|
||||
|
||||
# Suggested Fee Recipient Tests (New Transaction Type)
|
||||
result.add SuggestedFeeRecipientTest(
|
||||
mainFork: ForkCancun,
|
||||
txType : Opt.some(TxEIP4844),
|
||||
txType : Opt.some(TxEip4844),
|
||||
transactionCount: 1, # Only one blob tx gets through due to blob gas limit
|
||||
)
|
||||
|
||||
# Prev Randao Tests (New Transaction Type)
|
||||
result.add PrevRandaoTransactionTest(
|
||||
mainFork: ForkCancun,
|
||||
txType : Opt.some(TxEIP4844),
|
||||
txType : Opt.some(TxEip4844),
|
||||
)
|
||||
|
||||
proc getGenesisProc(cs: BaseSpec, param: NetworkParams) =
|
||||
|
@ -275,8 +275,8 @@ proc generatePayloadAttributes(cl: CLMocker) =
|
||||
let timestamp = Quantity cl.getNextBlockTimestamp.uint64
|
||||
cl.latestPayloadAttributes = PayloadAttributes(
|
||||
timestamp: timestamp,
|
||||
prevRandao: FixedBytes[32] nextPrevRandao.data,
|
||||
suggestedFeeRecipient: Address cl.nextFeeRecipient,
|
||||
prevRandao: nextPrevRandao,
|
||||
suggestedFeeRecipient: cl.nextFeeRecipient,
|
||||
)
|
||||
|
||||
if cl.isShanghai(timestamp):
|
||||
@ -311,8 +311,8 @@ proc requestNextPayload(cl: CLMocker): bool =
|
||||
head=cl.latestForkchoice.headBlockHash
|
||||
return false
|
||||
|
||||
doAssert s.payLoadID.isSome
|
||||
cl.nextPayloadID = s.payloadID.get()
|
||||
doAssert s.payloadId.isSome
|
||||
cl.nextPayloadID = s.payloadId.get()
|
||||
return true
|
||||
|
||||
proc getPayload(cl: CLMocker, payloadId: Bytes8): Result[GetPayloadResponse, string] =
|
||||
@ -339,9 +339,9 @@ proc getNextPayload(cl: CLMocker): bool =
|
||||
cl.latestShouldOverrideBuilder = x.shouldOverrideBuilder
|
||||
cl.latestExecutionRequests = x.executionRequests
|
||||
|
||||
let parentBeaconblockRoot = cl.latestPayloadAttributes.parentBeaconblockRoot
|
||||
let parentBeaconBlockRoot = cl.latestPayloadAttributes.parentBeaconBlockRoot
|
||||
let requestsHash = calcRequestsHash(x.executionRequests)
|
||||
let header = blockHeader(cl.latestPayloadBuilt, parentBeaconblockRoot = parentBeaconblockRoot, requestsHash)
|
||||
let header = blockHeader(cl.latestPayloadBuilt, parentBeaconBlockRoot, requestsHash)
|
||||
let blockHash = header.blockHash
|
||||
if blockHash != cl.latestPayloadBuilt.blockHash:
|
||||
error "CLMocker: getNextPayload blockHash mismatch",
|
||||
@ -493,9 +493,9 @@ proc broadcastForkchoiceUpdated*(cl: CLMocker,
|
||||
msg=s.payloadStatus.validationError.get
|
||||
return false
|
||||
|
||||
if s.payloadID.isSome:
|
||||
if s.payloadId.isSome:
|
||||
error "CLMocker: Expected empty PayloadID",
|
||||
msg=s.payloadID.get.toHex
|
||||
msg=s.payloadId.get.toHex
|
||||
return false
|
||||
|
||||
return true
|
||||
|
@ -78,11 +78,11 @@ method execute(cs: InconsistentForkchoiceTest, env: TestEnv): bool =
|
||||
|
||||
case cs.field
|
||||
of HeadBlockHash:
|
||||
inconsistentFcU.headblockHash = shadow.alt[len(shadow.alt)-1].blockHash
|
||||
inconsistentFcU.headBlockHash = shadow.alt[len(shadow.alt)-1].blockHash
|
||||
of SafeBlockHash:
|
||||
inconsistentFcU.safeblockHash = shadow.alt[len(shadow.canon)-2].blockHash
|
||||
inconsistentFcU.safeBlockHash = shadow.alt[len(shadow.canon)-2].blockHash
|
||||
of FinalizedBlockHash:
|
||||
inconsistentFcU.finalizedblockHash = shadow.alt[len(shadow.canon)-3].blockHash
|
||||
inconsistentFcU.finalizedBlockHash = shadow.alt[len(shadow.canon)-3].blockHash
|
||||
|
||||
let version = env.engine.version(env.clMock.latestPayloadBuilt.timestamp)
|
||||
var r = env.engine.client.forkchoiceUpdated(version, inconsistentFcU)
|
||||
@ -119,15 +119,15 @@ method execute(cs: ForkchoiceUpdatedUnknownBlockHashTest, env: TestEnv): bool =
|
||||
|
||||
if cs.field == HeadBlockHash:
|
||||
let fcu = ForkchoiceStateV1(
|
||||
headblockHash: randomblockHash,
|
||||
safeblockHash: env.clMock.latestForkchoice.safeblockHash,
|
||||
finalizedblockHash: env.clMock.latestForkchoice.finalizedblockHash,
|
||||
headBlockHash: randomblockHash,
|
||||
safeBlockHash: env.clMock.latestForkchoice.safeBlockHash,
|
||||
finalizedBlockHash: env.clMock.latestForkchoice.finalizedBlockHash,
|
||||
)
|
||||
|
||||
info "forkchoiceStateUnknownHeadHash",
|
||||
head=fcu.headblockHash.short,
|
||||
safe=fcu.safeblockHash.short,
|
||||
final=fcu.finalizedblockHash.short
|
||||
head=fcu.headBlockHash.short,
|
||||
safe=fcu.safeBlockHash.short,
|
||||
final=fcu.finalizedBlockHash.short
|
||||
|
||||
# Execution specification::
|
||||
# - (payloadStatus: (status: SYNCING, latestValidHash: null, validationError: null), payloadId: null)
|
||||
@ -143,21 +143,21 @@ method execute(cs: ForkchoiceUpdatedUnknownBlockHashTest, env: TestEnv): bool =
|
||||
# Test again using PayloadAttributes, should also return SYNCING and no PayloadID
|
||||
r = env.engine.client.forkchoiceUpdated(version, fcu, Opt.some(payloadAttributes))
|
||||
r.expectPayloadStatus(PayloadExecutionStatus.syncing)
|
||||
r.expectPayloadID(Opt.none(PayloadID))
|
||||
r.expectPayloadID(Opt.none(Bytes8))
|
||||
else:
|
||||
let pbRes = env.clMock.produceSingleBlock(BlockProcessCallbacks(
|
||||
# Run test after a new payload has been broadcast
|
||||
onNewPayloadBroadcast: proc(): bool =
|
||||
var fcu = ForkchoiceStateV1(
|
||||
headblockHash: env.clMock.latestExecutedPayload.blockHash,
|
||||
safeblockHash: env.clMock.latestForkchoice.safeblockHash,
|
||||
finalizedblockHash: env.clMock.latestForkchoice.finalizedblockHash,
|
||||
headBlockHash: env.clMock.latestExecutedPayload.blockHash,
|
||||
safeBlockHash: env.clMock.latestForkchoice.safeBlockHash,
|
||||
finalizedBlockHash: env.clMock.latestForkchoice.finalizedBlockHash,
|
||||
)
|
||||
|
||||
if cs.field == SafeBlockHash:
|
||||
fcu.safeblockHash = randomblockHash
|
||||
fcu.safeBlockHash = randomblockHash
|
||||
elif cs.field == FinalizedBlockHash:
|
||||
fcu.finalizedblockHash = randomblockHash
|
||||
fcu.finalizedBlockHash = randomblockHash
|
||||
|
||||
let version = env.engine.version(env.clMock.latestExecutedPayload.timestamp)
|
||||
var r = env.engine.client.forkchoiceUpdated(version, fcu)
|
||||
|
@ -192,11 +192,11 @@ method getName(cs: InvalidMissingAncestorReOrgSyncTest): string =
|
||||
"Invalid Missing Ancestor Syncing ReOrg, $1, EmptyTxs=$2, CanonicalReOrg=$3, Invalid P$4" % [
|
||||
$cs.invalidField, $cs.emptyTransactions, $cs.reOrgFromCanonical, $cs.invalidIndex]
|
||||
|
||||
func blockHeader(ex: ExecutableData): common.BlockHeader =
|
||||
func blockHeader(ex: ExecutableData): Header =
|
||||
let requestsHash = calcRequestsHash(ex.executionRequests)
|
||||
blockHeader(ex.basePayload, ex.beaconRoot, requestsHash)
|
||||
|
||||
func blockBody(ex: ExecutableData): common.BlockBody =
|
||||
func blockBody(ex: ExecutableData): BlockBody =
|
||||
blockBody(ex.basePayload)
|
||||
|
||||
method execute(cs: InvalidMissingAncestorReOrgSyncTest, env: TestEnv): bool =
|
||||
|
@ -346,7 +346,7 @@ method execute(cs: PayloadBuildAfterInvalidPayloadTest, env: TestEnv): bool =
|
||||
|
||||
let
|
||||
versione = env.engine.version(payloadAttributes.timestamp)
|
||||
s = invalidPayloadProducer.client.getPayload(r.get.payloadID.get, versione)
|
||||
s = invalidPayloadProducer.client.getPayload(r.get.payloadId.get, versione)
|
||||
s.expectNoError()
|
||||
|
||||
let basePayload = s.get.executionPayload
|
||||
@ -363,11 +363,11 @@ method execute(cs: PayloadBuildAfterInvalidPayloadTest, env: TestEnv): bool =
|
||||
r = env.engine.client.newPayload(version, inv_p)
|
||||
|
||||
r.expectStatus(PayloadExecutionStatus.invalid)
|
||||
r.expectLatestValidHash(env.clMock.latestForkchoice.headblockHash)
|
||||
r.expectLatestValidHash(env.clMock.latestForkchoice.headBlockHash)
|
||||
|
||||
let s = sec.client.newPayload(version, inv_p)
|
||||
s.expectStatus(PayloadExecutionStatus.invalid)
|
||||
s.expectLatestValidHash(env.clMock.latestForkchoice.headblockHash)
|
||||
s.expectLatestValidHash(env.clMock.latestForkchoice.headBlockHash)
|
||||
|
||||
# Let the block production continue.
|
||||
# At this point the selected payload producer will
|
||||
|
@ -46,9 +46,9 @@ method execute(cs: InvalidPayloadAttributesTest, env: TestEnv): bool =
|
||||
var fcu = env.clMock.latestForkchoice
|
||||
if cs.syncing:
|
||||
# Setting a random hash will put the client into `SYNCING`
|
||||
fcu.headblockHash = Hash32.randomBytes()
|
||||
fcu.headBlockHash = Hash32.randomBytes()
|
||||
else:
|
||||
fcu.headblockHash = env.clMock.latestPayloadBuilt.blockHash
|
||||
fcu.headBlockHash = env.clMock.latestPayloadBuilt.blockHash
|
||||
|
||||
info "Sending EngineForkchoiceUpdated with invalid payload attributes",
|
||||
syncing=cs.syncing, description=cs.description
|
||||
@ -76,7 +76,7 @@ method execute(cs: InvalidPayloadAttributesTest, env: TestEnv): bool =
|
||||
# Check that the forkchoice was applied, regardless of the error
|
||||
let s = env.engine.client.latestHeader()
|
||||
#s.ExpectationDescription = "Forkchoice is applied even on invalid payload attributes"
|
||||
s.expectHash(fcu.headblockHash)
|
||||
s.expectHash(fcu.headBlockHash)
|
||||
|
||||
return true
|
||||
))
|
||||
|
@ -169,7 +169,7 @@ method execute(cs: InOrderPayloadExecutionTest, env: TestEnv): bool =
|
||||
version = sec.version(env.clMock.latestExecutedPayload.timestamp)
|
||||
s = sec.client.forkchoiceUpdated(version, fcU)
|
||||
s.expectPayloadStatus(PayloadExecutionStatus.valid)
|
||||
s.expectLatestValidHash(fcU.headblockHash)
|
||||
s.expectLatestValidHash(fcU.headBlockHash)
|
||||
s.expectNoValidationError()
|
||||
|
||||
# At this point we should have our funded account balance equal to the expected value.
|
||||
@ -460,9 +460,9 @@ method execute(cs: NewPayloadWithMissingFcUTest, env: TestEnv): bool =
|
||||
let version = sec.version(env.clMock.latestHeader.timestamp)
|
||||
let p = sec.client.forkchoiceUpdated(version, fcU)
|
||||
p.expectPayloadStatus(PayloadExecutionStatus.valid)
|
||||
p.expectLatestValidHash(fcU.headblockHash)
|
||||
p.expectLatestValidHash(fcU.headBlockHash)
|
||||
|
||||
# Now the head should've changed to the latest PoS block
|
||||
let s = sec.client.latestHeader()
|
||||
s.expectHash(fcU.headblockHash)
|
||||
s.expectHash(fcU.headBlockHash)
|
||||
return true
|
||||
|
@ -114,7 +114,7 @@ method execute(cs: UniquePayloadIDTest, env: TestEnv): bool =
|
||||
let version = env.engine.version(env.clMock.latestHeader.timestamp)
|
||||
let r = env.engine.client.forkchoiceUpdated(version, env.clMock.latestForkchoice, Opt.some(attr))
|
||||
r.expectNoError()
|
||||
testCond env.clMock.addPayloadID(env.engine, r.get.payloadID.get)
|
||||
testCond env.clMock.addPayloadID(env.engine, r.get.payloadId.get)
|
||||
return true
|
||||
))
|
||||
testCond pbRes
|
||||
|
@ -71,7 +71,7 @@ method execute(cs: SidechainReOrgTest, env: TestEnv): bool =
|
||||
waitFor sleepAsync(period)
|
||||
|
||||
version = env.engine.version(attr.timestamp)
|
||||
let g = env.engine.client.getPayload(r.get.payloadID.get, version)
|
||||
let g = env.engine.client.getPayload(r.get.payloadId.get, version)
|
||||
g.expectNoError()
|
||||
|
||||
let alternativePayload = g.get.executionPayload
|
||||
@ -187,11 +187,11 @@ method execute(cs: TransactionReOrgTest, env: TestEnv): bool =
|
||||
var version = env.engine.version(env.clMock.latestHeader.timestamp)
|
||||
let r = env.engine.client.forkchoiceUpdated(version, env.clMock.latestForkchoice, Opt.some(attr))
|
||||
r.expectNoError()
|
||||
testCond r.get.payloadID.isSome:
|
||||
testCond r.get.payloadId.isSome:
|
||||
fatal "No payload ID returned by forkchoiceUpdated"
|
||||
|
||||
version = env.engine.version(attr.timestamp)
|
||||
let g = env.engine.client.getPayload(r.get.payloadID.get, version)
|
||||
let g = env.engine.client.getPayload(r.get.payloadId.get, version)
|
||||
g.expectNoError()
|
||||
shadow.payload = g.get.executionPayload
|
||||
|
||||
@ -252,7 +252,7 @@ method execute(cs: TransactionReOrgTest, env: TestEnv): bool =
|
||||
waitFor sleepAsync(period)
|
||||
|
||||
version = env.engine.version(env.clMock.latestPayloadAttributes.timestamp)
|
||||
let g = env.engine.client.getPayload(f.get.payloadID.get, version)
|
||||
let g = env.engine.client.getPayload(f.get.payloadId.get, version)
|
||||
g.expectNoError()
|
||||
|
||||
let payload = g.get.executionPayload
|
||||
@ -428,11 +428,11 @@ method execute(cs: ReOrgBackToCanonicalTest, env: TestEnv): bool =
|
||||
var version = env.engine.version(env.clMock.latestHeader.timestamp)
|
||||
let r = env.engine.client.forkchoiceUpdated(version, env.clMock.latestForkchoice, Opt.some(attr))
|
||||
r.expectNoError()
|
||||
testCond r.get.payloadID.isSome:
|
||||
testCond r.get.payloadId.isSome:
|
||||
fatal "No payload ID returned by forkchoiceUpdated"
|
||||
|
||||
version = env.engine.version(attr.timestamp)
|
||||
let g = env.engine.client.getPayload(r.get.payloadID.get, version)
|
||||
let g = env.engine.client.getPayload(r.get.payloadId.get, version)
|
||||
g.expectNoError()
|
||||
|
||||
shadow.payload = g.get.executionPayload
|
||||
@ -692,7 +692,7 @@ method execute(cs: ReOrgPrevValidatedPayloadOnSideChainTest, env: TestEnv): bool
|
||||
r.expectLatestValidHash(reOrgPayload.blockHash)
|
||||
|
||||
version = env.engine.version(newPayloadAttributes.timestamp)
|
||||
let p = env.engine.client.getPayload(r.get.payloadID.get, version)
|
||||
let p = env.engine.client.getPayload(r.get.payloadId.get, version)
|
||||
p.expectPayloadParentHash(reOrgPayload.blockHash)
|
||||
|
||||
let payload = p.get.executionPayload
|
||||
|
@ -75,13 +75,13 @@ method execute(cs: BlockStatus, env: TestEnv): bool =
|
||||
of LatestOnNewPayload:
|
||||
callbacks.onGetPayload = proc(): bool =
|
||||
let r = env.engine.client.namedHeader(Head)
|
||||
r.expectHash(env.clMock.latestForkchoice.headblockHash)
|
||||
r.expectHash(env.clMock.latestForkchoice.headBlockHash)
|
||||
|
||||
let s = env.engine.client.blockNumber()
|
||||
s.expectNumber(env.clMock.latestHeadNumber.uint64)
|
||||
|
||||
let p = env.engine.client.namedHeader(Head)
|
||||
p.expectHash(env.clMock.latestForkchoice.headblockHash)
|
||||
p.expectHash(env.clMock.latestForkchoice.headBlockHash)
|
||||
|
||||
# Check that the receipt for the transaction we just sent is still not available
|
||||
let q = env.engine.client.txReceipt(shadow.txHash)
|
||||
@ -90,19 +90,19 @@ method execute(cs: BlockStatus, env: TestEnv): bool =
|
||||
of LatestOnHeadBlockHash:
|
||||
callbacks.onForkchoiceBroadcast = proc(): bool =
|
||||
let r = env.engine.client.namedHeader(Head)
|
||||
r.expectHash(env.clMock.latestForkchoice.headblockHash)
|
||||
r.expectHash(env.clMock.latestForkchoice.headBlockHash)
|
||||
let s = env.engine.client.txReceipt(shadow.txHash)
|
||||
s.expectTransactionHash(shadow.txHash)
|
||||
return true
|
||||
of SafeOnSafeBlockHash:
|
||||
callbacks.onSafeBlockChange = proc(): bool =
|
||||
let r = env.engine.client.namedHeader(Safe)
|
||||
r.expectHash(env.clMock.latestForkchoice.safeblockHash)
|
||||
r.expectHash(env.clMock.latestForkchoice.safeBlockHash)
|
||||
return true
|
||||
of FinalizedOnFinalizedBlockHash:
|
||||
callbacks.onFinalizedBlockChange = proc(): bool =
|
||||
let r = env.engine.client.namedHeader(Finalized)
|
||||
r.expectHash(env.clMock.latestForkchoice.finalizedblockHash)
|
||||
r.expectHash(env.clMock.latestForkchoice.finalizedBlockHash)
|
||||
return true
|
||||
|
||||
# Perform the test
|
||||
|
@ -660,7 +660,7 @@ proc debugPrevRandaoTransaction*(
|
||||
if stack.len < 1:
|
||||
return err("Invalid stack after PREVRANDAO operation")
|
||||
|
||||
let stackHash = Bytes32(hextoByteArray[32](stack[0].getStr))
|
||||
let stackHash = Bytes32(hexToByteArray[32](stack[0].getStr))
|
||||
if stackHash != expectedPrevRandao:
|
||||
return err("Invalid stack after PREVRANDAO operation $1 != $2" % [stackHash.data.toHex, expectedPrevRandao.data.toHex])
|
||||
|
||||
|
@ -18,7 +18,7 @@ import
|
||||
|
||||
proc txInPayload*(payload: ExecutionPayload, txHash: Hash32): bool =
|
||||
for txBytes in payload.transactions:
|
||||
let currTx = rlp.decode(common.Blob txBytes, Transaction)
|
||||
let currTx = rlp.decode(seq[byte](txBytes), Transaction)
|
||||
if rlpHash(currTx) == txHash:
|
||||
return true
|
||||
|
||||
|
@ -52,10 +52,10 @@ type
|
||||
accounts: seq[TestAccount]
|
||||
nonceMap: Table[Address, uint64]
|
||||
txSent : int
|
||||
chainId : ChainID
|
||||
chainId : ChainId
|
||||
|
||||
MakeTxParams* = object
|
||||
chainId*: ChainID
|
||||
chainId*: ChainId
|
||||
key* : PrivateKey
|
||||
nonce* : AccountNonce
|
||||
|
||||
@ -128,7 +128,7 @@ proc getTxType(tc: BaseTx, nonce: uint64): TxType =
|
||||
if nonce mod 2 == 0:
|
||||
TxLegacy
|
||||
else:
|
||||
TxEIP1559
|
||||
TxEip1559
|
||||
else:
|
||||
tc.txType.get
|
||||
|
||||
@ -157,7 +157,7 @@ proc makeTxOfType(params: MakeTxParams, tc: BaseTx): PooledTransaction =
|
||||
of TxEip1559:
|
||||
PooledTransaction(
|
||||
tx: Transaction(
|
||||
txType : TxEIP1559,
|
||||
txType : TxEip1559,
|
||||
nonce : params.nonce,
|
||||
gasLimit: tc.gasLimit,
|
||||
maxFeePerGas: gasFeeCap,
|
||||
@ -182,7 +182,7 @@ proc makeTxOfType(params: MakeTxParams, tc: BaseTx): PooledTransaction =
|
||||
|
||||
PooledTransaction(
|
||||
tx: Transaction(
|
||||
txType : TxEIP4844,
|
||||
txType : TxEip4844,
|
||||
nonce : params.nonce,
|
||||
chainId : params.chainId,
|
||||
maxFeePerGas: gasFeeCap,
|
||||
@ -433,7 +433,7 @@ proc customizeTransaction*(sender: TxSender,
|
||||
|
||||
if baseTx.txType in {TxEip1559, TxEip4844}:
|
||||
if custTx.gasPriceOrGasFeeCap.isSome:
|
||||
modTx.maxFeePErGas = custTx.gasPriceOrGasFeeCap.get.GasInt
|
||||
modTx.maxFeePerGas = custTx.gasPriceOrGasFeeCap.get.GasInt
|
||||
|
||||
if custTx.gasTipCap.isSome:
|
||||
modTx.maxPriorityFeePerGas = custTx.gasTipCap.get.GasInt
|
||||
|
@ -12,7 +12,6 @@ import
|
||||
stint,
|
||||
chronicles,
|
||||
chronos,
|
||||
stew/byteutils,
|
||||
web3/eth_api_types,
|
||||
./wd_history,
|
||||
../test_env,
|
||||
|
@ -40,7 +40,7 @@ type
|
||||
nextIndex : int
|
||||
wdHistory : WDHistory
|
||||
sidechain : Table[uint64, ExecutionPayload]
|
||||
payloadId : PayloadID
|
||||
payloadId : Bytes8
|
||||
height : uint64
|
||||
attr : Opt[PayloadAttributes]
|
||||
|
||||
@ -180,9 +180,9 @@ proc execute*(ws: ReorgSpec, env: TestEnv): bool =
|
||||
let r = sec.client.forkchoiceUpdated(fcState, attr)
|
||||
r.expectNoError()
|
||||
r.expectPayloadStatus(PayloadExecutionStatus.valid)
|
||||
testCond r.get().payloadID.isSome:
|
||||
testCond r.get().payloadId.isSome:
|
||||
error "Unable to get a payload ID on the sidechain"
|
||||
sidechain.payloadId = r.get().payloadID.get()
|
||||
sidechain.payloadId = r.get().payloadId.get()
|
||||
|
||||
return true
|
||||
,
|
||||
@ -247,7 +247,7 @@ proc execute*(ws: ReorgSpec, env: TestEnv): bool =
|
||||
let r = sec.client.forkchoiceUpdatedV2(fcState, Opt.some(attr))
|
||||
r.expectPayloadStatus(PayloadExecutionStatus.valid)
|
||||
|
||||
let p = sec.client.getPayloadV2(r.get().payloadID.get)
|
||||
let p = sec.client.getPayloadV2(r.get().payloadId.get)
|
||||
p.expectNoError()
|
||||
|
||||
let z = p.get()
|
||||
|
@ -35,7 +35,7 @@ type
|
||||
const
|
||||
initPath = "hive_integration" / "nodocker" / "rpc" / "init"
|
||||
gasPrice* = 30.gwei
|
||||
chainID* = ChainID(7)
|
||||
chainID* = ChainId(7)
|
||||
|
||||
proc manageAccounts(ctx: EthContext, conf: NimbusConf) =
|
||||
if string(conf.importKey).len > 0:
|
||||
|
@ -42,12 +42,12 @@ type
|
||||
accounts: Table[Address, PrivateKey]
|
||||
|
||||
rng: ref HmacDrbgContext
|
||||
chainId: ChainID
|
||||
chainId: ChainId
|
||||
gasPrice: GasInt
|
||||
vaultKey: PrivateKey
|
||||
client: RpcClient
|
||||
|
||||
proc newVault*(chainID: ChainID, gasPrice: GasInt, client: RpcClient): Vault =
|
||||
proc newVault*(chainID: ChainId, gasPrice: GasInt, client: RpcClient): Vault =
|
||||
new(result)
|
||||
result.rng = newRng()
|
||||
result.chainId = chainID
|
||||
|
@ -19,15 +19,15 @@ import
|
||||
# Private helpers
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
template append(w: var RlpWriter, t: TypedTransaction) =
|
||||
w.appendRawBytes(distinctBase t)
|
||||
template append(w: var RlpWriter, typedTransaction: TypedTransaction) =
|
||||
w.appendRawBytes(distinctBase typedTransaction)
|
||||
|
||||
template append(w: var RlpWriter, t: WithdrawalV1) =
|
||||
template append(w: var RlpWriter, withdrawalV1: WithdrawalV1) =
|
||||
w.append blocks.Withdrawal(
|
||||
index: distinctBase(t.index),
|
||||
validatorIndex: distinctBase(t.validatorIndex),
|
||||
address: t.address,
|
||||
amount: distinctBase(t.amount),
|
||||
index: distinctBase(withdrawalV1.index),
|
||||
validatorIndex: distinctBase(withdrawalV1.validatorIndex),
|
||||
address: withdrawalV1.address,
|
||||
amount: distinctBase(withdrawalV1.amount),
|
||||
)
|
||||
|
||||
func wdRoot(list: openArray[WithdrawalV1]): Hash32 =
|
||||
|
@ -29,8 +29,8 @@ type
|
||||
Web3BlockNumber* = Quantity
|
||||
Web3Tx* = engine_api_types.TypedTransaction
|
||||
Web3Blob* = engine_api_types.Blob
|
||||
Web3KZGProof* = engine_api_types.KZGProof
|
||||
Web3KZGCommitment* = engine_api_types.KZGCommitment
|
||||
Web3KZGProof* = engine_api_types.KzgProof
|
||||
Web3KZGCommitment* = engine_api_types.KzgCommitment
|
||||
|
||||
{.push gcsafe, raises:[].}
|
||||
|
||||
|
@ -715,7 +715,7 @@ proc getBootNodes*(conf: NimbusConf): seq[ENode] =
|
||||
|
||||
# Bootstrap nodes provided as ENRs
|
||||
for enr in conf.bootstrapEnrs:
|
||||
let enode = Enode.fromEnr(enr).valueOr:
|
||||
let enode = ENode.fromEnr(enr).valueOr:
|
||||
fatal "Invalid bootstrap ENR provided", error
|
||||
quit 1
|
||||
|
||||
@ -730,7 +730,7 @@ proc getStaticPeers*(conf: NimbusConf): seq[ENode] =
|
||||
|
||||
# Static peers provided as ENRs
|
||||
for enr in conf.staticPeersEnrs:
|
||||
let enode = Enode.fromEnr(enr).valueOr:
|
||||
let enode = ENode.fromEnr(enr).valueOr:
|
||||
fatal "Invalid static peer ENR provided", error
|
||||
quit 1
|
||||
|
||||
|
@ -109,7 +109,7 @@ proc disposeById*(xp: TxPoolRef; itemIDs: openArray[Hash32]; reason: TxInfo)
|
||||
## unusable (e.g. with higher nonces for the same sender.)
|
||||
for itemID in itemIDs:
|
||||
let rcItem = xp.txDB.byItemID.eq(itemID)
|
||||
if rcItem.isOK:
|
||||
if rcItem.isOk:
|
||||
discard xp.txDB.dispose(rcItem.value, reason)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -105,7 +105,7 @@ type
|
||||
proc(db: AristoDbRef;
|
||||
accPath: Hash32;
|
||||
stoPath: Hash32;
|
||||
): Result[Uint256,AristoError]
|
||||
): Result[UInt256,AristoError]
|
||||
{.noRaise.}
|
||||
## For a storage tree related to account `accPath`, fetch the data
|
||||
## record from the database indexed by `stoPath`.
|
||||
@ -816,7 +816,7 @@ func init*(
|
||||
result = api.mergeAccountRecord(a, b, c)
|
||||
|
||||
profApi.mergeStorageData =
|
||||
proc(a: AristoDbRef; b, c: Hash32, d: Uint256): auto =
|
||||
proc(a: AristoDbRef; b, c: Hash32, d: UInt256): auto =
|
||||
AristoApiProfMergeStorageDataFn.profileRunner:
|
||||
result = api.mergeStorageData(a, b, c, d)
|
||||
|
||||
|
@ -103,7 +103,7 @@ proc getKey*(
|
||||
): Result[HashKey,(AristoError,string)] =
|
||||
# Try LRU cache first
|
||||
var rc = rdb.rdKeyLru.get(rvid.vid)
|
||||
if rc.isOK:
|
||||
if rc.isOk:
|
||||
rdbKeyLruStats[rvid.to(RdbStateType)].inc(true)
|
||||
return ok(move(rc.value))
|
||||
|
||||
@ -144,7 +144,7 @@ proc getVtx*(
|
||||
else:
|
||||
rdb.rdVtxLru.get(rvid.vid)
|
||||
|
||||
if rc.isOK:
|
||||
if rc.isOk:
|
||||
rdbVtxLruStats[rvid.to(RdbStateType)][rc.value().vType].inc(true)
|
||||
return ok(move(rc.value))
|
||||
|
||||
|
@ -65,7 +65,7 @@ proc branchNibbleMax*(vtx: VertexRef; maxInx: int8): int8 =
|
||||
## Find the greatest index for an argument branch `vtx` link with index
|
||||
## less or equal the argument `nibble`.
|
||||
if vtx.vType == Branch:
|
||||
for n in maxInx.countDown 0:
|
||||
for n in maxInx.countdown 0:
|
||||
if vtx.bVid[n].isValid:
|
||||
return n
|
||||
-1
|
||||
@ -400,7 +400,7 @@ iterator rightPairs*(
|
||||
var hike: Hike
|
||||
discard start.hikeUp(db, Opt.none(VertexRef), hike)
|
||||
var rc = hike.right db
|
||||
while rc.isOK:
|
||||
while rc.isOk:
|
||||
hike = rc.value
|
||||
let (key, pyl) = hike.toLeafTiePayload
|
||||
yield (key, pyl)
|
||||
@ -497,7 +497,7 @@ iterator leftPairs*(
|
||||
discard start.hikeUp(db, Opt.none(VertexRef), hike)
|
||||
|
||||
var rc = hike.left db
|
||||
while rc.isOK:
|
||||
while rc.isOk:
|
||||
hike = rc.value
|
||||
let (key, pyl) = hike.toLeafTiePayload
|
||||
yield (key, pyl)
|
||||
|
@ -47,7 +47,7 @@ func toFloat(ela: Duration): float =
|
||||
## Convert the argument `ela` to a floating point seconds result.
|
||||
let
|
||||
elaS = ela.inSeconds
|
||||
elaNs = (ela - initDuration(seconds=elaS)).inNanoSeconds
|
||||
elaNs = (ela - initDuration(seconds=elaS)).inNanoseconds
|
||||
elaS.float + elaNs.float / 1_000_000_000
|
||||
|
||||
proc updateTotal(t: AristoDbProfListRef; fnInx: uint) =
|
||||
@ -107,12 +107,12 @@ func toStr*(elapsed: Duration): string =
|
||||
result = elapsed.ppMins
|
||||
elif 0 < times.inSeconds(elapsed):
|
||||
result = elapsed.ppSecs
|
||||
elif 0 < times.inMilliSeconds(elapsed):
|
||||
elif 0 < times.inMilliseconds(elapsed):
|
||||
result = elapsed.ppMs
|
||||
elif 0 < times.inMicroSeconds(elapsed):
|
||||
elif 0 < times.inMicroseconds(elapsed):
|
||||
result = elapsed.ppUs
|
||||
else:
|
||||
result = $elapsed.inNanoSeconds & "ns"
|
||||
result = $elapsed.inNanoseconds & "ns"
|
||||
except ValueError:
|
||||
result = $elapsed
|
||||
|
||||
|
@ -178,7 +178,7 @@ iterator txFrameWalk*(tx: AristoTxRef): (int,AristoTxRef,LayerRef,AristoError) =
|
||||
yield (0,tx,db.top,AristoError(0))
|
||||
|
||||
# Walk down the transaction stack
|
||||
for level in (tx.level-1).countDown(1):
|
||||
for level in (tx.level-1).countdown(1):
|
||||
tx = tx.parent
|
||||
if tx.isNil or tx.level != level:
|
||||
yield (-1,tx,LayerRef(nil),TxStackGarbled)
|
||||
|
@ -340,7 +340,7 @@ func logRecord(
|
||||
func logRecord(
|
||||
info: AristoApiProfNames;
|
||||
req: TraceRequest;
|
||||
sto: Uint256;
|
||||
sto: UInt256;
|
||||
): TraceDataItemRef =
|
||||
TraceDataItemRef(
|
||||
pfx: info.to(TracePfx),
|
||||
@ -507,7 +507,7 @@ proc ariTraceRecorder(tr: TraceRecorderRef) =
|
||||
proc(mpt: AristoDbRef;
|
||||
accPath: Hash32;
|
||||
stoPath: Hash32;
|
||||
): Result[Uint256,AristoError] =
|
||||
): Result[UInt256,AristoError] =
|
||||
const info = AristoApiProfFetchStorageDataFn
|
||||
|
||||
when CoreDbNoisyCaptJournal:
|
||||
|
@ -58,13 +58,13 @@ template ctx*(kvt: CoreDbKvtRef): CoreDbCtxRef =
|
||||
|
||||
# ---------------
|
||||
|
||||
template call*(api: KvtApiRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||
template call*(api: KvtApiRef; fn: untyped; args: varargs[untyped]): untyped =
|
||||
when CoreDbEnableApiJumpTable:
|
||||
api.fn(args)
|
||||
else:
|
||||
fn(args)
|
||||
|
||||
template call*(kvt: CoreDbKvtRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||
template call*(kvt: CoreDbKvtRef; fn: untyped; args: varargs[untyped]): untyped =
|
||||
CoreDbCtxRef(kvt).parent.kvtApi.call(fn, args)
|
||||
|
||||
# ---------------
|
||||
@ -91,7 +91,7 @@ template ctx*(acc: CoreDbAccRef): CoreDbCtxRef =
|
||||
|
||||
# ---------------
|
||||
|
||||
template call*(api: AristoApiRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||
template call*(api: AristoApiRef; fn: untyped; args: varargs[untyped]): untyped =
|
||||
when CoreDbEnableApiJumpTable:
|
||||
api.fn(args)
|
||||
else:
|
||||
@ -100,7 +100,7 @@ template call*(api: AristoApiRef; fn: untyped; args: varArgs[untyped]): untyped
|
||||
template call*(
|
||||
acc: CoreDbAccRef;
|
||||
fn: untyped;
|
||||
args: varArgs[untyped];
|
||||
args: varargs[untyped];
|
||||
): untyped =
|
||||
CoreDbCtxRef(acc).parent.ariApi.call(fn, args)
|
||||
|
||||
|
@ -48,13 +48,13 @@ template dbType(dsc: CoreDbKvtRef | CoreDbAccRef): CoreDbType =
|
||||
template kvt(dsc: CoreDbKvtRef): KvtDbRef =
|
||||
dsc.distinctBase.kvt
|
||||
|
||||
template call(api: KvtApiRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||
template call(api: KvtApiRef; fn: untyped; args: varargs[untyped]): untyped =
|
||||
when CoreDbEnableApiJumpTable:
|
||||
api.fn(args)
|
||||
else:
|
||||
fn(args)
|
||||
|
||||
template call(kvt: CoreDbKvtRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||
template call(kvt: CoreDbKvtRef; fn: untyped; args: varargs[untyped]): untyped =
|
||||
kvt.distinctBase.parent.kvtApi.call(fn, args)
|
||||
|
||||
# ---------------
|
||||
@ -62,7 +62,7 @@ template call(kvt: CoreDbKvtRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||
template mpt(dsc: CoreDbAccRef): AristoDbRef =
|
||||
dsc.distinctBase.mpt
|
||||
|
||||
template call(api: AristoApiRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||
template call(api: AristoApiRef; fn: untyped; args: varargs[untyped]): untyped =
|
||||
when CoreDbEnableApiJumpTable:
|
||||
api.fn(args)
|
||||
else:
|
||||
@ -71,7 +71,7 @@ template call(api: AristoApiRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||
template call(
|
||||
acc: CoreDbAccRef;
|
||||
fn: untyped;
|
||||
args: varArgs[untyped];
|
||||
args: varargs[untyped];
|
||||
): untyped =
|
||||
acc.distinctBase.parent.ariApi.call(fn, args)
|
||||
|
||||
|
@ -783,14 +783,14 @@ proc txAccessList(ud: RootRef, params: Args, parent: Node): RespResult {.apiPrag
|
||||
|
||||
proc txMaxFeePerBlobGas(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} =
|
||||
let tx = TxNode(parent)
|
||||
if tx.tx.txType < TxEIP4844:
|
||||
if tx.tx.txType < TxEip4844:
|
||||
ok(respNull())
|
||||
else:
|
||||
longNode(tx.tx.maxFeePerBlobGas)
|
||||
|
||||
proc txVersionedHashes(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} =
|
||||
let tx = TxNode(parent)
|
||||
if tx.tx.txType < TxEIP4844:
|
||||
if tx.tx.txType < TxEip4844:
|
||||
ok(respNull())
|
||||
else:
|
||||
var list = respList()
|
||||
|
@ -160,7 +160,7 @@ proc populateTransactionObject*(tx: Transaction,
|
||||
result.chainId = Opt.some(Quantity(tx.chainId))
|
||||
result.accessList = Opt.some(tx.accessList)
|
||||
|
||||
if tx.txType >= TxEIP4844:
|
||||
if tx.txType >= TxEip4844:
|
||||
result.maxFeePerBlobGas = Opt.some(tx.maxFeePerBlobGas)
|
||||
result.blobVersionedHashes = Opt.some(tx.versionedHashes)
|
||||
|
||||
|
@ -65,7 +65,7 @@ proc populateTransactionObject*(tx: Transaction,
|
||||
result.chainId = Opt.some(Quantity(tx.chainId))
|
||||
result.accessList = Opt.some(tx.accessList)
|
||||
|
||||
if tx.txType >= TxEIP4844:
|
||||
if tx.txType >= TxEip4844:
|
||||
result.maxFeePerBlobGas = Opt.some(tx.maxFeePerBlobGas)
|
||||
result.blobVersionedHashes = Opt.some(tx.versionedHashes)
|
||||
|
||||
|
@ -70,7 +70,7 @@ proc headerStagedUpdateTarget*(
|
||||
let rc = await buddy.headersFetchReversed(iv, ctx.target.finalHash, info)
|
||||
ctx.target.locked = false
|
||||
|
||||
if rc.isOK:
|
||||
if rc.isOk:
|
||||
let hash = rlp.encode(rc.value[0]).keccak256
|
||||
if hash != ctx.target.finalHash:
|
||||
# Oops
|
||||
|
@ -32,7 +32,7 @@ proc beforeExecCreateEvmcNested(host: TransactionHost,
|
||||
gas: GasInt m.gas,
|
||||
sender: m.sender.fromEvmc,
|
||||
value: m.value.fromEvmc,
|
||||
data: @(makeOpenArray(m.inputData, m.inputSize.int))
|
||||
data: @(makeOpenArray(m.input_data, m.input_size.int))
|
||||
)
|
||||
return newComputation(host.vmState, false, childMsg,
|
||||
cast[ContractSalt](m.create2_salt))
|
||||
@ -68,7 +68,7 @@ proc beforeExecCallEvmcNested(host: TransactionHost,
|
||||
else:
|
||||
host.computation.msg.contractAddress,
|
||||
value: m.value.fromEvmc,
|
||||
data: @(makeOpenArray(m.inputData, m.inputSize.int)),
|
||||
data: @(makeOpenArray(m.input_data, m.input_size.int)),
|
||||
flags: m.flags,
|
||||
)
|
||||
return newComputation(host.vmState, false, childMsg)
|
||||
|
@ -377,7 +377,7 @@ proc verifyAsmResult(vmState: BaseVMState, boa: Assembler, asmResult: CallResult
|
||||
proc createSignedTx(payload: seq[byte], chainId: ChainId): Transaction =
|
||||
let privateKey = PrivateKey.fromHex("7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d")[]
|
||||
let unsignedTx = Transaction(
|
||||
txType: TxEIP4844,
|
||||
txType: TxEip4844,
|
||||
nonce: 0,
|
||||
gasPrice: 1.GasInt,
|
||||
gasLimit: 500_000_000.GasInt,
|
||||
|
@ -90,12 +90,12 @@ func pp*(elapsed: Duration): string =
|
||||
result = elapsed.ppMins
|
||||
elif 0 < times.inSeconds(elapsed):
|
||||
result = elapsed.ppSecs
|
||||
elif 0 < times.inMilliSeconds(elapsed):
|
||||
elif 0 < times.inMilliseconds(elapsed):
|
||||
result = elapsed.ppMs
|
||||
elif 0 < times.inMicroSeconds(elapsed):
|
||||
elif 0 < times.inMicroseconds(elapsed):
|
||||
result = elapsed.ppUs
|
||||
else:
|
||||
result = $elapsed.inNanoSeconds & "ns"
|
||||
result = $elapsed.inNanoseconds & "ns"
|
||||
except ValueError:
|
||||
result = $elapsed
|
||||
|
||||
|
@ -18,11 +18,8 @@ import
|
||||
aristo_check,
|
||||
aristo_compute,
|
||||
aristo_delete,
|
||||
aristo_get,
|
||||
aristo_merge,
|
||||
aristo_desc,
|
||||
aristo_utils,
|
||||
aristo_serialise,
|
||||
aristo_init,
|
||||
aristo_tx/tx_stow,
|
||||
]
|
||||
|
@ -20,11 +20,11 @@ import
|
||||
type
|
||||
Tester = object
|
||||
parentTimestamp: int64
|
||||
parentDifficulty: Uint256
|
||||
parentDifficulty: UInt256
|
||||
parentUncles: Hash32
|
||||
currentTimestamp: int64
|
||||
currentBlockNumber: uint64
|
||||
currentDifficulty: Uint256
|
||||
currentDifficulty: UInt256
|
||||
|
||||
Tests = Table[string, Tester]
|
||||
|
||||
@ -37,11 +37,11 @@ proc hexOrInt64(data: JsonNode, key: string, hex: static[bool]): int64 =
|
||||
else:
|
||||
int64(parseInt data[key].getStr)
|
||||
|
||||
proc hexOrInt256(data: JsonNode, key: string, hex: static[bool]): Uint256 =
|
||||
proc hexOrInt256(data: JsonNode, key: string, hex: static[bool]): UInt256 =
|
||||
when hex:
|
||||
UInt256.fromHex data[key].getStr
|
||||
else:
|
||||
parse(data[key].getStr, Uint256)
|
||||
parse(data[key].getStr, UInt256)
|
||||
|
||||
proc parseHash(data: string): Hash32 =
|
||||
case data
|
||||
@ -50,7 +50,7 @@ proc parseHash(data: string): Hash32 =
|
||||
else:
|
||||
doAssert(false, "invalid uncle hash")
|
||||
|
||||
proc parseTests(testData: JSonNode): Tests =
|
||||
proc parseTests(testData: JsonNode): Tests =
|
||||
const hex = true
|
||||
result = Table[string, Tester]()
|
||||
var t: Tester
|
||||
@ -115,7 +115,7 @@ template runTest() =
|
||||
|
||||
for fname in filenames:
|
||||
let filename = fname
|
||||
test fname.subStr(inputPath.len + 1):
|
||||
test fname.substr(inputPath.len + 1):
|
||||
let fixtures = parseJson(readFile(filename))
|
||||
testFixture(fixtures, testStatusIMPL)
|
||||
|
||||
|
@ -155,7 +155,7 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
|
||||
ctx.chainConfig = getChainConfig(forkName)
|
||||
except ValueError as ex:
|
||||
debugEcho ex.msg
|
||||
testStatusIMPL = TestStatus.Failed
|
||||
testStatusIMPL = TestStatus.FAILED
|
||||
return
|
||||
|
||||
template runSubTest(subTest: JsonNode) =
|
||||
|
@ -89,7 +89,7 @@ proc customGenesisTest() =
|
||||
let com = CommonRef.new(newCoreDbRef DefaultDbMemory, params = cg)
|
||||
let stateRoot = hash32"d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"
|
||||
let genesisHash = hash32"d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
|
||||
let ttd = "46_089_003_871_917_200_000_000".parse(Uint256)
|
||||
let ttd = "46_089_003_871_917_200_000_000".parse(UInt256)
|
||||
check com.genesisHeader.stateRoot == stateRoot
|
||||
check com.genesisHeader.blockHash == genesisHash
|
||||
check com.ttd.get == ttd
|
||||
@ -102,7 +102,7 @@ proc customGenesisTest() =
|
||||
let com = CommonRef.new(newCoreDbRef DefaultDbMemory, params = cg)
|
||||
let stateRoot = hash32"d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"
|
||||
let genesisHash = hash32"d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
|
||||
let ttd = "46_089_003_871_917_200_000_000".parse(Uint256)
|
||||
let ttd = "46_089_003_871_917_200_000_000".parse(UInt256)
|
||||
check com.genesisHeader.stateRoot == stateRoot
|
||||
check com.genesisHeader.blockHash == genesisHash
|
||||
check com.ttd.get == ttd
|
||||
|
@ -68,7 +68,7 @@ proc jsonTestImpl*(inputFolder, outputName: string, handler, skipTest: NimNode):
|
||||
doAssert(filenames.len > 0)
|
||||
for fname in filenames:
|
||||
let filename = fname
|
||||
test fname.subStr(inputPath.len + 1):
|
||||
test fname.substr(inputPath.len + 1):
|
||||
{.gcsafe.}:
|
||||
let
|
||||
(folder, name) = filename.splitPath()
|
||||
|
@ -306,7 +306,7 @@ proc opMemoryMain*() =
|
||||
var body = newStmtList()
|
||||
var stack = newStmtList()
|
||||
|
||||
for x in countDown(i, 0):
|
||||
for x in countdown(i, 0):
|
||||
let val = newLit("0x" & toHex(x+10, 2))
|
||||
body.add quote do:
|
||||
`pushIdent` `val`
|
||||
|
@ -211,7 +211,7 @@ proc readValue*(r: var JsonReader[T8Conv], val: var TransContext)
|
||||
of "txs" : r.readValue(val.txsJson)
|
||||
of "txsRlp" : r.readValue(val.txsRlp)
|
||||
|
||||
proc parseTxJson(txo: TxObject, chainId: ChainID): Result[Transaction, string] =
|
||||
proc parseTxJson(txo: TxObject, chainId: ChainId): Result[Transaction, string] =
|
||||
template required(field) =
|
||||
const fName = astToStr(oField)
|
||||
if txo.field.isNone:
|
||||
@ -308,33 +308,31 @@ proc filterGoodTransactions*(ctx: TransContext): seq[Transaction] =
|
||||
if txRes.isOk:
|
||||
result.add txRes.get
|
||||
|
||||
template wrapException(procName: string, body) =
|
||||
template wrapException(body) =
|
||||
try:
|
||||
body
|
||||
except SerializationError as exc:
|
||||
debugEcho "procName: ", procName
|
||||
raise newError(ErrorJson, exc.msg)
|
||||
except IOError as exc:
|
||||
debugEcho "procName: ", procName
|
||||
raise newError(ErrorJson, exc.msg)
|
||||
|
||||
proc parseTxsJson*(ctx: var TransContext, jsonFile: string) {.raises: [T8NError].} =
|
||||
wrapException("parseTxsJson"):
|
||||
wrapException:
|
||||
ctx.txsJson = T8Conv.loadFile(jsonFile, seq[TxObject])
|
||||
|
||||
proc parseAlloc*(ctx: var TransContext, allocFile: string) {.raises: [T8NError].} =
|
||||
wrapException("parseAlloc"):
|
||||
wrapException:
|
||||
ctx.alloc = T8Conv.loadFile(allocFile, GenesisAlloc)
|
||||
|
||||
proc parseEnv*(ctx: var TransContext, envFile: string) {.raises: [T8NError].} =
|
||||
wrapException("parseEnv"):
|
||||
wrapException:
|
||||
ctx.env = T8Conv.loadFile(envFile, EnvStruct)
|
||||
|
||||
proc parseTxsRlp*(ctx: var TransContext, hexData: string) {.raises: [ValueError].} =
|
||||
ctx.txsRlp = hexToSeqByte(hexData)
|
||||
|
||||
proc parseInputFromStdin*(ctx: var TransContext) {.raises: [T8NError].} =
|
||||
wrapException("parseInputFromStdin"):
|
||||
wrapException:
|
||||
let jsonData = stdin.readAll()
|
||||
ctx = T8Conv.decode(jsonData, TransContext)
|
||||
|
||||
|
@ -71,9 +71,7 @@ proc dispatchOutput(ctx: TransContext, conf: T8NConf, res: ExecOutput) =
|
||||
dis.dispatch(conf.outputBaseDir, conf.outputAlloc, "alloc", @@(res.alloc))
|
||||
dis.dispatch(conf.outputBaseDir, conf.outputResult, "result", @@(res.result))
|
||||
|
||||
let chainId = conf.stateChainId.ChainId
|
||||
let txList = ctx.filterGoodTransactions()
|
||||
|
||||
let body = @@(rlp.encode(txList))
|
||||
dis.dispatch(conf.outputBaseDir, conf.outputBody, "body", body)
|
||||
|
||||
|
2
vendor/nimbus-build-system
vendored
2
vendor/nimbus-build-system
vendored
@ -1 +1 @@
|
||||
Subproject commit 4afb0526629f51aef4c124368365ebe90a782d37
|
||||
Subproject commit 8fafcd0bac9f409091b7bcaee62ab6330f57441e
|
Loading…
x
Reference in New Issue
Block a user