# Nimbus # Copyright (c) 2023-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) # * MIT license ([LICENSE-MIT](LICENSE-MIT) or # http://opensource.org/licenses/MIT) # at your option. This file may not be copied, modified, or distributed except # according to those terms. import std/[tables], eth/common/[keys, transaction_utils], stew/endians2, nimcrypto/sha2, chronicles, ./engine_client, ./cancun/blobs, ../../../nimbus/transaction, ../../../nimbus/common, ../../../nimbus/utils/utils from std/sequtils import mapIt type BaseTx* = object of RootObj recipient* : Opt[Address] gasLimit* : GasInt amount* : UInt256 payload* : seq[byte] txType* : Opt[TxType] gasTip* : GasInt gasFee* : GasInt blobGasFee*: UInt256 blobCount* : int blobID* : BlobID BigInitcodeTx* = object of BaseTx initcodeLength*: int padByte* : uint8 initcode* : seq[byte] # Blob transaction creator BlobTx* = object of BaseTx TestAccount* = object key* : PrivateKey address*: Address index* : int TxSender* = ref object accounts: seq[TestAccount] nonceMap: Table[Address, uint64] txSent : int chainId : ChainId MakeTxParams* = object chainId*: ChainId key* : PrivateKey nonce* : AccountNonce CustSig* = object V*: uint64 R*: UInt256 S*: UInt256 CustomTransactionData* = object nonce* : Opt[uint64] gasPriceOrGasFeeCap*: Opt[GasInt] gasTipCap* : Opt[GasInt] gas* : Opt[GasInt] to* : Opt[common.Address] value* : Opt[UInt256] data* : Opt[seq[byte]] chainId* : Opt[ChainId] signature* : Opt[CustSig] const TestAccountCount = 1000 gasPrice* = 30.gwei gasTipPrice* = 1.gwei blobGasPrice* = 1.gwei func toAddress(key: PrivateKey): Address = toKeyPair(key).pubkey.toCanonicalAddress() proc createAccount(idx: int): TestAccount = let seed = toBytesBE(idx.uint64) seedHash = sha256.digest(seed) result.index = idx result.key = PrivateKey.fromRaw(seedHash.data).valueOr: echo error quit(QuitFailure) result.address = toAddress(result.key) proc createAccounts(sender: TxSender) = for i in 0..