# 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/keys, stew/endians2, nimcrypto/sha2, chronicles, ./engine_client, ./cancun/blobs, ../../../nimbus/transaction, ../../../nimbus/common, ../../../nimbus/utils/utils type BaseTx* = object of RootObj recipient* : Option[EthAddress] gasLimit* : GasInt amount* : UInt256 payload* : seq[byte] txType* : Option[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*: EthAddress index* : int TxSender* = ref object accounts: seq[TestAccount] nonceMap: Table[EthAddress, uint64] txSent : int chainId : ChainID MakeTxParams* = object chainId*: ChainID key* : PrivateKey nonce* : AccountNonce CustSig* = object V*: int64 R*: UInt256 S*: UInt256 CustomTransactionData* = object nonce* : Option[uint64] gasPriceOrGasFeeCap*: Option[GasInt] gasTipCap* : Option[GasInt] gas* : Option[GasInt] to* : Option[common.EthAddress] value* : Option[UInt256] data* : Option[seq[byte]] chainId* : Option[ChainId] signature* : Option[CustSig] const TestAccountCount = 1000 gasPrice* = 30.gwei gasTipPrice* = 1.gwei blobGasPrice* = 1.gwei func toAddress(key: PrivateKey): EthAddress = 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..