mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-16 05:56:24 +00:00
Bump nim-eth and nimbus-eth2 (#2741)
* Bump nim-eth and nimbus-eth2 * Fix ambiguous identifier
This commit is contained in:
parent
2838191c4f
commit
1126c7700d
@ -12,10 +12,10 @@ import stint, json_rpc/[client, jsonmarshal], web3/conversions, web3/eth_api_typ
|
|||||||
export eth_api_types
|
export eth_api_types
|
||||||
|
|
||||||
createRpcSigsFromNim(RpcClient):
|
createRpcSigsFromNim(RpcClient):
|
||||||
proc debug_getBalanceByStateRoot(data: Address, stateRoot: Hash256): UInt256
|
proc debug_getBalanceByStateRoot(data: Address, stateRoot: Hash32): UInt256
|
||||||
proc debug_getTransactionCountByStateRoot(data: Address, stateRoot: Hash256): Quantity
|
proc debug_getTransactionCountByStateRoot(data: Address, stateRoot: Hash32): Quantity
|
||||||
proc debug_getStorageAtByStateRoot(
|
proc debug_getStorageAtByStateRoot(
|
||||||
data: Address, slot: UInt256, stateRoot: Hash256
|
data: Address, slot: UInt256, stateRoot: Hash32
|
||||||
): FixedBytes[32]
|
): FixedBytes[32]
|
||||||
|
|
||||||
proc debug_getCodeByStateRoot(data: Address, stateRoot: Hash256): seq[byte]
|
proc debug_getCodeByStateRoot(data: Address, stateRoot: Hash32): seq[byte]
|
||||||
|
@ -287,7 +287,7 @@ proc installEthApiHandlers*(
|
|||||||
let
|
let
|
||||||
sn = stateNetwork.getOrRaise()
|
sn = stateNetwork.getOrRaise()
|
||||||
blockNumber = quantityTag.number.uint64
|
blockNumber = quantityTag.number.uint64
|
||||||
balance = (await sn.getBalance(blockNumber, data.EthAddress)).valueOr:
|
balance = (await sn.getBalance(blockNumber, data)).valueOr:
|
||||||
raise newException(ValueError, "Unable to get balance")
|
raise newException(ValueError, "Unable to get balance")
|
||||||
|
|
||||||
return balance
|
return balance
|
||||||
@ -312,7 +312,7 @@ proc installEthApiHandlers*(
|
|||||||
let
|
let
|
||||||
sn = stateNetwork.getOrRaise()
|
sn = stateNetwork.getOrRaise()
|
||||||
blockNumber = quantityTag.number.uint64
|
blockNumber = quantityTag.number.uint64
|
||||||
nonce = (await sn.getTransactionCount(blockNumber, data.EthAddress)).valueOr:
|
nonce = (await sn.getTransactionCount(blockNumber, data)).valueOr:
|
||||||
raise newException(ValueError, "Unable to get transaction count")
|
raise newException(ValueError, "Unable to get transaction count")
|
||||||
return nonce.Quantity
|
return nonce.Quantity
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ proc installEthApiHandlers*(
|
|||||||
let
|
let
|
||||||
sn = stateNetwork.getOrRaise()
|
sn = stateNetwork.getOrRaise()
|
||||||
blockNumber = quantityTag.number.uint64
|
blockNumber = quantityTag.number.uint64
|
||||||
slotValue = (await sn.getStorageAt(blockNumber, data.EthAddress, slot)).valueOr:
|
slotValue = (await sn.getStorageAt(blockNumber, data, slot)).valueOr:
|
||||||
raise newException(ValueError, "Unable to get storage slot")
|
raise newException(ValueError, "Unable to get storage slot")
|
||||||
return FixedBytes[32](slotValue.toBytesBE())
|
return FixedBytes[32](slotValue.toBytesBE())
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ proc installEthApiHandlers*(
|
|||||||
let
|
let
|
||||||
sn = stateNetwork.getOrRaise()
|
sn = stateNetwork.getOrRaise()
|
||||||
blockNumber = quantityTag.number.uint64
|
blockNumber = quantityTag.number.uint64
|
||||||
bytecode = (await sn.getCode(blockNumber, data.EthAddress)).valueOr:
|
bytecode = (await sn.getCode(blockNumber, data)).valueOr:
|
||||||
raise newException(ValueError, "Unable to get code")
|
raise newException(ValueError, "Unable to get code")
|
||||||
return bytecode.asSeq()
|
return bytecode.asSeq()
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ proc installEthApiHandlers*(
|
|||||||
let
|
let
|
||||||
sn = stateNetwork.getOrRaise()
|
sn = stateNetwork.getOrRaise()
|
||||||
blockNumber = quantityTag.number.uint64
|
blockNumber = quantityTag.number.uint64
|
||||||
proofs = (await sn.getProofs(blockNumber, data.EthAddress, slots)).valueOr:
|
proofs = (await sn.getProofs(blockNumber, data, slots)).valueOr:
|
||||||
raise newException(ValueError, "Unable to get proofs")
|
raise newException(ValueError, "Unable to get proofs")
|
||||||
|
|
||||||
var storageProof = newSeqOfCap[StorageProof](slots.len)
|
var storageProof = newSeqOfCap[StorageProof](slots.len)
|
||||||
|
@ -84,7 +84,7 @@ proc asPortalBlockData*(
|
|||||||
header = Header(
|
header = Header(
|
||||||
parentHash: payload.parentHash,
|
parentHash: payload.parentHash,
|
||||||
ommersHash: EMPTY_UNCLE_HASH,
|
ommersHash: EMPTY_UNCLE_HASH,
|
||||||
coinbase: EthAddress payload.feeRecipient,
|
coinbase: payload.feeRecipient,
|
||||||
stateRoot: payload.stateRoot,
|
stateRoot: payload.stateRoot,
|
||||||
transactionsRoot: txRoot,
|
transactionsRoot: txRoot,
|
||||||
receiptsRoot: payload.receiptsRoot,
|
receiptsRoot: payload.receiptsRoot,
|
||||||
@ -127,7 +127,7 @@ proc asPortalBlockData*(
|
|||||||
header = Header(
|
header = Header(
|
||||||
parentHash: payload.parentHash,
|
parentHash: payload.parentHash,
|
||||||
ommersHash: EMPTY_UNCLE_HASH,
|
ommersHash: EMPTY_UNCLE_HASH,
|
||||||
coinbase: EthAddress payload.feeRecipient,
|
coinbase: payload.feeRecipient,
|
||||||
stateRoot: payload.stateRoot,
|
stateRoot: payload.stateRoot,
|
||||||
transactionsRoot: txRoot,
|
transactionsRoot: txRoot,
|
||||||
receiptsRoot: payload.receiptsRoot,
|
receiptsRoot: payload.receiptsRoot,
|
||||||
@ -158,7 +158,7 @@ proc asPortalBlockData*(
|
|||||||
Withdrawal(
|
Withdrawal(
|
||||||
index: x.index.uint64,
|
index: x.index.uint64,
|
||||||
validatorIndex: x.validatorIndex.uint64,
|
validatorIndex: x.validatorIndex.uint64,
|
||||||
address: x.address.EthAddress,
|
address: x.address,
|
||||||
amount: x.amount.uint64,
|
amount: x.amount.uint64,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ proc runBackfillCollectBlockDataLoop(
|
|||||||
let blockData = BlockData(
|
let blockData = BlockData(
|
||||||
blockNumber: currentBlockNumber,
|
blockNumber: currentBlockNumber,
|
||||||
blockHash: blockObject.hash,
|
blockHash: blockObject.hash,
|
||||||
miner: blockObject.miner.EthAddress,
|
miner: blockObject.miner,
|
||||||
uncles: uncleBlocks.mapIt((it.miner.EthAddress, it.number.uint64)),
|
uncles: uncleBlocks.mapIt((it.miner, it.number.uint64)),
|
||||||
parentStateRoot: parentStateRoot,
|
parentStateRoot: parentStateRoot,
|
||||||
stateRoot: blockObject.stateRoot,
|
stateRoot: blockObject.stateRoot,
|
||||||
stateDiffs: stateDiffs,
|
stateDiffs: stateDiffs,
|
||||||
|
@ -29,8 +29,8 @@ type
|
|||||||
TestBlobTxPool* = ref object
|
TestBlobTxPool* = ref object
|
||||||
currentBlobID* : BlobID
|
currentBlobID* : BlobID
|
||||||
currentTxIndex*: int
|
currentTxIndex*: int
|
||||||
transactions* : Table[common.Hash256, PooledTransaction]
|
transactions* : Table[Hash32, PooledTransaction]
|
||||||
hashesByIndex* : Table[int, common.Hash256]
|
hashesByIndex* : Table[int, Hash32]
|
||||||
|
|
||||||
const
|
const
|
||||||
HISTORY_BUFFER_LENGTH* = 8191
|
HISTORY_BUFFER_LENGTH* = 8191
|
||||||
@ -147,7 +147,7 @@ proc beaconRootStorageIndexes*(timestamp: uint64): (UInt256, UInt256) =
|
|||||||
|
|
||||||
type
|
type
|
||||||
BlobWrapData* = object
|
BlobWrapData* = object
|
||||||
versionedHash*: common.Hash256
|
versionedHash*: Hash32
|
||||||
blob* : kzg.KzgBlob
|
blob* : kzg.KzgBlob
|
||||||
commitment* : kzg.KZGCommitment
|
commitment* : kzg.KZGCommitment
|
||||||
proof* : kzg.KzgProof
|
proof* : kzg.KzgProof
|
||||||
|
@ -39,7 +39,7 @@ method execute*(step: DevP2PRequestPooledTransactionHash, ctx: CancunTestContext
|
|||||||
engine.connect(sec.node)
|
engine.connect(sec.node)
|
||||||
|
|
||||||
var
|
var
|
||||||
txHashes = newSeq[common.Hash256](step.transactionIndexes.len)
|
txHashes = newSeq[Hash32](step.transactionIndexes.len)
|
||||||
txs = newSeq[PooledTransaction](step.transactionIndexes.len)
|
txs = newSeq[PooledTransaction](step.transactionIndexes.len)
|
||||||
|
|
||||||
for i, txIndex in step.transactionIndexes:
|
for i, txIndex in step.transactionIndexes:
|
||||||
|
@ -527,7 +527,7 @@ let cancunTestListA* = [
|
|||||||
testSequence: @[
|
testSequence: @[
|
||||||
NewPayloads(
|
NewPayloads(
|
||||||
fcUOnPayloadRequest: UpgradeForkchoiceUpdatedVersion(
|
fcUOnPayloadRequest: UpgradeForkchoiceUpdatedVersion(
|
||||||
beaconRoot: Opt.some(default(common.Hash256)),
|
beaconRoot: Opt.some(default(Hash32)),
|
||||||
expectedError: engineApiUnsupportedFork,
|
expectedError: engineApiUnsupportedFork,
|
||||||
),
|
),
|
||||||
expectationDescription: """
|
expectationDescription: """
|
||||||
@ -555,7 +555,7 @@ let cancunTestListA* = [
|
|||||||
testSequence: @[
|
testSequence: @[
|
||||||
NewPayloads(
|
NewPayloads(
|
||||||
fcUOnPayloadRequest: BaseForkchoiceUpdatedCustomizer(
|
fcUOnPayloadRequest: BaseForkchoiceUpdatedCustomizer(
|
||||||
beaconRoot: Opt.some(default(common.Hash256)),
|
beaconRoot: Opt.some(default(Hash32)),
|
||||||
expectedError: engineApiInvalidPayloadAttributes,
|
expectedError: engineApiInvalidPayloadAttributes,
|
||||||
),
|
),
|
||||||
expectationDescription: """
|
expectationDescription: """
|
||||||
@ -583,7 +583,7 @@ let cancunTestListA* = [
|
|||||||
testSequence: @[
|
testSequence: @[
|
||||||
NewPayloads(
|
NewPayloads(
|
||||||
fcUOnPayloadRequest: DowngradeForkchoiceUpdatedVersion(
|
fcUOnPayloadRequest: DowngradeForkchoiceUpdatedVersion(
|
||||||
beaconRoot: Opt.some(default(common.Hash256)),
|
beaconRoot: Opt.some(default(Hash32)),
|
||||||
expectedError: engineApiInvalidPayloadAttributes,
|
expectedError: engineApiInvalidPayloadAttributes,
|
||||||
),
|
),
|
||||||
expectationDescription: """
|
expectationDescription: """
|
||||||
@ -641,7 +641,7 @@ let cancunTestListA* = [
|
|||||||
NewPayloads(
|
NewPayloads(
|
||||||
expectedIncludedBlobCount: MAX_BLOBS_PER_BLOCK,
|
expectedIncludedBlobCount: MAX_BLOBS_PER_BLOCK,
|
||||||
fcUOnPayloadRequest: BaseForkchoiceUpdatedCustomizer(
|
fcUOnPayloadRequest: BaseForkchoiceUpdatedCustomizer(
|
||||||
beaconRoot: Opt.some(default(common.Hash256)),
|
beaconRoot: Opt.some(default(Hash32)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SendBlobTransactions(
|
SendBlobTransactions(
|
||||||
@ -818,7 +818,7 @@ let cancunTestListA* = [
|
|||||||
payloadCustomizer: CustomPayloadData(
|
payloadCustomizer: CustomPayloadData(
|
||||||
excessBlobGas: Opt.some(0'u64),
|
excessBlobGas: Opt.some(0'u64),
|
||||||
blobGasUsed: Opt.some(0'u64),
|
blobGasUsed: Opt.some(0'u64),
|
||||||
parentBeaconRoot: Opt.some(default(common.Hash256)),
|
parentBeaconRoot: Opt.some(default(Hash32)),
|
||||||
versionedHashesCustomizer: VersionedHashesCustomizer(
|
versionedHashesCustomizer: VersionedHashesCustomizer(
|
||||||
blobs: Opt.some(newSeq[BlobID]()),
|
blobs: Opt.some(newSeq[BlobID]()),
|
||||||
),
|
),
|
||||||
@ -1673,7 +1673,7 @@ let cancunTestListA* = [
|
|||||||
NewPayloads(
|
NewPayloads(
|
||||||
newPayloadCustomizer: UpgradeNewPayloadVersion(
|
newPayloadCustomizer: UpgradeNewPayloadVersion(
|
||||||
payloadCustomizer: CustomPayloadData(
|
payloadCustomizer: CustomPayloadData(
|
||||||
parentBeaconRoot: some(default(common.Hash256)),
|
parentBeaconRoot: some(default(Hash32)),
|
||||||
),
|
),
|
||||||
expectedError: engineApiInvalidParams,
|
expectedError: engineApiInvalidParams,
|
||||||
),
|
),
|
||||||
|
@ -23,7 +23,7 @@ import
|
|||||||
./engine_client,
|
./engine_client,
|
||||||
./types
|
./types
|
||||||
|
|
||||||
import web3/engine_api_types except Hash256 # conflict with the one from eth/common
|
import web3/engine_api_types
|
||||||
|
|
||||||
# Consensus Layer Client Mock used to sync the Execution Clients once the TTD has been reached
|
# Consensus Layer Client Mock used to sync the Execution Clients once the TTD has been reached
|
||||||
type
|
type
|
||||||
|
@ -301,7 +301,7 @@ method withMainFork(cs: PayloadBuildAfterInvalidPayloadTest, fork: EngineFork):
|
|||||||
method getName(cs: PayloadBuildAfterInvalidPayloadTest): string =
|
method getName(cs: PayloadBuildAfterInvalidPayloadTest): string =
|
||||||
"Payload Build after New Invalid payload: Invalid " & $cs.invalidField
|
"Payload Build after New Invalid payload: Invalid " & $cs.invalidField
|
||||||
|
|
||||||
proc collectBlobHashes(list: openArray[Web3Tx]): seq[common.Hash256] =
|
proc collectBlobHashes(list: openArray[Web3Tx]): seq[Hash32] =
|
||||||
for w3tx in list:
|
for w3tx in list:
|
||||||
let tx = ethTx(w3tx)
|
let tx = ethTx(w3tx)
|
||||||
for h in tx.versionedHashes:
|
for h in tx.versionedHashes:
|
||||||
@ -332,7 +332,7 @@ method execute(cs: PayloadBuildAfterInvalidPayloadTest, env: TestEnv): bool =
|
|||||||
# Get a payload from the invalid payload producer and invalidate it
|
# Get a payload from the invalid payload producer and invalidate it
|
||||||
let
|
let
|
||||||
customizer = BasePayloadAttributesCustomizer(
|
customizer = BasePayloadAttributesCustomizer(
|
||||||
prevRandao: Opt.some(default(common.Hash256)),
|
prevRandao: Opt.some(default(Hash32)),
|
||||||
suggestedFeerecipient: Opt.some(ZeroAddr),
|
suggestedFeerecipient: Opt.some(ZeroAddr),
|
||||||
)
|
)
|
||||||
payloadAttributes = customizer.getPayloadAttributes(env.clMock.latestPayloadAttributes)
|
payloadAttributes = customizer.getPayloadAttributes(env.clMock.latestPayloadAttributes)
|
||||||
@ -352,7 +352,7 @@ method execute(cs: PayloadBuildAfterInvalidPayloadTest, env: TestEnv): bool =
|
|||||||
let basePayload = s.get.executionPayload
|
let basePayload = s.get.executionPayload
|
||||||
var src = ExecutableData(basePayload: basePayload)
|
var src = ExecutableData(basePayload: basePayload)
|
||||||
if versione == Version.V3:
|
if versione == Version.V3:
|
||||||
src.beaconRoot = Opt.some(default(common.Hash256))
|
src.beaconRoot = Opt.some(default(Hash32))
|
||||||
src.versionedHashes = Opt.some(collectBlobHashes(basePayload.transactions))
|
src.versionedHashes = Opt.some(collectBlobHashes(basePayload.transactions))
|
||||||
|
|
||||||
inv_p = env.generateInvalidPayload(src, InvalidStateRoot)
|
inv_p = env.generateInvalidPayload(src, InvalidStateRoot)
|
||||||
|
@ -78,7 +78,7 @@ method execute(cs: ReExecutePayloadTest, env: TestEnv): bool =
|
|||||||
type
|
type
|
||||||
InOrderPayloadExecutionTest* = ref object of EngineSpec
|
InOrderPayloadExecutionTest* = ref object of EngineSpec
|
||||||
Shadow = ref object
|
Shadow = ref object
|
||||||
recipient: EthAddress
|
recipient: Address
|
||||||
amountPerTx: UInt256
|
amountPerTx: UInt256
|
||||||
txPerPayload: int
|
txPerPayload: int
|
||||||
payloadCount: int
|
payloadCount: int
|
||||||
@ -106,7 +106,7 @@ method execute(cs: InOrderPayloadExecutionTest, env: TestEnv): bool =
|
|||||||
# We will be also verifying that the transactions are correctly interpreted in the canonical chain,
|
# We will be also verifying that the transactions are correctly interpreted in the canonical chain,
|
||||||
# prepare a random account to receive funds.
|
# prepare a random account to receive funds.
|
||||||
var shadow = Shadow(
|
var shadow = Shadow(
|
||||||
recipient: EthAddress.randomBytes(),
|
recipient: Address.randomBytes(),
|
||||||
amountPerTx: 1000.u256,
|
amountPerTx: 1000.u256,
|
||||||
txPerPayload: 20,
|
txPerPayload: 20,
|
||||||
payloadCount: 10,
|
payloadCount: 10,
|
||||||
@ -218,7 +218,7 @@ method execute(cs: MultiplePayloadsExtendingCanonicalChainTest, env: TestEnv): b
|
|||||||
var callbacks = BlockProcessCallbacks(
|
var callbacks = BlockProcessCallbacks(
|
||||||
# We send the transactions after we got the Payload ID, before the CLMocker gets the prepared Payload
|
# We send the transactions after we got the Payload ID, before the CLMocker gets the prepared Payload
|
||||||
onPayloadProducerSelected: proc(): bool =
|
onPayloadProducerSelected: proc(): bool =
|
||||||
let recipient = EthAddress.randomBytes()
|
let recipient = Address.randomBytes()
|
||||||
let tc = BaseTx(
|
let tc = BaseTx(
|
||||||
recipient: Opt.some(recipient),
|
recipient: Opt.some(recipient),
|
||||||
txType: cs.txType,
|
txType: cs.txType,
|
||||||
@ -243,7 +243,7 @@ method execute(cs: MultiplePayloadsExtendingCanonicalChainTest, env: TestEnv): b
|
|||||||
|
|
||||||
# Fabricate and send multiple new payloads by changing the PrevRandao field
|
# Fabricate and send multiple new payloads by changing the PrevRandao field
|
||||||
for i in 0..<payloadCount:
|
for i in 0..<payloadCount:
|
||||||
let newPrevRandao = common.Hash256.randomBytes()
|
let newPrevRandao = Hash32.randomBytes()
|
||||||
let customizer = CustomPayloadData(
|
let customizer = CustomPayloadData(
|
||||||
prevRandao: Opt.some(newPrevRandao),
|
prevRandao: Opt.some(newPrevRandao),
|
||||||
)
|
)
|
||||||
@ -271,7 +271,7 @@ type
|
|||||||
NewPayloadOnSyncingClientTest* = ref object of EngineSpec
|
NewPayloadOnSyncingClientTest* = ref object of EngineSpec
|
||||||
|
|
||||||
Shadow2 = ref object
|
Shadow2 = ref object
|
||||||
recipient: EthAddress
|
recipient: Address
|
||||||
previousPayload: ExecutionPayload
|
previousPayload: ExecutionPayload
|
||||||
|
|
||||||
method withMainFork(cs: NewPayloadOnSyncingClientTest, fork: EngineFork): BaseSpec =
|
method withMainFork(cs: NewPayloadOnSyncingClientTest, fork: EngineFork): BaseSpec =
|
||||||
@ -286,7 +286,7 @@ method getName(cs: NewPayloadOnSyncingClientTest): string =
|
|||||||
method execute(cs: NewPayloadOnSyncingClientTest, env: TestEnv): bool =
|
method execute(cs: NewPayloadOnSyncingClientTest, env: TestEnv): bool =
|
||||||
var shadow = Shadow2(
|
var shadow = Shadow2(
|
||||||
# Set a random transaction recipient
|
# Set a random transaction recipient
|
||||||
recipient: EthAddress.randomBytes(),
|
recipient: Address.randomBytes(),
|
||||||
)
|
)
|
||||||
|
|
||||||
discard env.addEngine()
|
discard env.addEngine()
|
||||||
@ -418,7 +418,7 @@ method execute(cs: NewPayloadWithMissingFcUTest, env: TestEnv): bool =
|
|||||||
# Produce blocks on the main client, these payloads will be replayed on the secondary client.
|
# Produce blocks on the main client, these payloads will be replayed on the secondary client.
|
||||||
let pbRes = env.clMock.produceBlocks(5, BlockProcessCallbacks(
|
let pbRes = env.clMock.produceBlocks(5, BlockProcessCallbacks(
|
||||||
onPayloadProducerSelected: proc(): bool =
|
onPayloadProducerSelected: proc(): bool =
|
||||||
let recipient = common.EthAddress.randomBytes()
|
let recipient = Address.randomBytes()
|
||||||
let tc = BaseTx(
|
let tc = BaseTx(
|
||||||
recipient: Opt.some(recipient),
|
recipient: Opt.some(recipient),
|
||||||
txType: cs.txType,
|
txType: cs.txType,
|
||||||
|
@ -54,7 +54,7 @@ method execute(cs: SidechainReOrgTest, env: TestEnv): bool =
|
|||||||
onNewPayloadBroadcast: proc(): bool =
|
onNewPayloadBroadcast: proc(): bool =
|
||||||
# At this point the CLMocker has a payload that will result in a specific outcome,
|
# At this point the CLMocker has a payload that will result in a specific outcome,
|
||||||
# we can produce an alternative payload, send it, fcU to it, and verify the changes
|
# we can produce an alternative payload, send it, fcU to it, and verify the changes
|
||||||
let alternativePrevRandao = common.Hash256.randomBytes()
|
let alternativePrevRandao = Hash32.randomBytes()
|
||||||
let timestamp = w3Qty(env.clMock.latestPayloadBuilt.timestamp, 1)
|
let timestamp = w3Qty(env.clMock.latestPayloadBuilt.timestamp, 1)
|
||||||
let customizer = BasePayloadAttributesCustomizer(
|
let customizer = BasePayloadAttributesCustomizer(
|
||||||
timestamp: Opt.some(timestamp.uint64),
|
timestamp: Opt.some(timestamp.uint64),
|
||||||
@ -134,7 +134,7 @@ method getName(cs: TransactionReOrgTest): string =
|
|||||||
name.add ", " & $cs.scenario
|
name.add ", " & $cs.scenario
|
||||||
return name
|
return name
|
||||||
|
|
||||||
proc txHash(shadow: ShadowTx): common.Hash256 =
|
proc txHash(shadow: ShadowTx): Hash32 =
|
||||||
if shadow.tx.isNone:
|
if shadow.tx.isNone:
|
||||||
error "SHADOW TX IS NONE"
|
error "SHADOW TX IS NONE"
|
||||||
return
|
return
|
||||||
@ -669,7 +669,7 @@ method execute(cs: ReOrgPrevValidatedPayloadOnSideChainTest, env: TestEnv): bool
|
|||||||
pbRes = env.clMock.produceSingleBlock(BlockProcessCallbacks(
|
pbRes = env.clMock.produceSingleBlock(BlockProcessCallbacks(
|
||||||
onGetpayload: proc(): bool =
|
onGetpayload: proc(): bool =
|
||||||
var
|
var
|
||||||
prevRandao = common.Hash256.randomBytes()
|
prevRandao = Hash32.randomBytes()
|
||||||
suggestedFeeRecipient = ethAddress(0x12, 0x34)
|
suggestedFeeRecipient = ethAddress(0x12, 0x34)
|
||||||
|
|
||||||
let payloadAttributesCustomizer = BasePayloadAttributesCustomizer(
|
let payloadAttributesCustomizer = BasePayloadAttributesCustomizer(
|
||||||
|
@ -26,7 +26,7 @@ type
|
|||||||
# TODO: Syncing bool
|
# TODO: Syncing bool
|
||||||
|
|
||||||
Shadow = ref object
|
Shadow = ref object
|
||||||
txHash: common.Hash256
|
txHash: Hash32
|
||||||
|
|
||||||
method withMainFork(cs: BlockStatus, fork: EngineFork): BaseSpec =
|
method withMainFork(cs: BlockStatus, fork: EngineFork): BaseSpec =
|
||||||
var res = cs.clone()
|
var res = cs.clone()
|
||||||
|
@ -36,8 +36,8 @@ method execute(cs: SuggestedFeeRecipientTest, env: TestEnv): bool =
|
|||||||
|
|
||||||
# Verify that, in a block with transactions, fees are accrued by the suggestedFeeRecipient
|
# Verify that, in a block with transactions, fees are accrued by the suggestedFeeRecipient
|
||||||
let
|
let
|
||||||
feeRecipient = EthAddress.randomBytes()
|
feeRecipient = Address.randomBytes()
|
||||||
txRecipient = EthAddress.randomBytes()
|
txRecipient = Address.randomBytes()
|
||||||
|
|
||||||
# Send multiple transactions
|
# Send multiple transactions
|
||||||
for i in 0..<cs.transactionCount:
|
for i in 0..<cs.transactionCount:
|
||||||
|
@ -16,13 +16,13 @@ import
|
|||||||
./engine_client,
|
./engine_client,
|
||||||
./types
|
./types
|
||||||
|
|
||||||
proc txInPayload*(payload: ExecutionPayload, txHash: common.Hash256): bool =
|
proc txInPayload*(payload: ExecutionPayload, txHash: Hash32): bool =
|
||||||
for txBytes in payload.transactions:
|
for txBytes in payload.transactions:
|
||||||
let currTx = rlp.decode(common.Blob txBytes, Transaction)
|
let currTx = rlp.decode(common.Blob txBytes, Transaction)
|
||||||
if rlpHash(currTx) == txHash:
|
if rlpHash(currTx) == txHash:
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc checkPrevRandaoValue*(client: RpcClient, expectedPrevRandao: common.Hash256, blockNumber: uint64): bool =
|
proc checkPrevRandaoValue*(client: RpcClient, expectedPrevRandao: Hash32, blockNumber: uint64): bool =
|
||||||
let storageKey = blockNumber.u256
|
let storageKey = blockNumber.u256
|
||||||
let r = client.storageAt(prevRandaoContractAddr, storageKey)
|
let r = client.storageAt(prevRandaoContractAddr, storageKey)
|
||||||
let expected = FixedBytes[32](expectedPrevRandao.data)
|
let expected = FixedBytes[32](expectedPrevRandao.data)
|
||||||
|
@ -114,7 +114,7 @@ func blockHeader*(p: ExecutionPayload,
|
|||||||
blobGasUsed : u64(p.blobGasUsed),
|
blobGasUsed : u64(p.blobGasUsed),
|
||||||
excessBlobGas : u64(p.excessBlobGas),
|
excessBlobGas : u64(p.excessBlobGas),
|
||||||
parentBeaconBlockRoot: beaconRoot,
|
parentBeaconBlockRoot: beaconRoot,
|
||||||
requestsRoot : requestsRoot(p),
|
requestsHash : requestsRoot(p),
|
||||||
)
|
)
|
||||||
|
|
||||||
func blockBody*(p: ExecutionPayload):
|
func blockBody*(p: ExecutionPayload):
|
||||||
|
@ -183,8 +183,6 @@ proc init(com : CommonRef,
|
|||||||
com.pruneHistory= pruneHistory
|
com.pruneHistory= pruneHistory
|
||||||
com.pos = CasperRef.new
|
com.pos = CasperRef.new
|
||||||
|
|
||||||
const TimeZero = EthTime(0)
|
|
||||||
|
|
||||||
# com.forkIdCalculator and com.genesisHash are set
|
# com.forkIdCalculator and com.genesisHash are set
|
||||||
# by setForkId
|
# by setForkId
|
||||||
if genesis.isNil.not:
|
if genesis.isNil.not:
|
||||||
|
@ -27,8 +27,8 @@ const
|
|||||||
# address zero by accident, unrecoverably, due to poor user interface issues.
|
# address zero by accident, unrecoverably, due to poor user interface issues.
|
||||||
ZERO_ADDRESS* = default(Address)
|
ZERO_ADDRESS* = default(Address)
|
||||||
|
|
||||||
# ZERO_HASH256 is the parent hash of genesis blocks.
|
# ZERO_HASH32 is the parent hash of genesis blocks.
|
||||||
ZERO_HASH256* = default(Hash32)
|
ZERO_HASH32* = default(Hash32)
|
||||||
|
|
||||||
GAS_LIMIT_ADJUSTMENT_FACTOR* = 1_024
|
GAS_LIMIT_ADJUSTMENT_FACTOR* = 1_024
|
||||||
|
|
||||||
@ -42,10 +42,10 @@ const
|
|||||||
GENESIS_BLOCK_NUMBER* = 0.BlockNumber
|
GENESIS_BLOCK_NUMBER* = 0.BlockNumber
|
||||||
GENESIS_DIFFICULTY* = 131_072.u256
|
GENESIS_DIFFICULTY* = 131_072.u256
|
||||||
GENESIS_GAS_LIMIT* = 3_141_592
|
GENESIS_GAS_LIMIT* = 3_141_592
|
||||||
GENESIS_PARENT_HASH* = ZERO_HASH256
|
GENESIS_PARENT_HASH* = ZERO_HASH32
|
||||||
GENESIS_COINBASE* = ZERO_ADDRESS
|
GENESIS_COINBASE* = ZERO_ADDRESS
|
||||||
GENESIS_NONCE* = "\x00\x00\x00\x00\x00\x00\x00B"
|
GENESIS_NONCE* = "\x00\x00\x00\x00\x00\x00\x00B"
|
||||||
GENESIS_MIX_HASH* = ZERO_HASH256
|
GENESIS_MIX_HASH* = ZERO_HASH32
|
||||||
GENESIS_EXTRA_DATA* = ""
|
GENESIS_EXTRA_DATA* = ""
|
||||||
GAS_LIMIT_MINIMUM* = 5000
|
GAS_LIMIT_MINIMUM* = 5000
|
||||||
GAS_LIMIT_MAXIMUM* = int64.high.GasInt # Maximum the gas limit (2^63-1).
|
GAS_LIMIT_MAXIMUM* = int64.high.GasInt # Maximum the gas limit (2^63-1).
|
||||||
|
@ -75,12 +75,12 @@ proc procBlkPreamble(
|
|||||||
return err("Mismatched txRoot")
|
return err("Mismatched txRoot")
|
||||||
|
|
||||||
if com.isPragueOrLater(header.timestamp):
|
if com.isPragueOrLater(header.timestamp):
|
||||||
if header.requestsRoot.isNone or blk.requests.isNone:
|
if header.requestsHash.isNone or blk.requests.isNone:
|
||||||
return err("Post-Prague block header must have requestsRoot/requests")
|
return err("Post-Prague block header must have requestsRoot/requests")
|
||||||
|
|
||||||
?vmState.processParentBlockHash(header.parentHash)
|
?vmState.processParentBlockHash(header.parentHash)
|
||||||
else:
|
else:
|
||||||
if header.requestsRoot.isSome or blk.requests.isSome:
|
if header.requestsHash.isSome or blk.requests.isSome:
|
||||||
return err("Pre-Prague block header must not have requestsRoot/requests")
|
return err("Pre-Prague block header must not have requestsRoot/requests")
|
||||||
|
|
||||||
if com.isCancunOrLater(header.timestamp):
|
if com.isCancunOrLater(header.timestamp):
|
||||||
@ -96,7 +96,7 @@ proc procBlkPreamble(
|
|||||||
if blk.transactions.len == 0:
|
if blk.transactions.len == 0:
|
||||||
return err("Transactions missing from body")
|
return err("Transactions missing from body")
|
||||||
|
|
||||||
let collectLogs = header.requestsRoot.isSome and not skipValidation
|
let collectLogs = header.requestsHash.isSome and not skipValidation
|
||||||
?processTransactions(vmState, header, blk.transactions, skipReceipts, collectLogs)
|
?processTransactions(vmState, header, blk.transactions, skipReceipts, collectLogs)
|
||||||
elif blk.transactions.len > 0:
|
elif blk.transactions.len > 0:
|
||||||
return err("Transactions in block with empty txRoot")
|
return err("Transactions in block with empty txRoot")
|
||||||
@ -178,13 +178,13 @@ proc procBlkEpilogue(
|
|||||||
expected = header.receiptsRoot
|
expected = header.receiptsRoot
|
||||||
return err("receiptRoot mismatch")
|
return err("receiptRoot mismatch")
|
||||||
|
|
||||||
if header.requestsRoot.isSome:
|
if header.requestsHash.isSome:
|
||||||
let requestsRoot = calcRequestsRoot(blk.requests.get)
|
let requestsRoot = calcRequestsRoot(blk.requests.get)
|
||||||
if header.requestsRoot.get != requestsRoot:
|
if header.requestsHash.get != requestsRoot:
|
||||||
debug "wrong requestsRoot in block",
|
debug "wrong requestsRoot in block",
|
||||||
blockNumber = header.number,
|
blockNumber = header.number,
|
||||||
actual = requestsRoot,
|
actual = requestsRoot,
|
||||||
expected = header.requestsRoot.get
|
expected = header.requestsHash.get
|
||||||
return err("requestsRoot mismatch")
|
return err("requestsRoot mismatch")
|
||||||
let depositReqs = ?parseDepositLogs(vmState.allLogs)
|
let depositReqs = ?parseDepositLogs(vmState.allLogs)
|
||||||
var expectedDeposits: seq[Request]
|
var expectedDeposits: seq[Request]
|
||||||
|
@ -107,7 +107,7 @@ func baseFee(pst: TxPacker): GasInt =
|
|||||||
else:
|
else:
|
||||||
0.GasInt
|
0.GasInt
|
||||||
|
|
||||||
func feeRecipient(pst: TxPacker): EthAddress =
|
func feeRecipient(pst: TxPacker): Address =
|
||||||
pst.vmState.com.pos.feeRecipient
|
pst.vmState.com.pos.feeRecipient
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -23,17 +23,17 @@ import
|
|||||||
|
|
||||||
type
|
type
|
||||||
TxRank* = ##\
|
TxRank* = ##\
|
||||||
## Order relation, determins how the `EthAddresses` are ranked
|
## Order relation, determins how the `Addresses` are ranked
|
||||||
distinct int64
|
distinct int64
|
||||||
|
|
||||||
TxRankAddrRef* = ##\
|
TxRankAddrRef* = ##\
|
||||||
## Set of adresses having the same rank.
|
## Set of adresses having the same rank.
|
||||||
TableRef[EthAddress,TxRank]
|
TableRef[Address,TxRank]
|
||||||
|
|
||||||
TxRankTab* = object ##\
|
TxRankTab* = object ##\
|
||||||
## Descriptor for `TxRank` <-> `EthAddress` mapping.
|
## Descriptor for `TxRank` <-> `Address` mapping.
|
||||||
rankList: SortedSet[TxRank,TxRankAddrRef]
|
rankList: SortedSet[TxRank,TxRankAddrRef]
|
||||||
addrTab: Table[EthAddress,TxRank]
|
addrTab: Table[Address,TxRank]
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Private helpers
|
# Private helpers
|
||||||
@ -61,7 +61,7 @@ proc clear*(rt: var TxRankTab) =
|
|||||||
# Public functions, base management operations
|
# Public functions, base management operations
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc insert*(rt: var TxRankTab; rank: TxRank; sender: EthAddress): bool
|
proc insert*(rt: var TxRankTab; rank: TxRank; sender: Address): bool
|
||||||
{.gcsafe,raises: [KeyError].} =
|
{.gcsafe,raises: [KeyError].} =
|
||||||
## Add or update a new ranked address. This function returns `true` it the
|
## Add or update a new ranked address. This function returns `true` it the
|
||||||
## address exists already with the current rank.
|
## address exists already with the current rank.
|
||||||
@ -83,7 +83,7 @@ proc insert*(rt: var TxRankTab; rank: TxRank; sender: EthAddress): bool
|
|||||||
var newRankSet: TxRankAddrRef
|
var newRankSet: TxRankAddrRef
|
||||||
let rc = rt.rankList.insert(rank)
|
let rc = rt.rankList.insert(rank)
|
||||||
if rc.isOk:
|
if rc.isOk:
|
||||||
newRankSet = newTable[EthAddress,TxRank](1)
|
newRankSet = newTable[Address,TxRank](1)
|
||||||
rc.value.data = newRankSet
|
rc.value.data = newRankSet
|
||||||
else:
|
else:
|
||||||
newRankSet = rt.rankList.eq(rank).value.data
|
newRankSet = rt.rankList.eq(rank).value.data
|
||||||
@ -93,7 +93,7 @@ proc insert*(rt: var TxRankTab; rank: TxRank; sender: EthAddress): bool
|
|||||||
true
|
true
|
||||||
|
|
||||||
|
|
||||||
proc delete*(rt: var TxRankTab; sender: EthAddress): bool
|
proc delete*(rt: var TxRankTab; sender: Address): bool
|
||||||
{.gcsafe,raises: [KeyError].} =
|
{.gcsafe,raises: [KeyError].} =
|
||||||
## Delete argument address `sender` from rank table.
|
## Delete argument address `sender` from rank table.
|
||||||
if rt.addrTab.hasKey(sender):
|
if rt.addrTab.hasKey(sender):
|
||||||
@ -111,7 +111,7 @@ proc delete*(rt: var TxRankTab; sender: EthAddress): bool
|
|||||||
return true
|
return true
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Public functions: `TxRank` > `EthAddress`
|
# Public functions: `TxRank` > `Address`
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc len*(rt: var TxRankTab): int =
|
proc len*(rt: var TxRankTab): int =
|
||||||
@ -139,15 +139,15 @@ proc lt*(rt: var TxRankTab; rank: TxRank):
|
|||||||
rt.rankList.lt(rank)
|
rt.rankList.lt(rank)
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Public functions: `EthAddress` > `TxRank`
|
# Public functions: `Address` > `TxRank`
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc nItems*(rt: var TxRankTab): int =
|
proc nItems*(rt: var TxRankTab): int =
|
||||||
## Total number of address items registered
|
## Total number of address items registered
|
||||||
rt.addrTab.len
|
rt.addrTab.len
|
||||||
|
|
||||||
proc eq*(rt: var TxRankTab; sender: EthAddress):
|
proc eq*(rt: var TxRankTab; sender: Address):
|
||||||
SortedSetResult[EthAddress,TxRank]
|
SortedSetResult[Address,TxRank]
|
||||||
{.gcsafe,raises: [KeyError].} =
|
{.gcsafe,raises: [KeyError].} =
|
||||||
if rt.addrTab.hasKey(sender):
|
if rt.addrTab.hasKey(sender):
|
||||||
return toSortedSetResult(key = sender, data = rt.addrTab[sender])
|
return toSortedSetResult(key = sender, data = rt.addrTab[sender])
|
||||||
|
@ -29,7 +29,7 @@ type
|
|||||||
## Per address table. This table is provided as a keyed queue so deletion\
|
## Per address table. This table is provided as a keyed queue so deletion\
|
||||||
## while traversing is supported and predictable.
|
## while traversing is supported and predictable.
|
||||||
size: int ## Total number of items
|
size: int ## Total number of items
|
||||||
addrList: KeyedQueue[EthAddress,TxStatusNonceRef]
|
addrList: KeyedQueue[Address,TxStatusNonceRef]
|
||||||
|
|
||||||
TxStatusTab* = object ##\
|
TxStatusTab* = object ##\
|
||||||
## Per status table
|
## Per status table
|
||||||
@ -159,7 +159,7 @@ proc eq*(sq: var TxStatusTab; status: TxItemStatus):
|
|||||||
toSortedSetResult(key = status, data = addrData)
|
toSortedSetResult(key = status, data = addrData)
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Public array ops -- `EthAddress` (level 1)
|
# Public array ops -- `Address` (level 1)
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc nItems*(addrData: TxStatusSenderRef): int =
|
proc nItems*(addrData: TxStatusSenderRef): int =
|
||||||
@ -171,15 +171,15 @@ proc nItems*(rc: SortedSetResult[TxItemStatus,TxStatusSenderRef]): int =
|
|||||||
return rc.value.data.nItems
|
return rc.value.data.nItems
|
||||||
0
|
0
|
||||||
|
|
||||||
proc eq*(addrData: TxStatusSenderRef; sender: EthAddress):
|
proc eq*(addrData: TxStatusSenderRef; sender: Address):
|
||||||
SortedSetResult[EthAddress,TxStatusNonceRef]
|
SortedSetResult[Address,TxStatusNonceRef]
|
||||||
{.gcsafe,raises: [KeyError].} =
|
{.gcsafe,raises: [KeyError].} =
|
||||||
if addrData.addrList.hasKey(sender):
|
if addrData.addrList.hasKey(sender):
|
||||||
return toSortedSetResult(key = sender, data = addrData.addrList[sender])
|
return toSortedSetResult(key = sender, data = addrData.addrList[sender])
|
||||||
err(rbNotFound)
|
err(rbNotFound)
|
||||||
|
|
||||||
proc eq*(rc: SortedSetResult[TxItemStatus,TxStatusSenderRef];
|
proc eq*(rc: SortedSetResult[TxItemStatus,TxStatusSenderRef];
|
||||||
sender: EthAddress): SortedSetResult[EthAddress,TxStatusNonceRef]
|
sender: Address): SortedSetResult[Address,TxStatusNonceRef]
|
||||||
{.gcsafe,raises: [KeyError].} =
|
{.gcsafe,raises: [KeyError].} =
|
||||||
if rc.isOk:
|
if rc.isOk:
|
||||||
return rc.value.data.eq(sender)
|
return rc.value.data.eq(sender)
|
||||||
@ -197,7 +197,7 @@ proc nItems*(nonceData: TxStatusNonceRef): int =
|
|||||||
## Getter, total number of items in the sub-list
|
## Getter, total number of items in the sub-list
|
||||||
nonceData.nonceList.len
|
nonceData.nonceList.len
|
||||||
|
|
||||||
proc nItems*(rc: SortedSetResult[EthAddress,TxStatusNonceRef]): int =
|
proc nItems*(rc: SortedSetResult[Address,TxStatusNonceRef]): int =
|
||||||
if rc.isOk:
|
if rc.isOk:
|
||||||
return rc.value.data.nItems
|
return rc.value.data.nItems
|
||||||
0
|
0
|
||||||
@ -207,7 +207,7 @@ proc eq*(nonceData: TxStatusNonceRef; nonce: AccountNonce):
|
|||||||
SortedSetResult[AccountNonce,TxItemRef] =
|
SortedSetResult[AccountNonce,TxItemRef] =
|
||||||
nonceData.nonceList.eq(nonce)
|
nonceData.nonceList.eq(nonce)
|
||||||
|
|
||||||
proc eq*(rc: SortedSetResult[EthAddress,TxStatusNonceRef]; nonce: AccountNonce):
|
proc eq*(rc: SortedSetResult[Address,TxStatusNonceRef]; nonce: AccountNonce):
|
||||||
SortedSetResult[AccountNonce,TxItemRef] =
|
SortedSetResult[AccountNonce,TxItemRef] =
|
||||||
if rc.isOk:
|
if rc.isOk:
|
||||||
return rc.value.data.eq(nonce)
|
return rc.value.data.eq(nonce)
|
||||||
@ -218,7 +218,7 @@ proc ge*(nonceData: TxStatusNonceRef; nonce: AccountNonce):
|
|||||||
SortedSetResult[AccountNonce,TxItemRef] =
|
SortedSetResult[AccountNonce,TxItemRef] =
|
||||||
nonceData.nonceList.ge(nonce)
|
nonceData.nonceList.ge(nonce)
|
||||||
|
|
||||||
proc ge*(rc: SortedSetResult[EthAddress,TxStatusNonceRef]; nonce: AccountNonce):
|
proc ge*(rc: SortedSetResult[Address,TxStatusNonceRef]; nonce: AccountNonce):
|
||||||
SortedSetResult[AccountNonce,TxItemRef] =
|
SortedSetResult[AccountNonce,TxItemRef] =
|
||||||
if rc.isOk:
|
if rc.isOk:
|
||||||
return rc.value.data.ge(nonce)
|
return rc.value.data.ge(nonce)
|
||||||
@ -229,7 +229,7 @@ proc gt*(nonceData: TxStatusNonceRef; nonce: AccountNonce):
|
|||||||
SortedSetResult[AccountNonce,TxItemRef] =
|
SortedSetResult[AccountNonce,TxItemRef] =
|
||||||
nonceData.nonceList.gt(nonce)
|
nonceData.nonceList.gt(nonce)
|
||||||
|
|
||||||
proc gt*(rc: SortedSetResult[EthAddress,TxStatusNonceRef]; nonce: AccountNonce):
|
proc gt*(rc: SortedSetResult[Address,TxStatusNonceRef]; nonce: AccountNonce):
|
||||||
SortedSetResult[AccountNonce,TxItemRef] =
|
SortedSetResult[AccountNonce,TxItemRef] =
|
||||||
if rc.isOk:
|
if rc.isOk:
|
||||||
return rc.value.data.gt(nonce)
|
return rc.value.data.gt(nonce)
|
||||||
|
@ -248,7 +248,7 @@ proc validateTxBasic*(
|
|||||||
proc validateTransaction*(
|
proc validateTransaction*(
|
||||||
roDB: ReadOnlyStateDB; ## Parent accounts environment for transaction
|
roDB: ReadOnlyStateDB; ## Parent accounts environment for transaction
|
||||||
tx: Transaction; ## tx to validate
|
tx: Transaction; ## tx to validate
|
||||||
sender: EthAddress; ## tx.recoverSender
|
sender: Address; ## tx.recoverSender
|
||||||
maxLimit: GasInt; ## gasLimit from block header
|
maxLimit: GasInt; ## gasLimit from block header
|
||||||
baseFee: UInt256; ## baseFee from block header
|
baseFee: UInt256; ## baseFee from block header
|
||||||
excessBlobGas: uint64; ## excessBlobGas from parent block header
|
excessBlobGas: uint64; ## excessBlobGas from parent block header
|
||||||
|
@ -18,7 +18,7 @@ type
|
|||||||
SlotSet = HashSet[UInt256]
|
SlotSet = HashSet[UInt256]
|
||||||
|
|
||||||
AccessList* = object
|
AccessList* = object
|
||||||
slots: Table[EthAddress, SlotSet]
|
slots: Table[Address, SlotSet]
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Private helpers
|
# Private helpers
|
||||||
@ -33,7 +33,7 @@ func toStorageKeys(slots: SlotSet): seq[Bytes32] =
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc init*(ac: var AccessList) =
|
proc init*(ac: var AccessList) =
|
||||||
ac.slots = Table[EthAddress, SlotSet]()
|
ac.slots = Table[Address, SlotSet]()
|
||||||
|
|
||||||
proc init*(_: type AccessList): AccessList {.inline.} =
|
proc init*(_: type AccessList): AccessList {.inline.} =
|
||||||
result.init()
|
result.init()
|
||||||
@ -42,11 +42,11 @@ proc init*(_: type AccessList): AccessList {.inline.} =
|
|||||||
# Public functions
|
# Public functions
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
func contains*(ac: AccessList, address: EthAddress): bool {.inline.} =
|
func contains*(ac: AccessList, address: Address): bool {.inline.} =
|
||||||
address in ac.slots
|
address in ac.slots
|
||||||
|
|
||||||
# returnValue: (addressPresent, slotPresent)
|
# returnValue: (addressPresent, slotPresent)
|
||||||
func contains*(ac: var AccessList, address: EthAddress, slot: UInt256): bool =
|
func contains*(ac: var AccessList, address: Address, slot: UInt256): bool =
|
||||||
ac.slots.withValue(address, val):
|
ac.slots.withValue(address, val):
|
||||||
result = slot in val[]
|
result = slot in val[]
|
||||||
|
|
||||||
@ -54,11 +54,11 @@ proc mergeAndReset*(ac, other: var AccessList) =
|
|||||||
# move values in `other` to `ac`
|
# move values in `other` to `ac`
|
||||||
ac.slots.mergeAndReset(other.slots)
|
ac.slots.mergeAndReset(other.slots)
|
||||||
|
|
||||||
proc add*(ac: var AccessList, address: EthAddress) =
|
proc add*(ac: var AccessList, address: Address) =
|
||||||
if address notin ac.slots:
|
if address notin ac.slots:
|
||||||
ac.slots[address] = HashSet[UInt256]()
|
ac.slots[address] = HashSet[UInt256]()
|
||||||
|
|
||||||
proc add*(ac: var AccessList, address: EthAddress, slot: UInt256) =
|
proc add*(ac: var AccessList, address: Address, slot: UInt256) =
|
||||||
ac.slots.withValue(address, val):
|
ac.slots.withValue(address, val):
|
||||||
val[].incl slot
|
val[].incl slot
|
||||||
do:
|
do:
|
||||||
|
@ -87,7 +87,7 @@ type
|
|||||||
func oaToStr(w: openArray[byte]): string =
|
func oaToStr(w: openArray[byte]): string =
|
||||||
w.toHex.toLowerAscii
|
w.toHex.toLowerAscii
|
||||||
|
|
||||||
func toStr(w: EthAddress): string =
|
func toStr(w: Address): string =
|
||||||
w.toHex
|
w.toHex
|
||||||
|
|
||||||
func toStr(w: Hash32): string =
|
func toStr(w: Hash32): string =
|
||||||
@ -115,7 +115,7 @@ func `$`*(w: CodeBytesRef): string {.used.} = w.toStr
|
|||||||
func `$`*(e: Elapsed): string = e.Duration.toStr
|
func `$`*(e: Elapsed): string = e.Duration.toStr
|
||||||
func `$`*(l: seq[Log]): string = l.toStr
|
func `$`*(l: seq[Log]): string = l.toStr
|
||||||
func `$`*(b: seq[byte]): string = b.toStr
|
func `$`*(b: seq[byte]): string = b.toStr
|
||||||
func `$$`*(a: EthAddress): string = a.toStr # otherwise collision w/existing `$`
|
func `$$`*(a: Address): string = a.toStr # otherwise collision w/existing `$`
|
||||||
func `$$`*(h: Hash32): string = h.toStr # otherwise collision w/existing `$`
|
func `$$`*(h: Hash32): string = h.toStr # otherwise collision w/existing `$`
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -36,21 +36,21 @@ iterator accounts*(ldg: LedgerRef): Account =
|
|||||||
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
||||||
|
|
||||||
|
|
||||||
iterator addresses*(ldg: LedgerRef): EthAddress =
|
iterator addresses*(ldg: LedgerRef): Address =
|
||||||
ldg.beginTrackApi LdgAdressesIt
|
ldg.beginTrackApi LdgAdressesIt
|
||||||
for w in ldg.ac.addresses():
|
for w in ldg.ac.addresses():
|
||||||
yield w
|
yield w
|
||||||
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
ldg.ifTrackApi: debug apiTxt, api, elapsed
|
||||||
|
|
||||||
|
|
||||||
iterator cachedStorage*(ldg: LedgerRef, eAddr: EthAddress): (UInt256,UInt256) =
|
iterator cachedStorage*(ldg: LedgerRef, eAddr: Address): (UInt256,UInt256) =
|
||||||
ldg.beginTrackApi LdgCachedStorageIt
|
ldg.beginTrackApi LdgCachedStorageIt
|
||||||
for w in ldg.ac.cachedStorage(eAddr):
|
for w in ldg.ac.cachedStorage(eAddr):
|
||||||
yield w
|
yield w
|
||||||
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr)
|
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr)
|
||||||
|
|
||||||
|
|
||||||
iterator pairs*(ldg: LedgerRef): (EthAddress,Account) =
|
iterator pairs*(ldg: LedgerRef): (Address,Account) =
|
||||||
ldg.beginTrackApi LdgPairsIt
|
ldg.beginTrackApi LdgPairsIt
|
||||||
for w in ldg.ac.pairs():
|
for w in ldg.ac.pairs():
|
||||||
yield w
|
yield w
|
||||||
@ -59,7 +59,7 @@ iterator pairs*(ldg: LedgerRef): (EthAddress,Account) =
|
|||||||
|
|
||||||
iterator storage*(
|
iterator storage*(
|
||||||
ldg: LedgerRef;
|
ldg: LedgerRef;
|
||||||
eAddr: EthAddress;
|
eAddr: Address;
|
||||||
): (UInt256,UInt256) =
|
): (UInt256,UInt256) =
|
||||||
ldg.beginTrackApi LdgStorageIt
|
ldg.beginTrackApi LdgStorageIt
|
||||||
for w in ldg.ac.storage(eAddr):
|
for w in ldg.ac.storage(eAddr):
|
||||||
|
@ -19,7 +19,7 @@ type
|
|||||||
map: Table[UInt256, UInt256]
|
map: Table[UInt256, UInt256]
|
||||||
|
|
||||||
TransientStorage* = object
|
TransientStorage* = object
|
||||||
map: Table[EthAddress, StorageTable]
|
map: Table[Address, StorageTable]
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Private helpers
|
# Private helpers
|
||||||
@ -33,13 +33,13 @@ proc mergeAndReset*(a, b: StorageTable) =
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
proc init*(ac: var TransientStorage) =
|
proc init*(ac: var TransientStorage) =
|
||||||
ac.map = Table[EthAddress, StorageTable]()
|
ac.map = Table[Address, StorageTable]()
|
||||||
|
|
||||||
proc init*(_: type TransientStorage): TransientStorage {.inline.} =
|
proc init*(_: type TransientStorage): TransientStorage {.inline.} =
|
||||||
result.init()
|
result.init()
|
||||||
|
|
||||||
func getStorage*(ac: TransientStorage,
|
func getStorage*(ac: TransientStorage,
|
||||||
address: EthAddress, slot: UInt256): (bool, UInt256) =
|
address: Address, slot: UInt256): (bool, UInt256) =
|
||||||
var table = ac.map.getOrDefault(address)
|
var table = ac.map.getOrDefault(address)
|
||||||
if table.isNil:
|
if table.isNil:
|
||||||
return (false, 0.u256)
|
return (false, 0.u256)
|
||||||
@ -50,7 +50,7 @@ func getStorage*(ac: TransientStorage,
|
|||||||
return (false, 0.u256)
|
return (false, 0.u256)
|
||||||
|
|
||||||
proc setStorage*(ac: var TransientStorage,
|
proc setStorage*(ac: var TransientStorage,
|
||||||
address: EthAddress, slot, value: UInt256) =
|
address: Address, slot, value: UInt256) =
|
||||||
var table = ac.map.getOrDefault(address)
|
var table = ac.map.getOrDefault(address)
|
||||||
if table.isNil:
|
if table.isNil:
|
||||||
table = StorageTable()
|
table = StorageTable()
|
||||||
|
@ -20,8 +20,8 @@ type
|
|||||||
# and we can reduce unecessary conversion further
|
# and we can reduce unecessary conversion further
|
||||||
nimbus_tx_context* = object
|
nimbus_tx_context* = object
|
||||||
tx_gas_price* : evmc_uint256be # The transaction gas price.
|
tx_gas_price* : evmc_uint256be # The transaction gas price.
|
||||||
tx_origin* : EthAddress # The transaction origin account.
|
tx_origin* : Address # The transaction origin account.
|
||||||
block_coinbase* : EthAddress # The miner of the block.
|
block_coinbase* : Address # The miner of the block.
|
||||||
block_number* : int64 # The block number.
|
block_number* : int64 # The block number.
|
||||||
block_timestamp* : int64 # The block timestamp.
|
block_timestamp* : int64 # The block timestamp.
|
||||||
block_gas_limit* : int64 # The block gas limit.
|
block_gas_limit* : int64 # The block gas limit.
|
||||||
@ -39,13 +39,13 @@ type
|
|||||||
flags* : evmc_flags
|
flags* : evmc_flags
|
||||||
depth* : int32
|
depth* : int32
|
||||||
gas* : int64
|
gas* : int64
|
||||||
recipient* : EthAddress
|
recipient* : Address
|
||||||
sender* : EthAddress
|
sender* : Address
|
||||||
input_data* : ptr byte
|
input_data* : ptr byte
|
||||||
input_size* : uint
|
input_size* : uint
|
||||||
value* : evmc_uint256be
|
value* : evmc_uint256be
|
||||||
create2_salt*: evmc_bytes32
|
create2_salt*: evmc_bytes32
|
||||||
code_address*: EthAddress
|
code_address*: Address
|
||||||
code* : ptr byte
|
code* : ptr byte
|
||||||
code_size* : csize_t
|
code_size* : csize_t
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ type
|
|||||||
output_size* : uint
|
output_size* : uint
|
||||||
release* : proc(result: var nimbus_result)
|
release* : proc(result: var nimbus_result)
|
||||||
{.cdecl, gcsafe, raises: [].}
|
{.cdecl, gcsafe, raises: [].}
|
||||||
create_address*: EthAddress
|
create_address*: Address
|
||||||
padding* : array[4, byte]
|
padding* : array[4, byte]
|
||||||
|
|
||||||
nimbus_host_interface* = object
|
nimbus_host_interface* = object
|
||||||
@ -107,20 +107,20 @@ proc init*(x: typedesc[HostContext], host: ptr nimbus_host_interface, context: e
|
|||||||
proc getTxContext*(ctx: HostContext): nimbus_tx_context =
|
proc getTxContext*(ctx: HostContext): nimbus_tx_context =
|
||||||
ctx.host.get_tx_context(ctx.context)
|
ctx.host.get_tx_context(ctx.context)
|
||||||
|
|
||||||
proc getBlockHash*(ctx: HostContext, number: BlockNumber): Hash256 =
|
proc getBlockHash*(ctx: HostContext, number: BlockNumber): Hash32 =
|
||||||
Hash256.fromEvmc ctx.host.get_block_hash(ctx.context, number.int64)
|
Hash32.fromEvmc ctx.host.get_block_hash(ctx.context, number.int64)
|
||||||
|
|
||||||
proc accountExists*(ctx: HostContext, address: EthAddress): bool =
|
proc accountExists*(ctx: HostContext, address: Address): bool =
|
||||||
var address = toEvmc(address)
|
var address = toEvmc(address)
|
||||||
ctx.host.account_exists(ctx.context, address.addr)
|
ctx.host.account_exists(ctx.context, address.addr)
|
||||||
|
|
||||||
proc getStorage*(ctx: HostContext, address: EthAddress, key: UInt256): UInt256 =
|
proc getStorage*(ctx: HostContext, address: Address, key: UInt256): UInt256 =
|
||||||
var
|
var
|
||||||
address = toEvmc(address)
|
address = toEvmc(address)
|
||||||
key = toEvmc(key)
|
key = toEvmc(key)
|
||||||
UInt256.fromEvmc ctx.host.get_storage(ctx.context, address.addr, key.addr)
|
UInt256.fromEvmc ctx.host.get_storage(ctx.context, address.addr, key.addr)
|
||||||
|
|
||||||
proc setStorage*(ctx: HostContext, address: EthAddress,
|
proc setStorage*(ctx: HostContext, address: Address,
|
||||||
key, value: UInt256): evmc_storage_status =
|
key, value: UInt256): evmc_storage_status =
|
||||||
var
|
var
|
||||||
address = toEvmc(address)
|
address = toEvmc(address)
|
||||||
@ -128,19 +128,19 @@ proc setStorage*(ctx: HostContext, address: EthAddress,
|
|||||||
value = toEvmc(value)
|
value = toEvmc(value)
|
||||||
ctx.host.set_storage(ctx.context, address.addr, key.addr, value.addr)
|
ctx.host.set_storage(ctx.context, address.addr, key.addr, value.addr)
|
||||||
|
|
||||||
proc getBalance*(ctx: HostContext, address: EthAddress): UInt256 =
|
proc getBalance*(ctx: HostContext, address: Address): UInt256 =
|
||||||
var address = toEvmc(address)
|
var address = toEvmc(address)
|
||||||
UInt256.fromEvmc ctx.host.get_balance(ctx.context, address.addr)
|
UInt256.fromEvmc ctx.host.get_balance(ctx.context, address.addr)
|
||||||
|
|
||||||
proc getCodeSize*(ctx: HostContext, address: EthAddress): uint =
|
proc getCodeSize*(ctx: HostContext, address: Address): uint =
|
||||||
var address = toEvmc(address)
|
var address = toEvmc(address)
|
||||||
ctx.host.get_code_size(ctx.context, address.addr)
|
ctx.host.get_code_size(ctx.context, address.addr)
|
||||||
|
|
||||||
proc getCodeHash*(ctx: HostContext, address: EthAddress): Hash256 =
|
proc getCodeHash*(ctx: HostContext, address: Address): Hash32 =
|
||||||
var address = toEvmc(address)
|
var address = toEvmc(address)
|
||||||
Hash256.fromEvmc ctx.host.get_code_hash(ctx.context, address.addr)
|
Hash32.fromEvmc ctx.host.get_code_hash(ctx.context, address.addr)
|
||||||
|
|
||||||
proc copyCode*(ctx: HostContext, address: EthAddress, codeOffset: int = 0): seq[byte] =
|
proc copyCode*(ctx: HostContext, address: Address, codeOffset: int = 0): seq[byte] =
|
||||||
let size = ctx.getCodeSize(address).int
|
let size = ctx.getCodeSize(address).int
|
||||||
if size - codeOffset > 0:
|
if size - codeOffset > 0:
|
||||||
result = newSeq[byte](size - codeOffset)
|
result = newSeq[byte](size - codeOffset)
|
||||||
@ -149,13 +149,13 @@ proc copyCode*(ctx: HostContext, address: EthAddress, codeOffset: int = 0): seq[
|
|||||||
codeOffset, result[0].addr, result.len)
|
codeOffset, result[0].addr, result.len)
|
||||||
doAssert(read == result.len)
|
doAssert(read == result.len)
|
||||||
|
|
||||||
proc selfDestruct*(ctx: HostContext, address, beneficiary: EthAddress) =
|
proc selfDestruct*(ctx: HostContext, address, beneficiary: Address) =
|
||||||
var
|
var
|
||||||
address = toEvmc(address)
|
address = toEvmc(address)
|
||||||
beneficiary = toEvmc(beneficiary)
|
beneficiary = toEvmc(beneficiary)
|
||||||
ctx.host.selfdestruct(ctx.context, address.addr, beneficiary.addr)
|
ctx.host.selfdestruct(ctx.context, address.addr, beneficiary.addr)
|
||||||
|
|
||||||
proc emitLog*(ctx: HostContext, address: EthAddress, data: openArray[byte],
|
proc emitLog*(ctx: HostContext, address: Address, data: openArray[byte],
|
||||||
topics: ptr evmc_bytes32, topicsCount: int) =
|
topics: ptr evmc_bytes32, topicsCount: int) =
|
||||||
var address = toEvmc(address)
|
var address = toEvmc(address)
|
||||||
ctx.host.emit_log(ctx.context, address.addr, if data.len > 0: data[0].unsafeAddr else: nil,
|
ctx.host.emit_log(ctx.context, address.addr, if data.len > 0: data[0].unsafeAddr else: nil,
|
||||||
@ -165,24 +165,24 @@ proc call*(ctx: HostContext, msg: nimbus_message): nimbus_result =
|
|||||||
ctx.host.call(ctx.context, msg.unsafeAddr)
|
ctx.host.call(ctx.context, msg.unsafeAddr)
|
||||||
|
|
||||||
proc accessAccount*(ctx: HostContext,
|
proc accessAccount*(ctx: HostContext,
|
||||||
address: EthAddress): evmc_access_status =
|
address: Address): evmc_access_status =
|
||||||
var address = toEvmc(address)
|
var address = toEvmc(address)
|
||||||
ctx.host.access_account(ctx.context, address.addr)
|
ctx.host.access_account(ctx.context, address.addr)
|
||||||
|
|
||||||
proc accessStorage*(ctx: HostContext, address: EthAddress,
|
proc accessStorage*(ctx: HostContext, address: Address,
|
||||||
key: UInt256): evmc_access_status =
|
key: UInt256): evmc_access_status =
|
||||||
var
|
var
|
||||||
address = toEvmc(address)
|
address = toEvmc(address)
|
||||||
key = toEvmc(key)
|
key = toEvmc(key)
|
||||||
ctx.host.access_storage(ctx.context, address.addr, key.addr)
|
ctx.host.access_storage(ctx.context, address.addr, key.addr)
|
||||||
|
|
||||||
proc getTransientStorage*(ctx: HostContext, address: EthAddress, key: UInt256): UInt256 =
|
proc getTransientStorage*(ctx: HostContext, address: Address, key: UInt256): UInt256 =
|
||||||
var
|
var
|
||||||
address = toEvmc(address)
|
address = toEvmc(address)
|
||||||
key = toEvmc(key)
|
key = toEvmc(key)
|
||||||
UInt256.fromEvmc ctx.host.get_transient_storage(ctx.context, address.addr, key.addr)
|
UInt256.fromEvmc ctx.host.get_transient_storage(ctx.context, address.addr, key.addr)
|
||||||
|
|
||||||
proc setTransientStorage*(ctx: HostContext, address: EthAddress,
|
proc setTransientStorage*(ctx: HostContext, address: Address,
|
||||||
key, value: UInt256) =
|
key, value: UInt256) =
|
||||||
var
|
var
|
||||||
address = toEvmc(address)
|
address = toEvmc(address)
|
||||||
|
@ -17,10 +17,10 @@ import
|
|||||||
const
|
const
|
||||||
evmc_native* {.booldefine.} = false
|
evmc_native* {.booldefine.} = false
|
||||||
|
|
||||||
func toEvmc*(a: EthAddress): evmc_address {.inline.} =
|
func toEvmc*(a: Address): evmc_address {.inline.} =
|
||||||
evmc_address(bytes: a.data)
|
evmc_address(bytes: a.data)
|
||||||
|
|
||||||
func toEvmc*(h: Hash256): evmc_bytes32 {.inline.} =
|
func toEvmc*(h: Hash32): evmc_bytes32 {.inline.} =
|
||||||
doAssert sizeof(h) == sizeof(evmc_bytes32)
|
doAssert sizeof(h) == sizeof(evmc_bytes32)
|
||||||
evmc_bytes32(bytes: h.data)
|
evmc_bytes32(bytes: h.data)
|
||||||
|
|
||||||
@ -48,8 +48,8 @@ func fromEvmc*(T: type, n: evmc_bytes32): T {.inline.} =
|
|||||||
else:
|
else:
|
||||||
{.error: "cannot convert unsupported evmc type".}
|
{.error: "cannot convert unsupported evmc type".}
|
||||||
|
|
||||||
func fromEvmc*(a: evmc_address): EthAddress {.inline.} =
|
func fromEvmc*(a: evmc_address): Address {.inline.} =
|
||||||
EthAddress(a.bytes)
|
Address(a.bytes)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
import ../constants
|
import ../constants
|
||||||
@ -62,7 +62,7 @@ when isMainModule:
|
|||||||
assert(b == fromEvmc(UInt256, eb))
|
assert(b == fromEvmc(UInt256, eb))
|
||||||
var h = EMPTY_SHA3
|
var h = EMPTY_SHA3
|
||||||
var eh = toEvmc(h)
|
var eh = toEvmc(h)
|
||||||
assert(h == fromEvmc(Hash256, eh))
|
assert(h == fromEvmc(Hash32, eh))
|
||||||
var s = cast[ContractSalt](EMPTY_ROOT_HASH)
|
var s = cast[ContractSalt](EMPTY_ROOT_HASH)
|
||||||
var es = toEvmc(s)
|
var es = toEvmc(s)
|
||||||
assert(s == fromEvmc(ContractSalt, es))
|
assert(s == fromEvmc(ContractSalt, es))
|
||||||
|
@ -49,8 +49,8 @@ type
|
|||||||
LocalParams = object
|
LocalParams = object
|
||||||
gas: UInt256
|
gas: UInt256
|
||||||
value: UInt256
|
value: UInt256
|
||||||
codeAddress: EthAddress
|
codeAddress: Address
|
||||||
sender: EthAddress
|
sender: Address
|
||||||
memInPos: int
|
memInPos: int
|
||||||
memInLen: int
|
memInLen: int
|
||||||
memOutPos: int
|
memOutPos: int
|
||||||
@ -58,7 +58,7 @@ type
|
|||||||
flags: MsgFlags
|
flags: MsgFlags
|
||||||
memOffset: int
|
memOffset: int
|
||||||
memLength: int
|
memLength: int
|
||||||
contractAddress: EthAddress
|
contractAddress: Address
|
||||||
gasCallEIP2929: GasInt
|
gasCallEIP2929: GasInt
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ else:
|
|||||||
# Public
|
# Public
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc gasEip2929AccountCheck*(c: Computation; address: EthAddress): GasInt =
|
proc gasEip2929AccountCheck*(c: Computation; address: Address): GasInt =
|
||||||
when defined(evmc_enabled):
|
when defined(evmc_enabled):
|
||||||
result = if c.host.accessAccount(address) == EVMC_ACCESS_COLD:
|
result = if c.host.accessAccount(address) == EVMC_ACCESS_COLD:
|
||||||
ColdAccountAccessCost
|
ColdAccountAccessCost
|
||||||
@ -49,7 +49,7 @@ proc gasEip2929AccountCheck*(c: Computation; address: EthAddress): GasInt =
|
|||||||
else:
|
else:
|
||||||
WarmStorageReadCost
|
WarmStorageReadCost
|
||||||
|
|
||||||
proc gasEip2929AccountCheck*(c: Computation; address: EthAddress, slot: UInt256): GasInt =
|
proc gasEip2929AccountCheck*(c: Computation; address: Address, slot: UInt256): GasInt =
|
||||||
when defined(evmc_enabled):
|
when defined(evmc_enabled):
|
||||||
result = if c.host.accessStorage(address, slot) == EVMC_ACCESS_COLD:
|
result = if c.host.accessStorage(address, slot) == EVMC_ACCESS_COLD:
|
||||||
ColdSloadCost
|
ColdSloadCost
|
||||||
|
@ -23,9 +23,9 @@ type
|
|||||||
|
|
||||||
proc new*(T: type AccessListTracer,
|
proc new*(T: type AccessListTracer,
|
||||||
acl: common.AccessList,
|
acl: common.AccessList,
|
||||||
sender: EthAddress,
|
sender: Address,
|
||||||
to: EthAddress,
|
to: Address,
|
||||||
precompiles: openArray[EthAddress]): T =
|
precompiles: openArray[Address]): T =
|
||||||
let act = T()
|
let act = T()
|
||||||
act.excl.incl sender
|
act.excl.incl sender
|
||||||
act.excl.incl to
|
act.excl.incl to
|
||||||
|
@ -136,7 +136,7 @@ method capturePrepare*(ctx: JsonTracer, comp: Computation, depth: int) {.gcsafe.
|
|||||||
|
|
||||||
# Top call frame
|
# Top call frame
|
||||||
method captureStart*(ctx: JsonTracer, comp: Computation,
|
method captureStart*(ctx: JsonTracer, comp: Computation,
|
||||||
sender: EthAddress, to: EthAddress,
|
sender: Address, to: Address,
|
||||||
create: bool, input: openArray[byte],
|
create: bool, input: openArray[byte],
|
||||||
gasLimit: GasInt, value: UInt256) {.gcsafe.} =
|
gasLimit: GasInt, value: UInt256) {.gcsafe.} =
|
||||||
discard
|
discard
|
||||||
|
@ -169,16 +169,16 @@ method captureFault*(ctx: LegacyTracer, comp: Computation,
|
|||||||
proc getTracingResult*(ctx: LegacyTracer): JsonNode =
|
proc getTracingResult*(ctx: LegacyTracer): JsonNode =
|
||||||
ctx.trace
|
ctx.trace
|
||||||
|
|
||||||
iterator tracedAccounts*(ctx: LegacyTracer): EthAddress =
|
iterator tracedAccounts*(ctx: LegacyTracer): Address =
|
||||||
for acc in ctx.accounts:
|
for acc in ctx.accounts:
|
||||||
yield acc
|
yield acc
|
||||||
|
|
||||||
iterator tracedAccountsPairs*(ctx: LegacyTracer): (int, EthAddress) =
|
iterator tracedAccountsPairs*(ctx: LegacyTracer): (int, Address) =
|
||||||
var idx = 0
|
var idx = 0
|
||||||
for acc in ctx.accounts:
|
for acc in ctx.accounts:
|
||||||
yield (idx, acc)
|
yield (idx, acc)
|
||||||
inc idx
|
inc idx
|
||||||
|
|
||||||
proc removeTracedAccounts*(ctx: LegacyTracer, accounts: varargs[EthAddress]) =
|
proc removeTracedAccounts*(ctx: LegacyTracer, accounts: varargs[Address]) =
|
||||||
for acc in accounts:
|
for acc in accounts:
|
||||||
ctx.accounts.excl acc
|
ctx.accounts.excl acc
|
||||||
|
@ -40,7 +40,7 @@ proc deriveLogs*(header: Header, transactions: seq[Transaction], receipts: seq[R
|
|||||||
blockNumber: Opt.some(Quantity(header.number)),
|
blockNumber: Opt.some(Quantity(header.number)),
|
||||||
address: log.address,
|
address: log.address,
|
||||||
data: log.data,
|
data: log.data,
|
||||||
# TODO topics should probably be kept as Hash256 in receipts
|
# TODO topics should probably be kept as Hash32 in receipts
|
||||||
topics: log.topics
|
topics: log.topics
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -269,8 +269,8 @@ proc setupEthRpc*(
|
|||||||
raise newException(ValueError, "Incorrect number of proofs")
|
raise newException(ValueError, "Incorrect number of proofs")
|
||||||
NetworkPayload(
|
NetworkPayload(
|
||||||
blobs: data.blobs.get.mapIt it.NetworkBlob,
|
blobs: data.blobs.get.mapIt it.NetworkBlob,
|
||||||
commitments: data.commitments.get.mapIt eth_types.KzgCommitment(it),
|
commitments: data.commitments.get,
|
||||||
proofs: data.proofs.get.mapIt eth_types.KzgProof(it))
|
proofs: data.proofs.get)
|
||||||
else:
|
else:
|
||||||
if data.blobs.isSome or data.commitments.isSome or data.proofs.isSome:
|
if data.blobs.isSome or data.commitments.isSome or data.proofs.isSome:
|
||||||
raise newException(ValueError, "Blobs require EIP-4844 transaction")
|
raise newException(ValueError, "Blobs require EIP-4844 transaction")
|
||||||
|
@ -240,7 +240,7 @@ proc populateReceipt*(receipt: Receipt, gasUsed: GasInt, tx: Transaction,
|
|||||||
result.contractAddress = Opt.some(tx.creationAddress(sender[]))
|
result.contractAddress = Opt.some(tx.creationAddress(sender[]))
|
||||||
|
|
||||||
for log in receipt.logs:
|
for log in receipt.logs:
|
||||||
# TODO: Work everywhere with either `Hash256` as topic or `array[32, byte]`
|
# TODO: Work everywhere with either `Hash32` as topic or `array[32, byte]`
|
||||||
var topics: seq[Bytes32]
|
var topics: seq[Bytes32]
|
||||||
for topic in log.topics:
|
for topic in log.topics:
|
||||||
topics.add (topic)
|
topics.add (topic)
|
||||||
|
@ -126,7 +126,7 @@ proc dumpReceiptsImpl(
|
|||||||
proc captureAccount(
|
proc captureAccount(
|
||||||
n: JsonNode;
|
n: JsonNode;
|
||||||
db: LedgerRef;
|
db: LedgerRef;
|
||||||
address: EthAddress;
|
address: Address;
|
||||||
name: string;
|
name: string;
|
||||||
) =
|
) =
|
||||||
var jaccount = newJObject()
|
var jaccount = newJObject()
|
||||||
|
@ -55,7 +55,7 @@ type
|
|||||||
CallResult* = object
|
CallResult* = object
|
||||||
error*: string # Something if the call failed.
|
error*: string # Something if the call failed.
|
||||||
gasUsed*: GasInt # Gas used by the call.
|
gasUsed*: GasInt # Gas used by the call.
|
||||||
contractAddress*: EthAddress # Created account (when `isCreate`).
|
contractAddress*: Address # Created account (when `isCreate`).
|
||||||
output*: seq[byte] # Output data.
|
output*: seq[byte] # Output data.
|
||||||
stack*: EvmStack # EVM stack on return (for test only).
|
stack*: EvmStack # EVM stack on return (for test only).
|
||||||
memory*: EvmMemory # EVM memory on return (for test only).
|
memory*: EvmMemory # EVM memory on return (for test only).
|
||||||
|
@ -148,7 +148,7 @@ proc rpcEstimateGas*(args: TransactionArgs,
|
|||||||
|
|
||||||
ok(hi)
|
ok(hi)
|
||||||
|
|
||||||
proc callParamsForTx(tx: Transaction, sender: EthAddress, vmState: BaseVMState, baseFee: GasInt): CallParams =
|
proc callParamsForTx(tx: Transaction, sender: Address, vmState: BaseVMState, baseFee: GasInt): CallParams =
|
||||||
# Is there a nice idiom for this kind of thing? Should I
|
# Is there a nice idiom for this kind of thing? Should I
|
||||||
# just be writing this as a bunch of assignment statements?
|
# just be writing this as a bunch of assignment statements?
|
||||||
result = CallParams(
|
result = CallParams(
|
||||||
@ -167,7 +167,7 @@ proc callParamsForTx(tx: Transaction, sender: EthAddress, vmState: BaseVMState,
|
|||||||
if tx.txType >= TxEip4844:
|
if tx.txType >= TxEip4844:
|
||||||
result.versionedHashes = tx.versionedHashes
|
result.versionedHashes = tx.versionedHashes
|
||||||
|
|
||||||
proc callParamsForTest(tx: Transaction, sender: EthAddress, vmState: BaseVMState): CallParams =
|
proc callParamsForTest(tx: Transaction, sender: Address, vmState: BaseVMState): CallParams =
|
||||||
result = CallParams(
|
result = CallParams(
|
||||||
vmState: vmState,
|
vmState: vmState,
|
||||||
gasPrice: tx.gasPrice,
|
gasPrice: tx.gasPrice,
|
||||||
@ -188,14 +188,14 @@ proc callParamsForTest(tx: Transaction, sender: EthAddress, vmState: BaseVMState
|
|||||||
result.versionedHashes = tx.versionedHashes
|
result.versionedHashes = tx.versionedHashes
|
||||||
|
|
||||||
proc txCallEvm*(tx: Transaction,
|
proc txCallEvm*(tx: Transaction,
|
||||||
sender: EthAddress,
|
sender: Address,
|
||||||
vmState: BaseVMState, baseFee: GasInt): GasInt =
|
vmState: BaseVMState, baseFee: GasInt): GasInt =
|
||||||
let
|
let
|
||||||
call = callParamsForTx(tx, sender, vmState, baseFee)
|
call = callParamsForTx(tx, sender, vmState, baseFee)
|
||||||
runComputation(call, GasInt)
|
runComputation(call, GasInt)
|
||||||
|
|
||||||
proc testCallEvm*(tx: Transaction,
|
proc testCallEvm*(tx: Transaction,
|
||||||
sender: EthAddress,
|
sender: Address,
|
||||||
vmState: BaseVMState): CallResult =
|
vmState: BaseVMState): CallResult =
|
||||||
let call = callParamsForTest(tx, sender, vmState)
|
let call = callParamsForTest(tx, sender, vmState)
|
||||||
runComputation(call, CallResult)
|
runComputation(call, CallResult)
|
||||||
|
@ -62,14 +62,14 @@ proc dumpAccounts*(vmState: BaseVMState): JsonNode =
|
|||||||
%dumpAccounts(vmState.stateDB)
|
%dumpAccounts(vmState.stateDB)
|
||||||
|
|
||||||
proc debugAccounts*(stateDB: LedgerRef, addresses: openArray[string]): string =
|
proc debugAccounts*(stateDB: LedgerRef, addresses: openArray[string]): string =
|
||||||
var accountList = newSeq[EthAddress]()
|
var accountList = newSeq[Address]()
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
accountList.add EthAddress.fromHex(address)
|
accountList.add Address.fromHex(address)
|
||||||
|
|
||||||
(%dumpAccounts(stateDB, accountList)).pretty
|
(%dumpAccounts(stateDB, accountList)).pretty
|
||||||
|
|
||||||
proc debugAccounts*(vmState: BaseVMState): string =
|
proc debugAccounts*(vmState: BaseVMState): string =
|
||||||
var accountList = newSeq[EthAddress]()
|
var accountList = newSeq[Address]()
|
||||||
for address in vmState.stateDB.addresses:
|
for address in vmState.stateDB.addresses:
|
||||||
accountList.add address
|
accountList.add address
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import
|
|||||||
chronicles,
|
chronicles,
|
||||||
chronos,
|
chronos,
|
||||||
confutils,
|
confutils,
|
||||||
eth/keys,
|
eth/common/keys,
|
||||||
json_rpc/rpcproxy,
|
json_rpc/rpcproxy,
|
||||||
beacon_chain/el/[el_manager, engine_api_conversions],
|
beacon_chain/el/[el_manager, engine_api_conversions],
|
||||||
beacon_chain/gossip_processing/optimistic_processor,
|
beacon_chain/gossip_processing/optimistic_processor,
|
||||||
|
@ -80,12 +80,12 @@ proc asExecutionData*(payload: SomeExecutionPayload): ExecutionData =
|
|||||||
func toFixedBytes(d: MDigest[256]): FixedBytes[32] =
|
func toFixedBytes(d: MDigest[256]): FixedBytes[32] =
|
||||||
FixedBytes[32](d.data)
|
FixedBytes[32](d.data)
|
||||||
|
|
||||||
template asEthHash(hash: BlockHash): etypes.Hash256 =
|
template asEthHash(hash: BlockHash): etypes.Hash32 =
|
||||||
etypes.Hash256(distinctBase(hash))
|
etypes.Hash32(distinctBase(hash))
|
||||||
|
|
||||||
proc calculateTransactionData(
|
proc calculateTransactionData(
|
||||||
items: openArray[TypedTransaction]
|
items: openArray[TypedTransaction]
|
||||||
): (etypes.Hash256, seq[TxOrHash], uint64) =
|
): (etypes.Hash32, seq[TxOrHash], uint64) =
|
||||||
## returns tuple composed of
|
## returns tuple composed of
|
||||||
## - root of transactions trie
|
## - root of transactions trie
|
||||||
## - list of transactions hashes
|
## - list of transactions hashes
|
||||||
@ -101,14 +101,14 @@ proc calculateTransactionData(
|
|||||||
let rootHash = tr.state(updateOk = true).expect "hash"
|
let rootHash = tr.state(updateOk = true).expect "hash"
|
||||||
(rootHash, txHashes, txSize)
|
(rootHash, txHashes, txSize)
|
||||||
|
|
||||||
func blockHeaderSize(payload: ExecutionData, txRoot: etypes.Hash256): uint64 =
|
func blockHeaderSize(payload: ExecutionData, txRoot: etypes.Hash32): uint64 =
|
||||||
let bh = etypes.BlockHeader(
|
let bh = etypes.BlockHeader(
|
||||||
parentHash: payload.parentHash.asEthHash,
|
parentHash: payload.parentHash,
|
||||||
ommersHash: etypes.EMPTY_UNCLE_HASH,
|
ommersHash: etypes.EMPTY_UNCLE_HASH,
|
||||||
coinbase: etypes.EthAddress payload.feeRecipient,
|
coinbase: payload.feeRecipient,
|
||||||
stateRoot: payload.stateRoot.asEthHash,
|
stateRoot: payload.stateRoot,
|
||||||
transactionsRoot: txRoot,
|
transactionsRoot: txRoot,
|
||||||
receiptsRoot: payload.receiptsRoot.asEthHash,
|
receiptsRoot: payload.receiptsRoot,
|
||||||
logsBloom: distinctBase(payload.logsBloom).to(Bloom),
|
logsBloom: distinctBase(payload.logsBloom).to(Bloom),
|
||||||
difficulty: default(etypes.DifficultyInt),
|
difficulty: default(etypes.DifficultyInt),
|
||||||
number: payload.blockNumber.distinctBase,
|
number: payload.blockNumber.distinctBase,
|
||||||
|
@ -28,13 +28,13 @@ export
|
|||||||
func pp*(b: seq[byte]): string =
|
func pp*(b: seq[byte]): string =
|
||||||
b.toHex.pp(hex = true)
|
b.toHex.pp(hex = true)
|
||||||
|
|
||||||
func pp*(a: EthAddress): string =
|
func pp*(a: Address): string =
|
||||||
a.toHex[32 .. 39]
|
a.toHex[32 .. 39]
|
||||||
|
|
||||||
func pp*(a: Opt[EthAddress]): string =
|
func pp*(a: Opt[Address]): string =
|
||||||
if a.isSome: a.unsafeGet.pp else: "n/a"
|
if a.isSome: a.unsafeGet.pp else: "n/a"
|
||||||
|
|
||||||
func pp*(a: openArray[EthAddress]): string =
|
func pp*(a: openArray[Address]): string =
|
||||||
"[" & a.mapIt(it.pp).join(" ") & "]"
|
"[" & a.mapIt(it.pp).join(" ") & "]"
|
||||||
|
|
||||||
func pp*(a: Bytes8|Bytes32): string =
|
func pp*(a: Bytes8|Bytes32): string =
|
||||||
|
@ -123,16 +123,14 @@ func pp*(q: openArray[int]; itemsPerLine: int; lineSep: string): string =
|
|||||||
func pp*(a: Hash32; collapse = true): string =
|
func pp*(a: Hash32; collapse = true): string =
|
||||||
if not collapse:
|
if not collapse:
|
||||||
a.data.toHex
|
a.data.toHex
|
||||||
elif a == ZERO_HASH256:
|
elif a == ZERO_HASH32:
|
||||||
"ZERO_HASH256"
|
"ZERO_HASH32"
|
||||||
elif a == EMPTY_ROOT_HASH:
|
elif a == EMPTY_ROOT_HASH:
|
||||||
"EMPTY_ROOT_HASH"
|
"EMPTY_ROOT_HASH"
|
||||||
elif a == EMPTY_UNCLE_HASH:
|
elif a == EMPTY_UNCLE_HASH:
|
||||||
"EMPTY_UNCLE_HASH"
|
"EMPTY_UNCLE_HASH"
|
||||||
elif a == EMPTY_SHA3:
|
elif a == EMPTY_SHA3:
|
||||||
"EMPTY_SHA3"
|
"EMPTY_SHA3"
|
||||||
elif a == ZERO_HASH256:
|
|
||||||
"ZERO_HASH256"
|
|
||||||
else:
|
else:
|
||||||
"£" & a.data.toHex.join[0..6] & ".." & a.data.toHex.join[56..63]
|
"£" & a.data.toHex.join[0..6] & ".." & a.data.toHex.join[56..63]
|
||||||
|
|
||||||
|
@ -68,12 +68,12 @@ proc preLoadAristoDb(jKvp: JsonNode): PartStateRef =
|
|||||||
ps
|
ps
|
||||||
|
|
||||||
|
|
||||||
proc collectAddresses(node: JsonNode, collect: var HashSet[EthAddress]) =
|
proc collectAddresses(node: JsonNode, collect: var HashSet[Address]) =
|
||||||
case node.kind:
|
case node.kind:
|
||||||
of JObject:
|
of JObject:
|
||||||
for k,v in node.pairs:
|
for k,v in node.pairs:
|
||||||
if k == "address" and v.kind == JString:
|
if k == "address" and v.kind == JString:
|
||||||
collect.incl EthAddress.fromHex v.getStr
|
collect.incl Address.fromHex v.getStr
|
||||||
else:
|
else:
|
||||||
v.collectAddresses collect
|
v.collectAddresses collect
|
||||||
of JArray:
|
of JArray:
|
||||||
@ -142,7 +142,7 @@ proc testCreatePortalProof(node: JsonNode, testStatusIMPL: var TestStatus) =
|
|||||||
let ps = node["state"].preLoadAristoDb()
|
let ps = node["state"].preLoadAristoDb()
|
||||||
|
|
||||||
# Collect addresses from json structure
|
# Collect addresses from json structure
|
||||||
var addresses: HashSet[EthAddress]
|
var addresses: HashSet[Address]
|
||||||
node.collectAddresses addresses
|
node.collectAddresses addresses
|
||||||
|
|
||||||
# Convert addresses to valid paths (not all addresses might work)
|
# Convert addresses to valid paths (not all addresses might work)
|
||||||
|
@ -23,7 +23,7 @@ import
|
|||||||
|
|
||||||
./test_helpers, ./test_allowed_to_fail
|
./test_helpers, ./test_allowed_to_fail
|
||||||
|
|
||||||
proc initAddress(i: byte): EthAddress = result.data[19] = i
|
proc initAddress(i: byte): Address = result.data[19] = i
|
||||||
|
|
||||||
template doTest(fixture: JsonNode; vmState: BaseVMState; address: PrecompileAddresses): untyped =
|
template doTest(fixture: JsonNode; vmState: BaseVMState; address: PrecompileAddresses): untyped =
|
||||||
for test in fixture:
|
for test in fixture:
|
||||||
|
@ -186,7 +186,7 @@ proc setupEnv(com: CommonRef, signer, ks2: Address, ctx: EthContext): TestEnv =
|
|||||||
gasUsed : vmState.cumulativeGasUsed,
|
gasUsed : vmState.cumulativeGasUsed,
|
||||||
timestamp : timeStamp
|
timestamp : timeStamp
|
||||||
#extraData: Blob
|
#extraData: Blob
|
||||||
#mixHash: Hash256
|
#mixHash: Hash32
|
||||||
#nonce: BlockNonce
|
#nonce: BlockNonce
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ proc testTxByFork(tx: Transaction, forkData: JsonNode, forkName: string, testSta
|
|||||||
return
|
return
|
||||||
|
|
||||||
if forkData.len > 0 and "sender" in forkData:
|
if forkData.len > 0 and "sender" in forkData:
|
||||||
let sender = EthAddress.fromHex(forkData["sender"].getStr)
|
let sender = Address.fromHex(forkData["sender"].getStr)
|
||||||
check "hash" in forkData
|
check "hash" in forkData
|
||||||
check tx.txHash == forkData["hash"].getStr
|
check tx.txHash == forkData["hash"].getStr
|
||||||
check tx.recoverSender().expect("valid signature") == sender
|
check tx.recoverSender().expect("valid signature") == sender
|
||||||
|
@ -58,7 +58,7 @@ var
|
|||||||
bcCom: CommonRef
|
bcCom: CommonRef
|
||||||
|
|
||||||
# Accounts to be considered local
|
# Accounts to be considered local
|
||||||
localAccounts: seq[EthAddress]
|
localAccounts: seq[Address]
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Helpers
|
# Helpers
|
||||||
@ -342,7 +342,7 @@ proc runTxPoolTests(noisy = false) =
|
|||||||
block:
|
block:
|
||||||
var
|
var
|
||||||
xq = bcCom.toTxPool(txList, noisy = noisy)
|
xq = bcCom.toTxPool(txList, noisy = noisy)
|
||||||
maxAddr: EthAddress
|
maxAddr: Address
|
||||||
nAddrItems = 0
|
nAddrItems = 0
|
||||||
|
|
||||||
nAddrPendingItems = 0
|
nAddrPendingItems = 0
|
||||||
|
@ -35,12 +35,12 @@ type
|
|||||||
TxEnv = object
|
TxEnv = object
|
||||||
chainId: ChainID
|
chainId: ChainID
|
||||||
rng: ref HmacDrbgContext
|
rng: ref HmacDrbgContext
|
||||||
signers: Table[EthAddress, PrivateKey]
|
signers: Table[Address, PrivateKey]
|
||||||
map: Table[EthAddress, EthAddress]
|
map: Table[Address, Address]
|
||||||
txs: seq[Transaction]
|
txs: seq[Transaction]
|
||||||
|
|
||||||
Signer = object
|
Signer = object
|
||||||
address: EthAddress
|
address: Address
|
||||||
signer: PrivateKey
|
signer: PrivateKey
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -50,7 +50,7 @@ proc initTxEnv(chainId: ChainID): TxEnv =
|
|||||||
result.rng = newRng()
|
result.rng = newRng()
|
||||||
result.chainId = chainId
|
result.chainId = chainId
|
||||||
|
|
||||||
proc getSigner(env: var TxEnv, address: EthAddress): Signer =
|
proc getSigner(env: var TxEnv, address: Address): Signer =
|
||||||
env.map.withValue(address, val) do:
|
env.map.withValue(address, val) do:
|
||||||
let newAddress = val[]
|
let newAddress = val[]
|
||||||
return Signer(address: newAddress, signer: env.signers[newAddress])
|
return Signer(address: newAddress, signer: env.signers[newAddress])
|
||||||
@ -65,7 +65,7 @@ proc fillGenesis(env: var TxEnv, param: NetworkParams) =
|
|||||||
const txFile = "tests/test_txpool/transactions.json"
|
const txFile = "tests/test_txpool/transactions.json"
|
||||||
let n = json.parseFile(txFile)
|
let n = json.parseFile(txFile)
|
||||||
|
|
||||||
var map: Table[EthAddress, UInt256]
|
var map: Table[Address, UInt256]
|
||||||
|
|
||||||
for z in n:
|
for z in n:
|
||||||
let bytes = hexToSeqByte(z.getStr)
|
let bytes = hexToSeqByte(z.getStr)
|
||||||
@ -112,7 +112,7 @@ proc toTxPool*(
|
|||||||
com: CommonRef; ## to be modified, initialisier for `TxPool`
|
com: CommonRef; ## to be modified, initialisier for `TxPool`
|
||||||
itList: seq[TxItemRef]; ## import items into new `TxPool` (read only)
|
itList: seq[TxItemRef]; ## import items into new `TxPool` (read only)
|
||||||
baseFee = 0.GasPrice; ## initalise with `baseFee` (unless 0)
|
baseFee = 0.GasPrice; ## initalise with `baseFee` (unless 0)
|
||||||
local: seq[EthAddress] = @[]; ## local addresses
|
local: seq[Address] = @[]; ## local addresses
|
||||||
noisy = true): TxPoolRef =
|
noisy = true): TxPoolRef =
|
||||||
|
|
||||||
doAssert not com.isNil
|
doAssert not com.isNil
|
||||||
@ -122,7 +122,7 @@ proc toTxPool*(
|
|||||||
result.maxRejects = itList.len
|
result.maxRejects = itList.len
|
||||||
|
|
||||||
let noLocals = local.len == 0
|
let noLocals = local.len == 0
|
||||||
var localAddr: Table[EthAddress,bool]
|
var localAddr: Table[Address,bool]
|
||||||
for a in local:
|
for a in local:
|
||||||
localAddr[a] = true
|
localAddr[a] = true
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ proc toTxPool*(
|
|||||||
baseFee = 0.GasPrice; ## initalise with `baseFee` (unless 0)
|
baseFee = 0.GasPrice; ## initalise with `baseFee` (unless 0)
|
||||||
itemsPC = 30; ## % number if items befor time gap
|
itemsPC = 30; ## % number if items befor time gap
|
||||||
delayMSecs = 200; ## size of time vap
|
delayMSecs = 200; ## size of time vap
|
||||||
local: seq[EthAddress] = @[]; ## local addresses
|
local: seq[EAddress] = @[]; ## local addresses
|
||||||
noisy = true): TxPoolRef =
|
noisy = true): TxPoolRef =
|
||||||
## Variant of `toTxPoolFromSeq()` with a time gap between consecutive
|
## Variant of `toTxPoolFromSeq()` with a time gap between consecutive
|
||||||
## items on the `remote` queue
|
## items on the `remote` queue
|
||||||
@ -157,7 +157,7 @@ proc toTxPool*(
|
|||||||
result.maxRejects = itList.len
|
result.maxRejects = itList.len
|
||||||
|
|
||||||
let noLocals = local.len == 0
|
let noLocals = local.len == 0
|
||||||
var localAddr: Table[EthAddress,bool]
|
var localAddr: Table[Address,bool]
|
||||||
for a in local:
|
for a in local:
|
||||||
localAddr[a] = true
|
localAddr[a] = true
|
||||||
|
|
||||||
@ -209,11 +209,11 @@ proc setItemStatusFromInfo*(xp: TxPoolRef) =
|
|||||||
|
|
||||||
|
|
||||||
proc getBackHeader*(xp: TxPoolRef; nTxs, nAccounts: int):
|
proc getBackHeader*(xp: TxPoolRef; nTxs, nAccounts: int):
|
||||||
(BlockHeader, seq[Transaction], seq[EthAddress]) {.inline.} =
|
(BlockHeader, seq[Transaction], seq[Address]) {.inline.} =
|
||||||
## back track the block chain for at least `nTxs` transactions and
|
## back track the block chain for at least `nTxs` transactions and
|
||||||
## `nAccounts` sender accounts
|
## `nAccounts` sender accounts
|
||||||
var
|
var
|
||||||
accTab: Table[EthAddress,bool]
|
accTab: Table[Address,bool]
|
||||||
txsLst: seq[Transaction]
|
txsLst: seq[Transaction]
|
||||||
backHash = xp.head.blockHash
|
backHash = xp.head.blockHash
|
||||||
backHeader = xp.head
|
backHeader = xp.head
|
||||||
|
@ -60,7 +60,7 @@ proc testKeySign*(header: BlockHeader): BlockHeader =
|
|||||||
## Sign the header and embed the signature in extra data
|
## Sign the header and embed the signature in extra data
|
||||||
header.sign(prvTestKey)
|
header.sign(prvTestKey)
|
||||||
|
|
||||||
proc signerFunc*(signer: EthAddress, msg: openArray[byte]):
|
proc signerFunc*(signer: Address, msg: openArray[byte]):
|
||||||
Result[array[RawSignatureSize, byte], cstring] {.gcsafe.} =
|
Result[array[RawSignatureSize, byte], cstring] {.gcsafe.} =
|
||||||
doAssert(signer == testAddress)
|
doAssert(signer == testAddress)
|
||||||
let
|
let
|
||||||
|
@ -14,7 +14,7 @@ import
|
|||||||
../../nimbus/db/ledger
|
../../nimbus/db/ledger
|
||||||
|
|
||||||
proc coinbaseStateClearing*(vmState: BaseVMState,
|
proc coinbaseStateClearing*(vmState: BaseVMState,
|
||||||
miner: EthAddress,
|
miner: Address,
|
||||||
touched = true) =
|
touched = true) =
|
||||||
# This is necessary due to the manner in which the state tests are
|
# This is necessary due to the manner in which the state tests are
|
||||||
# generated. State tests are generated from the BlockChainTest tests
|
# generated. State tests are generated from the BlockChainTest tests
|
||||||
|
@ -112,9 +112,9 @@ proc fromJson(T: type Authorization, n: JsonNode): Authorization =
|
|||||||
chainId: fromJson(ChainId, n, "chainId"),
|
chainId: fromJson(ChainId, n, "chainId"),
|
||||||
address: fromJson(Address, n, "address"),
|
address: fromJson(Address, n, "address"),
|
||||||
nonce: fromJson(uint64, n, "nonce"),
|
nonce: fromJson(uint64, n, "nonce"),
|
||||||
yParity: fromJson(uint64, n, "yParity"),
|
v: fromJson(uint64, n, "v"),
|
||||||
R: fromJson(UInt256, n, "R"),
|
r: fromJson(UInt256, n, "r"),
|
||||||
S: fromJson(UInt256, n, "S"),
|
s: fromJson(UInt256, n, "s"),
|
||||||
)
|
)
|
||||||
|
|
||||||
proc fromJson(T: type seq[Authorization], n: JsonNode, field: string): T =
|
proc fromJson(T: type seq[Authorization], n: JsonNode, field: string): T =
|
||||||
|
2
vendor/nim-eth
vendored
2
vendor/nim-eth
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 470baf82bdbf05dd399881123ae9020b8f117871
|
Subproject commit 171531fbf1a308c1bf4d2f6b88c6ee6924657437
|
2
vendor/nimbus-eth2
vendored
2
vendor/nimbus-eth2
vendored
@ -1 +1 @@
|
|||||||
Subproject commit b8a424991d4f8590f5e5364b18ffeabef72e1ff4
|
Subproject commit ec0accf29033bbb2fe718c130694c46e54c26387
|
Loading…
x
Reference in New Issue
Block a user