Bump nim-eth and nimbus-eth2 (#2741)

* Bump nim-eth and nimbus-eth2

* Fix ambiguous identifier
This commit is contained in:
andri lim 2024-10-16 13:51:38 +07:00 committed by GitHub
parent 2838191c4f
commit 1126c7700d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
55 changed files with 184 additions and 188 deletions

View File

@ -12,10 +12,10 @@ import stint, json_rpc/[client, jsonmarshal], web3/conversions, web3/eth_api_typ
export eth_api_types
createRpcSigsFromNim(RpcClient):
proc debug_getBalanceByStateRoot(data: Address, stateRoot: Hash256): UInt256
proc debug_getTransactionCountByStateRoot(data: Address, stateRoot: Hash256): Quantity
proc debug_getBalanceByStateRoot(data: Address, stateRoot: Hash32): UInt256
proc debug_getTransactionCountByStateRoot(data: Address, stateRoot: Hash32): Quantity
proc debug_getStorageAtByStateRoot(
data: Address, slot: UInt256, stateRoot: Hash256
data: Address, slot: UInt256, stateRoot: Hash32
): FixedBytes[32]
proc debug_getCodeByStateRoot(data: Address, stateRoot: Hash256): seq[byte]
proc debug_getCodeByStateRoot(data: Address, stateRoot: Hash32): seq[byte]

View File

@ -287,7 +287,7 @@ proc installEthApiHandlers*(
let
sn = stateNetwork.getOrRaise()
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")
return balance
@ -312,7 +312,7 @@ proc installEthApiHandlers*(
let
sn = stateNetwork.getOrRaise()
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")
return nonce.Quantity
@ -337,7 +337,7 @@ proc installEthApiHandlers*(
let
sn = stateNetwork.getOrRaise()
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")
return FixedBytes[32](slotValue.toBytesBE())
@ -361,7 +361,7 @@ proc installEthApiHandlers*(
let
sn = stateNetwork.getOrRaise()
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")
return bytecode.asSeq()
@ -388,7 +388,7 @@ proc installEthApiHandlers*(
let
sn = stateNetwork.getOrRaise()
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")
var storageProof = newSeqOfCap[StorageProof](slots.len)

View File

@ -84,7 +84,7 @@ proc asPortalBlockData*(
header = Header(
parentHash: payload.parentHash,
ommersHash: EMPTY_UNCLE_HASH,
coinbase: EthAddress payload.feeRecipient,
coinbase: payload.feeRecipient,
stateRoot: payload.stateRoot,
transactionsRoot: txRoot,
receiptsRoot: payload.receiptsRoot,
@ -127,7 +127,7 @@ proc asPortalBlockData*(
header = Header(
parentHash: payload.parentHash,
ommersHash: EMPTY_UNCLE_HASH,
coinbase: EthAddress payload.feeRecipient,
coinbase: payload.feeRecipient,
stateRoot: payload.stateRoot,
transactionsRoot: txRoot,
receiptsRoot: payload.receiptsRoot,
@ -158,7 +158,7 @@ proc asPortalBlockData*(
Withdrawal(
index: x.index.uint64,
validatorIndex: x.validatorIndex.uint64,
address: x.address.EthAddress,
address: x.address,
amount: x.amount.uint64,
)

View File

@ -122,8 +122,8 @@ proc runBackfillCollectBlockDataLoop(
let blockData = BlockData(
blockNumber: currentBlockNumber,
blockHash: blockObject.hash,
miner: blockObject.miner.EthAddress,
uncles: uncleBlocks.mapIt((it.miner.EthAddress, it.number.uint64)),
miner: blockObject.miner,
uncles: uncleBlocks.mapIt((it.miner, it.number.uint64)),
parentStateRoot: parentStateRoot,
stateRoot: blockObject.stateRoot,
stateDiffs: stateDiffs,

View File

@ -29,8 +29,8 @@ type
TestBlobTxPool* = ref object
currentBlobID* : BlobID
currentTxIndex*: int
transactions* : Table[common.Hash256, PooledTransaction]
hashesByIndex* : Table[int, common.Hash256]
transactions* : Table[Hash32, PooledTransaction]
hashesByIndex* : Table[int, Hash32]
const
HISTORY_BUFFER_LENGTH* = 8191
@ -147,7 +147,7 @@ proc beaconRootStorageIndexes*(timestamp: uint64): (UInt256, UInt256) =
type
BlobWrapData* = object
versionedHash*: common.Hash256
versionedHash*: Hash32
blob* : kzg.KzgBlob
commitment* : kzg.KZGCommitment
proof* : kzg.KzgProof

View File

@ -39,7 +39,7 @@ method execute*(step: DevP2PRequestPooledTransactionHash, ctx: CancunTestContext
engine.connect(sec.node)
var
txHashes = newSeq[common.Hash256](step.transactionIndexes.len)
txHashes = newSeq[Hash32](step.transactionIndexes.len)
txs = newSeq[PooledTransaction](step.transactionIndexes.len)
for i, txIndex in step.transactionIndexes:

View File

@ -527,7 +527,7 @@ let cancunTestListA* = [
testSequence: @[
NewPayloads(
fcUOnPayloadRequest: UpgradeForkchoiceUpdatedVersion(
beaconRoot: Opt.some(default(common.Hash256)),
beaconRoot: Opt.some(default(Hash32)),
expectedError: engineApiUnsupportedFork,
),
expectationDescription: """
@ -555,7 +555,7 @@ let cancunTestListA* = [
testSequence: @[
NewPayloads(
fcUOnPayloadRequest: BaseForkchoiceUpdatedCustomizer(
beaconRoot: Opt.some(default(common.Hash256)),
beaconRoot: Opt.some(default(Hash32)),
expectedError: engineApiInvalidPayloadAttributes,
),
expectationDescription: """
@ -583,7 +583,7 @@ let cancunTestListA* = [
testSequence: @[
NewPayloads(
fcUOnPayloadRequest: DowngradeForkchoiceUpdatedVersion(
beaconRoot: Opt.some(default(common.Hash256)),
beaconRoot: Opt.some(default(Hash32)),
expectedError: engineApiInvalidPayloadAttributes,
),
expectationDescription: """
@ -641,7 +641,7 @@ let cancunTestListA* = [
NewPayloads(
expectedIncludedBlobCount: MAX_BLOBS_PER_BLOCK,
fcUOnPayloadRequest: BaseForkchoiceUpdatedCustomizer(
beaconRoot: Opt.some(default(common.Hash256)),
beaconRoot: Opt.some(default(Hash32)),
),
),
SendBlobTransactions(
@ -818,7 +818,7 @@ let cancunTestListA* = [
payloadCustomizer: CustomPayloadData(
excessBlobGas: Opt.some(0'u64),
blobGasUsed: Opt.some(0'u64),
parentBeaconRoot: Opt.some(default(common.Hash256)),
parentBeaconRoot: Opt.some(default(Hash32)),
versionedHashesCustomizer: VersionedHashesCustomizer(
blobs: Opt.some(newSeq[BlobID]()),
),
@ -1673,7 +1673,7 @@ let cancunTestListA* = [
NewPayloads(
newPayloadCustomizer: UpgradeNewPayloadVersion(
payloadCustomizer: CustomPayloadData(
parentBeaconRoot: some(default(common.Hash256)),
parentBeaconRoot: some(default(Hash32)),
),
expectedError: engineApiInvalidParams,
),

View File

@ -23,7 +23,7 @@ import
./engine_client,
./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
type

View File

@ -301,7 +301,7 @@ method withMainFork(cs: PayloadBuildAfterInvalidPayloadTest, fork: EngineFork):
method getName(cs: PayloadBuildAfterInvalidPayloadTest): string =
"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:
let tx = ethTx(w3tx)
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
let
customizer = BasePayloadAttributesCustomizer(
prevRandao: Opt.some(default(common.Hash256)),
prevRandao: Opt.some(default(Hash32)),
suggestedFeerecipient: Opt.some(ZeroAddr),
)
payloadAttributes = customizer.getPayloadAttributes(env.clMock.latestPayloadAttributes)
@ -352,7 +352,7 @@ method execute(cs: PayloadBuildAfterInvalidPayloadTest, env: TestEnv): bool =
let basePayload = s.get.executionPayload
var src = ExecutableData(basePayload: basePayload)
if versione == Version.V3:
src.beaconRoot = Opt.some(default(common.Hash256))
src.beaconRoot = Opt.some(default(Hash32))
src.versionedHashes = Opt.some(collectBlobHashes(basePayload.transactions))
inv_p = env.generateInvalidPayload(src, InvalidStateRoot)

View File

@ -78,7 +78,7 @@ method execute(cs: ReExecutePayloadTest, env: TestEnv): bool =
type
InOrderPayloadExecutionTest* = ref object of EngineSpec
Shadow = ref object
recipient: EthAddress
recipient: Address
amountPerTx: UInt256
txPerPayload: 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,
# prepare a random account to receive funds.
var shadow = Shadow(
recipient: EthAddress.randomBytes(),
recipient: Address.randomBytes(),
amountPerTx: 1000.u256,
txPerPayload: 20,
payloadCount: 10,
@ -218,7 +218,7 @@ method execute(cs: MultiplePayloadsExtendingCanonicalChainTest, env: TestEnv): b
var callbacks = BlockProcessCallbacks(
# We send the transactions after we got the Payload ID, before the CLMocker gets the prepared Payload
onPayloadProducerSelected: proc(): bool =
let recipient = EthAddress.randomBytes()
let recipient = Address.randomBytes()
let tc = BaseTx(
recipient: Opt.some(recipient),
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
for i in 0..<payloadCount:
let newPrevRandao = common.Hash256.randomBytes()
let newPrevRandao = Hash32.randomBytes()
let customizer = CustomPayloadData(
prevRandao: Opt.some(newPrevRandao),
)
@ -271,7 +271,7 @@ type
NewPayloadOnSyncingClientTest* = ref object of EngineSpec
Shadow2 = ref object
recipient: EthAddress
recipient: Address
previousPayload: ExecutionPayload
method withMainFork(cs: NewPayloadOnSyncingClientTest, fork: EngineFork): BaseSpec =
@ -286,7 +286,7 @@ method getName(cs: NewPayloadOnSyncingClientTest): string =
method execute(cs: NewPayloadOnSyncingClientTest, env: TestEnv): bool =
var shadow = Shadow2(
# Set a random transaction recipient
recipient: EthAddress.randomBytes(),
recipient: Address.randomBytes(),
)
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.
let pbRes = env.clMock.produceBlocks(5, BlockProcessCallbacks(
onPayloadProducerSelected: proc(): bool =
let recipient = common.EthAddress.randomBytes()
let recipient = Address.randomBytes()
let tc = BaseTx(
recipient: Opt.some(recipient),
txType: cs.txType,

View File

@ -54,7 +54,7 @@ method execute(cs: SidechainReOrgTest, env: TestEnv): bool =
onNewPayloadBroadcast: proc(): bool =
# 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
let alternativePrevRandao = common.Hash256.randomBytes()
let alternativePrevRandao = Hash32.randomBytes()
let timestamp = w3Qty(env.clMock.latestPayloadBuilt.timestamp, 1)
let customizer = BasePayloadAttributesCustomizer(
timestamp: Opt.some(timestamp.uint64),
@ -134,7 +134,7 @@ method getName(cs: TransactionReOrgTest): string =
name.add ", " & $cs.scenario
return name
proc txHash(shadow: ShadowTx): common.Hash256 =
proc txHash(shadow: ShadowTx): Hash32 =
if shadow.tx.isNone:
error "SHADOW TX IS NONE"
return
@ -669,7 +669,7 @@ method execute(cs: ReOrgPrevValidatedPayloadOnSideChainTest, env: TestEnv): bool
pbRes = env.clMock.produceSingleBlock(BlockProcessCallbacks(
onGetpayload: proc(): bool =
var
prevRandao = common.Hash256.randomBytes()
prevRandao = Hash32.randomBytes()
suggestedFeeRecipient = ethAddress(0x12, 0x34)
let payloadAttributesCustomizer = BasePayloadAttributesCustomizer(

View File

@ -26,7 +26,7 @@ type
# TODO: Syncing bool
Shadow = ref object
txHash: common.Hash256
txHash: Hash32
method withMainFork(cs: BlockStatus, fork: EngineFork): BaseSpec =
var res = cs.clone()

View File

@ -36,8 +36,8 @@ method execute(cs: SuggestedFeeRecipientTest, env: TestEnv): bool =
# Verify that, in a block with transactions, fees are accrued by the suggestedFeeRecipient
let
feeRecipient = EthAddress.randomBytes()
txRecipient = EthAddress.randomBytes()
feeRecipient = Address.randomBytes()
txRecipient = Address.randomBytes()
# Send multiple transactions
for i in 0..<cs.transactionCount:

View File

@ -16,13 +16,13 @@ import
./engine_client,
./types
proc txInPayload*(payload: ExecutionPayload, txHash: common.Hash256): bool =
proc txInPayload*(payload: ExecutionPayload, txHash: Hash32): bool =
for txBytes in payload.transactions:
let currTx = rlp.decode(common.Blob txBytes, Transaction)
if rlpHash(currTx) == txHash:
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 r = client.storageAt(prevRandaoContractAddr, storageKey)
let expected = FixedBytes[32](expectedPrevRandao.data)

View File

@ -114,7 +114,7 @@ func blockHeader*(p: ExecutionPayload,
blobGasUsed : u64(p.blobGasUsed),
excessBlobGas : u64(p.excessBlobGas),
parentBeaconBlockRoot: beaconRoot,
requestsRoot : requestsRoot(p),
requestsHash : requestsRoot(p),
)
func blockBody*(p: ExecutionPayload):

View File

@ -183,8 +183,6 @@ proc init(com : CommonRef,
com.pruneHistory= pruneHistory
com.pos = CasperRef.new
const TimeZero = EthTime(0)
# com.forkIdCalculator and com.genesisHash are set
# by setForkId
if genesis.isNil.not:

View File

@ -27,8 +27,8 @@ const
# address zero by accident, unrecoverably, due to poor user interface issues.
ZERO_ADDRESS* = default(Address)
# ZERO_HASH256 is the parent hash of genesis blocks.
ZERO_HASH256* = default(Hash32)
# ZERO_HASH32 is the parent hash of genesis blocks.
ZERO_HASH32* = default(Hash32)
GAS_LIMIT_ADJUSTMENT_FACTOR* = 1_024
@ -42,10 +42,10 @@ const
GENESIS_BLOCK_NUMBER* = 0.BlockNumber
GENESIS_DIFFICULTY* = 131_072.u256
GENESIS_GAS_LIMIT* = 3_141_592
GENESIS_PARENT_HASH* = ZERO_HASH256
GENESIS_PARENT_HASH* = ZERO_HASH32
GENESIS_COINBASE* = ZERO_ADDRESS
GENESIS_NONCE* = "\x00\x00\x00\x00\x00\x00\x00B"
GENESIS_MIX_HASH* = ZERO_HASH256
GENESIS_MIX_HASH* = ZERO_HASH32
GENESIS_EXTRA_DATA* = ""
GAS_LIMIT_MINIMUM* = 5000
GAS_LIMIT_MAXIMUM* = int64.high.GasInt # Maximum the gas limit (2^63-1).

View File

@ -75,12 +75,12 @@ proc procBlkPreamble(
return err("Mismatched txRoot")
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")
?vmState.processParentBlockHash(header.parentHash)
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")
if com.isCancunOrLater(header.timestamp):
@ -96,7 +96,7 @@ proc procBlkPreamble(
if blk.transactions.len == 0:
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)
elif blk.transactions.len > 0:
return err("Transactions in block with empty txRoot")
@ -178,13 +178,13 @@ proc procBlkEpilogue(
expected = header.receiptsRoot
return err("receiptRoot mismatch")
if header.requestsRoot.isSome:
if header.requestsHash.isSome:
let requestsRoot = calcRequestsRoot(blk.requests.get)
if header.requestsRoot.get != requestsRoot:
if header.requestsHash.get != requestsRoot:
debug "wrong requestsRoot in block",
blockNumber = header.number,
actual = requestsRoot,
expected = header.requestsRoot.get
expected = header.requestsHash.get
return err("requestsRoot mismatch")
let depositReqs = ?parseDepositLogs(vmState.allLogs)
var expectedDeposits: seq[Request]

View File

@ -107,7 +107,7 @@ func baseFee(pst: TxPacker): GasInt =
else:
0.GasInt
func feeRecipient(pst: TxPacker): EthAddress =
func feeRecipient(pst: TxPacker): Address =
pst.vmState.com.pos.feeRecipient
# ------------------------------------------------------------------------------

View File

@ -23,17 +23,17 @@ import
type
TxRank* = ##\
## Order relation, determins how the `EthAddresses` are ranked
## Order relation, determins how the `Addresses` are ranked
distinct int64
TxRankAddrRef* = ##\
## Set of adresses having the same rank.
TableRef[EthAddress,TxRank]
TableRef[Address,TxRank]
TxRankTab* = object ##\
## Descriptor for `TxRank` <-> `EthAddress` mapping.
## Descriptor for `TxRank` <-> `Address` mapping.
rankList: SortedSet[TxRank,TxRankAddrRef]
addrTab: Table[EthAddress,TxRank]
addrTab: Table[Address,TxRank]
# ------------------------------------------------------------------------------
# Private helpers
@ -61,7 +61,7 @@ proc clear*(rt: var TxRankTab) =
# 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].} =
## Add or update a new ranked address. This function returns `true` it the
## address exists already with the current rank.
@ -83,7 +83,7 @@ proc insert*(rt: var TxRankTab; rank: TxRank; sender: EthAddress): bool
var newRankSet: TxRankAddrRef
let rc = rt.rankList.insert(rank)
if rc.isOk:
newRankSet = newTable[EthAddress,TxRank](1)
newRankSet = newTable[Address,TxRank](1)
rc.value.data = newRankSet
else:
newRankSet = rt.rankList.eq(rank).value.data
@ -93,7 +93,7 @@ proc insert*(rt: var TxRankTab; rank: TxRank; sender: EthAddress): bool
true
proc delete*(rt: var TxRankTab; sender: EthAddress): bool
proc delete*(rt: var TxRankTab; sender: Address): bool
{.gcsafe,raises: [KeyError].} =
## Delete argument address `sender` from rank table.
if rt.addrTab.hasKey(sender):
@ -111,7 +111,7 @@ proc delete*(rt: var TxRankTab; sender: EthAddress): bool
return true
# ------------------------------------------------------------------------------
# Public functions: `TxRank` > `EthAddress`
# Public functions: `TxRank` > `Address`
# ------------------------------------------------------------------------------
proc len*(rt: var TxRankTab): int =
@ -139,15 +139,15 @@ proc lt*(rt: var TxRankTab; rank: TxRank):
rt.rankList.lt(rank)
# ------------------------------------------------------------------------------
# Public functions: `EthAddress` > `TxRank`
# Public functions: `Address` > `TxRank`
# ------------------------------------------------------------------------------
proc nItems*(rt: var TxRankTab): int =
## Total number of address items registered
rt.addrTab.len
proc eq*(rt: var TxRankTab; sender: EthAddress):
SortedSetResult[EthAddress,TxRank]
proc eq*(rt: var TxRankTab; sender: Address):
SortedSetResult[Address,TxRank]
{.gcsafe,raises: [KeyError].} =
if rt.addrTab.hasKey(sender):
return toSortedSetResult(key = sender, data = rt.addrTab[sender])

View File

@ -29,7 +29,7 @@ type
## Per address table. This table is provided as a keyed queue so deletion\
## while traversing is supported and predictable.
size: int ## Total number of items
addrList: KeyedQueue[EthAddress,TxStatusNonceRef]
addrList: KeyedQueue[Address,TxStatusNonceRef]
TxStatusTab* = object ##\
## Per status table
@ -159,7 +159,7 @@ proc eq*(sq: var TxStatusTab; status: TxItemStatus):
toSortedSetResult(key = status, data = addrData)
# ------------------------------------------------------------------------------
# Public array ops -- `EthAddress` (level 1)
# Public array ops -- `Address` (level 1)
# ------------------------------------------------------------------------------
proc nItems*(addrData: TxStatusSenderRef): int =
@ -171,15 +171,15 @@ proc nItems*(rc: SortedSetResult[TxItemStatus,TxStatusSenderRef]): int =
return rc.value.data.nItems
0
proc eq*(addrData: TxStatusSenderRef; sender: EthAddress):
SortedSetResult[EthAddress,TxStatusNonceRef]
proc eq*(addrData: TxStatusSenderRef; sender: Address):
SortedSetResult[Address,TxStatusNonceRef]
{.gcsafe,raises: [KeyError].} =
if addrData.addrList.hasKey(sender):
return toSortedSetResult(key = sender, data = addrData.addrList[sender])
err(rbNotFound)
proc eq*(rc: SortedSetResult[TxItemStatus,TxStatusSenderRef];
sender: EthAddress): SortedSetResult[EthAddress,TxStatusNonceRef]
sender: Address): SortedSetResult[Address,TxStatusNonceRef]
{.gcsafe,raises: [KeyError].} =
if rc.isOk:
return rc.value.data.eq(sender)
@ -197,7 +197,7 @@ proc nItems*(nonceData: TxStatusNonceRef): int =
## Getter, total number of items in the sub-list
nonceData.nonceList.len
proc nItems*(rc: SortedSetResult[EthAddress,TxStatusNonceRef]): int =
proc nItems*(rc: SortedSetResult[Address,TxStatusNonceRef]): int =
if rc.isOk:
return rc.value.data.nItems
0
@ -207,7 +207,7 @@ proc eq*(nonceData: TxStatusNonceRef; nonce: AccountNonce):
SortedSetResult[AccountNonce,TxItemRef] =
nonceData.nonceList.eq(nonce)
proc eq*(rc: SortedSetResult[EthAddress,TxStatusNonceRef]; nonce: AccountNonce):
proc eq*(rc: SortedSetResult[Address,TxStatusNonceRef]; nonce: AccountNonce):
SortedSetResult[AccountNonce,TxItemRef] =
if rc.isOk:
return rc.value.data.eq(nonce)
@ -218,7 +218,7 @@ proc ge*(nonceData: TxStatusNonceRef; nonce: AccountNonce):
SortedSetResult[AccountNonce,TxItemRef] =
nonceData.nonceList.ge(nonce)
proc ge*(rc: SortedSetResult[EthAddress,TxStatusNonceRef]; nonce: AccountNonce):
proc ge*(rc: SortedSetResult[Address,TxStatusNonceRef]; nonce: AccountNonce):
SortedSetResult[AccountNonce,TxItemRef] =
if rc.isOk:
return rc.value.data.ge(nonce)
@ -229,7 +229,7 @@ proc gt*(nonceData: TxStatusNonceRef; nonce: AccountNonce):
SortedSetResult[AccountNonce,TxItemRef] =
nonceData.nonceList.gt(nonce)
proc gt*(rc: SortedSetResult[EthAddress,TxStatusNonceRef]; nonce: AccountNonce):
proc gt*(rc: SortedSetResult[Address,TxStatusNonceRef]; nonce: AccountNonce):
SortedSetResult[AccountNonce,TxItemRef] =
if rc.isOk:
return rc.value.data.gt(nonce)

View File

@ -248,7 +248,7 @@ proc validateTxBasic*(
proc validateTransaction*(
roDB: ReadOnlyStateDB; ## Parent accounts environment for transaction
tx: Transaction; ## tx to validate
sender: EthAddress; ## tx.recoverSender
sender: Address; ## tx.recoverSender
maxLimit: GasInt; ## gasLimit from block header
baseFee: UInt256; ## baseFee from block header
excessBlobGas: uint64; ## excessBlobGas from parent block header

View File

@ -18,7 +18,7 @@ type
SlotSet = HashSet[UInt256]
AccessList* = object
slots: Table[EthAddress, SlotSet]
slots: Table[Address, SlotSet]
# ------------------------------------------------------------------------------
# Private helpers
@ -33,7 +33,7 @@ func toStorageKeys(slots: SlotSet): seq[Bytes32] =
# ------------------------------------------------------------------------------
proc init*(ac: var AccessList) =
ac.slots = Table[EthAddress, SlotSet]()
ac.slots = Table[Address, SlotSet]()
proc init*(_: type AccessList): AccessList {.inline.} =
result.init()
@ -42,11 +42,11 @@ proc init*(_: type AccessList): AccessList {.inline.} =
# Public functions
# ------------------------------------------------------------------------------
func contains*(ac: AccessList, address: EthAddress): bool {.inline.} =
func contains*(ac: AccessList, address: Address): bool {.inline.} =
address in ac.slots
# 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):
result = slot in val[]
@ -54,11 +54,11 @@ proc mergeAndReset*(ac, other: var AccessList) =
# move values in `other` to `ac`
ac.slots.mergeAndReset(other.slots)
proc add*(ac: var AccessList, address: EthAddress) =
proc add*(ac: var AccessList, address: Address) =
if address notin ac.slots:
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):
val[].incl slot
do:

View File

@ -87,7 +87,7 @@ type
func oaToStr(w: openArray[byte]): string =
w.toHex.toLowerAscii
func toStr(w: EthAddress): string =
func toStr(w: Address): string =
w.toHex
func toStr(w: Hash32): string =
@ -115,7 +115,7 @@ func `$`*(w: CodeBytesRef): string {.used.} = w.toStr
func `$`*(e: Elapsed): string = e.Duration.toStr
func `$`*(l: seq[Log]): string = l.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 `$`
# ------------------------------------------------------------------------------

View File

@ -36,21 +36,21 @@ iterator accounts*(ldg: LedgerRef): Account =
ldg.ifTrackApi: debug apiTxt, api, elapsed
iterator addresses*(ldg: LedgerRef): EthAddress =
iterator addresses*(ldg: LedgerRef): Address =
ldg.beginTrackApi LdgAdressesIt
for w in ldg.ac.addresses():
yield w
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
for w in ldg.ac.cachedStorage(eAddr):
yield w
ldg.ifTrackApi: debug apiTxt, api, elapsed, eAddr=($$eAddr)
iterator pairs*(ldg: LedgerRef): (EthAddress,Account) =
iterator pairs*(ldg: LedgerRef): (Address,Account) =
ldg.beginTrackApi LdgPairsIt
for w in ldg.ac.pairs():
yield w
@ -59,7 +59,7 @@ iterator pairs*(ldg: LedgerRef): (EthAddress,Account) =
iterator storage*(
ldg: LedgerRef;
eAddr: EthAddress;
eAddr: Address;
): (UInt256,UInt256) =
ldg.beginTrackApi LdgStorageIt
for w in ldg.ac.storage(eAddr):

View File

@ -19,7 +19,7 @@ type
map: Table[UInt256, UInt256]
TransientStorage* = object
map: Table[EthAddress, StorageTable]
map: Table[Address, StorageTable]
#######################################################################
# Private helpers
@ -33,13 +33,13 @@ proc mergeAndReset*(a, b: StorageTable) =
#######################################################################
proc init*(ac: var TransientStorage) =
ac.map = Table[EthAddress, StorageTable]()
ac.map = Table[Address, StorageTable]()
proc init*(_: type TransientStorage): TransientStorage {.inline.} =
result.init()
func getStorage*(ac: TransientStorage,
address: EthAddress, slot: UInt256): (bool, UInt256) =
address: Address, slot: UInt256): (bool, UInt256) =
var table = ac.map.getOrDefault(address)
if table.isNil:
return (false, 0.u256)
@ -50,7 +50,7 @@ func getStorage*(ac: TransientStorage,
return (false, 0.u256)
proc setStorage*(ac: var TransientStorage,
address: EthAddress, slot, value: UInt256) =
address: Address, slot, value: UInt256) =
var table = ac.map.getOrDefault(address)
if table.isNil:
table = StorageTable()

View File

@ -20,8 +20,8 @@ type
# and we can reduce unecessary conversion further
nimbus_tx_context* = object
tx_gas_price* : evmc_uint256be # The transaction gas price.
tx_origin* : EthAddress # The transaction origin account.
block_coinbase* : EthAddress # The miner of the block.
tx_origin* : Address # The transaction origin account.
block_coinbase* : Address # The miner of the block.
block_number* : int64 # The block number.
block_timestamp* : int64 # The block timestamp.
block_gas_limit* : int64 # The block gas limit.
@ -39,13 +39,13 @@ type
flags* : evmc_flags
depth* : int32
gas* : int64
recipient* : EthAddress
sender* : EthAddress
recipient* : Address
sender* : Address
input_data* : ptr byte
input_size* : uint
value* : evmc_uint256be
create2_salt*: evmc_bytes32
code_address*: EthAddress
code_address*: Address
code* : ptr byte
code_size* : csize_t
@ -57,7 +57,7 @@ type
output_size* : uint
release* : proc(result: var nimbus_result)
{.cdecl, gcsafe, raises: [].}
create_address*: EthAddress
create_address*: Address
padding* : array[4, byte]
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 =
ctx.host.get_tx_context(ctx.context)
proc getBlockHash*(ctx: HostContext, number: BlockNumber): Hash256 =
Hash256.fromEvmc ctx.host.get_block_hash(ctx.context, number.int64)
proc getBlockHash*(ctx: HostContext, number: BlockNumber): Hash32 =
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)
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
address = toEvmc(address)
key = toEvmc(key)
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 =
var
address = toEvmc(address)
@ -128,19 +128,19 @@ proc setStorage*(ctx: HostContext, address: EthAddress,
value = toEvmc(value)
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)
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)
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)
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
if size - codeOffset > 0:
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)
doAssert(read == result.len)
proc selfDestruct*(ctx: HostContext, address, beneficiary: EthAddress) =
proc selfDestruct*(ctx: HostContext, address, beneficiary: Address) =
var
address = toEvmc(address)
beneficiary = toEvmc(beneficiary)
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) =
var address = toEvmc(address)
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)
proc accessAccount*(ctx: HostContext,
address: EthAddress): evmc_access_status =
address: Address): evmc_access_status =
var address = toEvmc(address)
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 =
var
address = toEvmc(address)
key = toEvmc(key)
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
address = toEvmc(address)
key = toEvmc(key)
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) =
var
address = toEvmc(address)

View File

@ -17,10 +17,10 @@ import
const
evmc_native* {.booldefine.} = false
func toEvmc*(a: EthAddress): evmc_address {.inline.} =
func toEvmc*(a: Address): evmc_address {.inline.} =
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)
evmc_bytes32(bytes: h.data)
@ -48,8 +48,8 @@ func fromEvmc*(T: type, n: evmc_bytes32): T {.inline.} =
else:
{.error: "cannot convert unsupported evmc type".}
func fromEvmc*(a: evmc_address): EthAddress {.inline.} =
EthAddress(a.bytes)
func fromEvmc*(a: evmc_address): Address {.inline.} =
Address(a.bytes)
when isMainModule:
import ../constants
@ -62,7 +62,7 @@ when isMainModule:
assert(b == fromEvmc(UInt256, eb))
var h = EMPTY_SHA3
var eh = toEvmc(h)
assert(h == fromEvmc(Hash256, eh))
assert(h == fromEvmc(Hash32, eh))
var s = cast[ContractSalt](EMPTY_ROOT_HASH)
var es = toEvmc(s)
assert(s == fromEvmc(ContractSalt, es))

View File

@ -49,8 +49,8 @@ type
LocalParams = object
gas: UInt256
value: UInt256
codeAddress: EthAddress
sender: EthAddress
codeAddress: Address
sender: Address
memInPos: int
memInLen: int
memOutPos: int
@ -58,7 +58,7 @@ type
flags: MsgFlags
memOffset: int
memLength: int
contractAddress: EthAddress
contractAddress: Address
gasCallEIP2929: GasInt

View File

@ -35,7 +35,7 @@ else:
# Public
# ------------------------------------------------------------------------------
proc gasEip2929AccountCheck*(c: Computation; address: EthAddress): GasInt =
proc gasEip2929AccountCheck*(c: Computation; address: Address): GasInt =
when defined(evmc_enabled):
result = if c.host.accessAccount(address) == EVMC_ACCESS_COLD:
ColdAccountAccessCost
@ -49,7 +49,7 @@ proc gasEip2929AccountCheck*(c: Computation; address: EthAddress): GasInt =
else:
WarmStorageReadCost
proc gasEip2929AccountCheck*(c: Computation; address: EthAddress, slot: UInt256): GasInt =
proc gasEip2929AccountCheck*(c: Computation; address: Address, slot: UInt256): GasInt =
when defined(evmc_enabled):
result = if c.host.accessStorage(address, slot) == EVMC_ACCESS_COLD:
ColdSloadCost

View File

@ -23,9 +23,9 @@ type
proc new*(T: type AccessListTracer,
acl: common.AccessList,
sender: EthAddress,
to: EthAddress,
precompiles: openArray[EthAddress]): T =
sender: Address,
to: Address,
precompiles: openArray[Address]): T =
let act = T()
act.excl.incl sender
act.excl.incl to

View File

@ -136,7 +136,7 @@ method capturePrepare*(ctx: JsonTracer, comp: Computation, depth: int) {.gcsafe.
# Top call frame
method captureStart*(ctx: JsonTracer, comp: Computation,
sender: EthAddress, to: EthAddress,
sender: Address, to: Address,
create: bool, input: openArray[byte],
gasLimit: GasInt, value: UInt256) {.gcsafe.} =
discard

View File

@ -169,16 +169,16 @@ method captureFault*(ctx: LegacyTracer, comp: Computation,
proc getTracingResult*(ctx: LegacyTracer): JsonNode =
ctx.trace
iterator tracedAccounts*(ctx: LegacyTracer): EthAddress =
iterator tracedAccounts*(ctx: LegacyTracer): Address =
for acc in ctx.accounts:
yield acc
iterator tracedAccountsPairs*(ctx: LegacyTracer): (int, EthAddress) =
iterator tracedAccountsPairs*(ctx: LegacyTracer): (int, Address) =
var idx = 0
for acc in ctx.accounts:
yield (idx, acc)
inc idx
proc removeTracedAccounts*(ctx: LegacyTracer, accounts: varargs[EthAddress]) =
proc removeTracedAccounts*(ctx: LegacyTracer, accounts: varargs[Address]) =
for acc in accounts:
ctx.accounts.excl acc

View File

@ -40,7 +40,7 @@ proc deriveLogs*(header: Header, transactions: seq[Transaction], receipts: seq[R
blockNumber: Opt.some(Quantity(header.number)),
address: log.address,
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
)

View File

@ -269,8 +269,8 @@ proc setupEthRpc*(
raise newException(ValueError, "Incorrect number of proofs")
NetworkPayload(
blobs: data.blobs.get.mapIt it.NetworkBlob,
commitments: data.commitments.get.mapIt eth_types.KzgCommitment(it),
proofs: data.proofs.get.mapIt eth_types.KzgProof(it))
commitments: data.commitments.get,
proofs: data.proofs.get)
else:
if data.blobs.isSome or data.commitments.isSome or data.proofs.isSome:
raise newException(ValueError, "Blobs require EIP-4844 transaction")

View File

@ -240,7 +240,7 @@ proc populateReceipt*(receipt: Receipt, gasUsed: GasInt, tx: Transaction,
result.contractAddress = Opt.some(tx.creationAddress(sender[]))
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]
for topic in log.topics:
topics.add (topic)

View File

@ -126,7 +126,7 @@ proc dumpReceiptsImpl(
proc captureAccount(
n: JsonNode;
db: LedgerRef;
address: EthAddress;
address: Address;
name: string;
) =
var jaccount = newJObject()

View File

@ -55,7 +55,7 @@ type
CallResult* = object
error*: string # Something if the call failed.
gasUsed*: GasInt # Gas used by the call.
contractAddress*: EthAddress # Created account (when `isCreate`).
contractAddress*: Address # Created account (when `isCreate`).
output*: seq[byte] # Output data.
stack*: EvmStack # EVM stack on return (for test only).
memory*: EvmMemory # EVM memory on return (for test only).

View File

@ -148,7 +148,7 @@ proc rpcEstimateGas*(args: TransactionArgs,
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
# just be writing this as a bunch of assignment statements?
result = CallParams(
@ -167,7 +167,7 @@ proc callParamsForTx(tx: Transaction, sender: EthAddress, vmState: BaseVMState,
if tx.txType >= TxEip4844:
result.versionedHashes = tx.versionedHashes
proc callParamsForTest(tx: Transaction, sender: EthAddress, vmState: BaseVMState): CallParams =
proc callParamsForTest(tx: Transaction, sender: Address, vmState: BaseVMState): CallParams =
result = CallParams(
vmState: vmState,
gasPrice: tx.gasPrice,
@ -188,14 +188,14 @@ proc callParamsForTest(tx: Transaction, sender: EthAddress, vmState: BaseVMState
result.versionedHashes = tx.versionedHashes
proc txCallEvm*(tx: Transaction,
sender: EthAddress,
sender: Address,
vmState: BaseVMState, baseFee: GasInt): GasInt =
let
call = callParamsForTx(tx, sender, vmState, baseFee)
runComputation(call, GasInt)
proc testCallEvm*(tx: Transaction,
sender: EthAddress,
sender: Address,
vmState: BaseVMState): CallResult =
let call = callParamsForTest(tx, sender, vmState)
runComputation(call, CallResult)

View File

@ -62,14 +62,14 @@ proc dumpAccounts*(vmState: BaseVMState): JsonNode =
%dumpAccounts(vmState.stateDB)
proc debugAccounts*(stateDB: LedgerRef, addresses: openArray[string]): string =
var accountList = newSeq[EthAddress]()
var accountList = newSeq[Address]()
for address in addresses:
accountList.add EthAddress.fromHex(address)
accountList.add Address.fromHex(address)
(%dumpAccounts(stateDB, accountList)).pretty
proc debugAccounts*(vmState: BaseVMState): string =
var accountList = newSeq[EthAddress]()
var accountList = newSeq[Address]()
for address in vmState.stateDB.addresses:
accountList.add address

View File

@ -12,7 +12,7 @@ import
chronicles,
chronos,
confutils,
eth/keys,
eth/common/keys,
json_rpc/rpcproxy,
beacon_chain/el/[el_manager, engine_api_conversions],
beacon_chain/gossip_processing/optimistic_processor,

View File

@ -80,12 +80,12 @@ proc asExecutionData*(payload: SomeExecutionPayload): ExecutionData =
func toFixedBytes(d: MDigest[256]): FixedBytes[32] =
FixedBytes[32](d.data)
template asEthHash(hash: BlockHash): etypes.Hash256 =
etypes.Hash256(distinctBase(hash))
template asEthHash(hash: BlockHash): etypes.Hash32 =
etypes.Hash32(distinctBase(hash))
proc calculateTransactionData(
items: openArray[TypedTransaction]
): (etypes.Hash256, seq[TxOrHash], uint64) =
): (etypes.Hash32, seq[TxOrHash], uint64) =
## returns tuple composed of
## - root of transactions trie
## - list of transactions hashes
@ -101,14 +101,14 @@ proc calculateTransactionData(
let rootHash = tr.state(updateOk = true).expect "hash"
(rootHash, txHashes, txSize)
func blockHeaderSize(payload: ExecutionData, txRoot: etypes.Hash256): uint64 =
func blockHeaderSize(payload: ExecutionData, txRoot: etypes.Hash32): uint64 =
let bh = etypes.BlockHeader(
parentHash: payload.parentHash.asEthHash,
parentHash: payload.parentHash,
ommersHash: etypes.EMPTY_UNCLE_HASH,
coinbase: etypes.EthAddress payload.feeRecipient,
stateRoot: payload.stateRoot.asEthHash,
coinbase: payload.feeRecipient,
stateRoot: payload.stateRoot,
transactionsRoot: txRoot,
receiptsRoot: payload.receiptsRoot.asEthHash,
receiptsRoot: payload.receiptsRoot,
logsBloom: distinctBase(payload.logsBloom).to(Bloom),
difficulty: default(etypes.DifficultyInt),
number: payload.blockNumber.distinctBase,

View File

@ -28,13 +28,13 @@ export
func pp*(b: seq[byte]): string =
b.toHex.pp(hex = true)
func pp*(a: EthAddress): string =
func pp*(a: Address): string =
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"
func pp*(a: openArray[EthAddress]): string =
func pp*(a: openArray[Address]): string =
"[" & a.mapIt(it.pp).join(" ") & "]"
func pp*(a: Bytes8|Bytes32): string =

View File

@ -123,16 +123,14 @@ func pp*(q: openArray[int]; itemsPerLine: int; lineSep: string): string =
func pp*(a: Hash32; collapse = true): string =
if not collapse:
a.data.toHex
elif a == ZERO_HASH256:
"ZERO_HASH256"
elif a == ZERO_HASH32:
"ZERO_HASH32"
elif a == EMPTY_ROOT_HASH:
"EMPTY_ROOT_HASH"
elif a == EMPTY_UNCLE_HASH:
"EMPTY_UNCLE_HASH"
elif a == EMPTY_SHA3:
"EMPTY_SHA3"
elif a == ZERO_HASH256:
"ZERO_HASH256"
else:
"£" & a.data.toHex.join[0..6] & ".." & a.data.toHex.join[56..63]

View File

@ -68,12 +68,12 @@ proc preLoadAristoDb(jKvp: JsonNode): PartStateRef =
ps
proc collectAddresses(node: JsonNode, collect: var HashSet[EthAddress]) =
proc collectAddresses(node: JsonNode, collect: var HashSet[Address]) =
case node.kind:
of JObject:
for k,v in node.pairs:
if k == "address" and v.kind == JString:
collect.incl EthAddress.fromHex v.getStr
collect.incl Address.fromHex v.getStr
else:
v.collectAddresses collect
of JArray:
@ -142,7 +142,7 @@ proc testCreatePortalProof(node: JsonNode, testStatusIMPL: var TestStatus) =
let ps = node["state"].preLoadAristoDb()
# Collect addresses from json structure
var addresses: HashSet[EthAddress]
var addresses: HashSet[Address]
node.collectAddresses addresses
# Convert addresses to valid paths (not all addresses might work)

View File

@ -23,7 +23,7 @@ import
./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 =
for test in fixture:

View File

@ -186,7 +186,7 @@ proc setupEnv(com: CommonRef, signer, ks2: Address, ctx: EthContext): TestEnv =
gasUsed : vmState.cumulativeGasUsed,
timestamp : timeStamp
#extraData: Blob
#mixHash: Hash256
#mixHash: Hash32
#nonce: BlockNonce
)

View File

@ -39,7 +39,7 @@ proc testTxByFork(tx: Transaction, forkData: JsonNode, forkName: string, testSta
return
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 tx.txHash == forkData["hash"].getStr
check tx.recoverSender().expect("valid signature") == sender

View File

@ -58,7 +58,7 @@ var
bcCom: CommonRef
# Accounts to be considered local
localAccounts: seq[EthAddress]
localAccounts: seq[Address]
# ------------------------------------------------------------------------------
# Helpers
@ -342,7 +342,7 @@ proc runTxPoolTests(noisy = false) =
block:
var
xq = bcCom.toTxPool(txList, noisy = noisy)
maxAddr: EthAddress
maxAddr: Address
nAddrItems = 0
nAddrPendingItems = 0

View File

@ -35,12 +35,12 @@ type
TxEnv = object
chainId: ChainID
rng: ref HmacDrbgContext
signers: Table[EthAddress, PrivateKey]
map: Table[EthAddress, EthAddress]
signers: Table[Address, PrivateKey]
map: Table[Address, Address]
txs: seq[Transaction]
Signer = object
address: EthAddress
address: Address
signer: PrivateKey
const
@ -50,7 +50,7 @@ proc initTxEnv(chainId: ChainID): TxEnv =
result.rng = newRng()
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:
let newAddress = val[]
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"
let n = json.parseFile(txFile)
var map: Table[EthAddress, UInt256]
var map: Table[Address, UInt256]
for z in n:
let bytes = hexToSeqByte(z.getStr)
@ -112,7 +112,7 @@ proc toTxPool*(
com: CommonRef; ## to be modified, initialisier for `TxPool`
itList: seq[TxItemRef]; ## import items into new `TxPool` (read only)
baseFee = 0.GasPrice; ## initalise with `baseFee` (unless 0)
local: seq[EthAddress] = @[]; ## local addresses
local: seq[Address] = @[]; ## local addresses
noisy = true): TxPoolRef =
doAssert not com.isNil
@ -122,7 +122,7 @@ proc toTxPool*(
result.maxRejects = itList.len
let noLocals = local.len == 0
var localAddr: Table[EthAddress,bool]
var localAddr: Table[Address,bool]
for a in local:
localAddr[a] = true
@ -145,7 +145,7 @@ proc toTxPool*(
baseFee = 0.GasPrice; ## initalise with `baseFee` (unless 0)
itemsPC = 30; ## % number if items befor time gap
delayMSecs = 200; ## size of time vap
local: seq[EthAddress] = @[]; ## local addresses
local: seq[EAddress] = @[]; ## local addresses
noisy = true): TxPoolRef =
## Variant of `toTxPoolFromSeq()` with a time gap between consecutive
## items on the `remote` queue
@ -157,7 +157,7 @@ proc toTxPool*(
result.maxRejects = itList.len
let noLocals = local.len == 0
var localAddr: Table[EthAddress,bool]
var localAddr: Table[Address,bool]
for a in local:
localAddr[a] = true
@ -209,11 +209,11 @@ proc setItemStatusFromInfo*(xp: TxPoolRef) =
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
## `nAccounts` sender accounts
var
accTab: Table[EthAddress,bool]
accTab: Table[Address,bool]
txsLst: seq[Transaction]
backHash = xp.head.blockHash
backHeader = xp.head

View File

@ -60,7 +60,7 @@ proc testKeySign*(header: BlockHeader): BlockHeader =
## Sign the header and embed the signature in extra data
header.sign(prvTestKey)
proc signerFunc*(signer: EthAddress, msg: openArray[byte]):
proc signerFunc*(signer: Address, msg: openArray[byte]):
Result[array[RawSignatureSize, byte], cstring] {.gcsafe.} =
doAssert(signer == testAddress)
let

View File

@ -14,7 +14,7 @@ import
../../nimbus/db/ledger
proc coinbaseStateClearing*(vmState: BaseVMState,
miner: EthAddress,
miner: Address,
touched = true) =
# This is necessary due to the manner in which the state tests are
# generated. State tests are generated from the BlockChainTest tests

View File

@ -112,9 +112,9 @@ proc fromJson(T: type Authorization, n: JsonNode): Authorization =
chainId: fromJson(ChainId, n, "chainId"),
address: fromJson(Address, n, "address"),
nonce: fromJson(uint64, n, "nonce"),
yParity: fromJson(uint64, n, "yParity"),
R: fromJson(UInt256, n, "R"),
S: fromJson(UInt256, n, "S"),
v: fromJson(uint64, n, "v"),
r: fromJson(UInt256, n, "r"),
s: fromJson(UInt256, n, "s"),
)
proc fromJson(T: type seq[Authorization], n: JsonNode, field: string): T =

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit 470baf82bdbf05dd399881123ae9020b8f117871
Subproject commit 171531fbf1a308c1bf4d2f6b88c6ee6924657437

2
vendor/nimbus-eth2 vendored

@ -1 +1 @@
Subproject commit b8a424991d4f8590f5e5364b18ffeabef72e1ff4
Subproject commit ec0accf29033bbb2fe718c130694c46e54c26387