commit
95f6711304
|
@ -445,11 +445,11 @@ proc processAddressPortsList(v: string,
|
|||
var tas4: seq[TransportAddress]
|
||||
var tas6: seq[TransportAddress]
|
||||
try:
|
||||
tas4 = resolveTAddress(item, IpAddressFamily.IPv4)
|
||||
tas4 = resolveTAddress(item, AddressFamily.IPv4)
|
||||
except CatchableError:
|
||||
discard
|
||||
try:
|
||||
tas6 = resolveTAddress(item, IpAddressFamily.IPv6)
|
||||
tas6 = resolveTAddress(item, AddressFamily.IPv6)
|
||||
except CatchableError:
|
||||
discard
|
||||
if len(tas4) == 0 and len(tas6) == 0:
|
||||
|
@ -672,7 +672,6 @@ proc processNetArguments(key, value: string): ConfigStatus =
|
|||
error "Invalid genesis block config file format", invalidFileName=value
|
||||
result = ErrorIncorrectOption
|
||||
except:
|
||||
var exceptionType = getCurrentException()
|
||||
var msg = getCurrentExceptionMsg()
|
||||
error "Error loading genesis block config file", invalidFileName=msg
|
||||
result = Error
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
{.used.}
|
||||
|
||||
import
|
||||
eth/common, nimcrypto/hash
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import
|
|||
tables, hashes, sets,
|
||||
eth/[common, rlp], eth/trie/[hexary, db, trie_defs],
|
||||
../constants, ../utils, storage_types,
|
||||
../../stateless/[witness_types, multi_keys]
|
||||
../../stateless/multi_keys
|
||||
|
||||
type
|
||||
AccountFlag = enum
|
||||
|
|
|
@ -49,8 +49,8 @@ proc start(nimbus: NimbusNode) =
|
|||
{.gcsafe.}:
|
||||
let registry = defaultRegistry
|
||||
info "metrics", registry
|
||||
addTimer(Moment.fromNow(conf.debug.logMetricsInterval.seconds), logMetrics)
|
||||
addTimer(Moment.fromNow(conf.debug.logMetricsInterval.seconds), logMetrics)
|
||||
discard setTimer(Moment.fromNow(conf.debug.logMetricsInterval.seconds), logMetrics)
|
||||
discard setTimer(Moment.fromNow(conf.debug.logMetricsInterval.seconds), logMetrics)
|
||||
|
||||
## Creating RPC Server
|
||||
if RpcFlags.Enabled in conf.rpc.flags:
|
||||
|
@ -162,6 +162,7 @@ proc process*(nimbus: NimbusNode) =
|
|||
poll()
|
||||
except CatchableError as e:
|
||||
debug "Exception in poll()", exc = e.name, err = e.msg
|
||||
discard e # silence warning when chronicles not activated
|
||||
|
||||
# Stop loop
|
||||
waitFor nimbus.stop()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ../db/db_chain, eth/common, chronicles, ../vm_state, ../vm_types,
|
||||
../vm/[computation, message], ../vm/interpreter/vm_forks, stint, nimcrypto,
|
||||
../utils, eth/trie/db, ../tracer, ./executor, ../config, ../genesis, ../utils,
|
||||
../utils, eth/trie/db, ./executor, ../config, ../genesis, ../utils,
|
||||
stew/endians2
|
||||
|
||||
type
|
||||
|
|
|
@ -28,7 +28,7 @@ import
|
|||
|
||||
# Work around for https://github.com/nim-lang/Nim/issues/8645
|
||||
proc `%`*(value: Time): JsonNode =
|
||||
result = %value.toSeconds
|
||||
result = %value.toUnix
|
||||
|
||||
template balance(addressDb: ReadOnlyStateDb, address: EthAddress): GasInt =
|
||||
# TODO: Account balance u256 but GasInt is int64?
|
||||
|
@ -107,7 +107,6 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) =
|
|||
# TODO: Requires PeerPool to check sync state.
|
||||
# TODO: Use variant objects
|
||||
var
|
||||
res: JsonNode
|
||||
sync: SyncState
|
||||
if true:
|
||||
# TODO: Populate sync state, this is a placeholder
|
||||
|
@ -237,20 +236,19 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) =
|
|||
## data: address.
|
||||
## message: message to sign.
|
||||
## Returns signature.
|
||||
let accountDb = getAccountDb(chain.getCanonicalHead())
|
||||
var privateKey: PrivateKey # TODO: Get from key store
|
||||
result = ("0x" & sign(privateKey, message.string)).HexDataStr
|
||||
|
||||
proc setupTransaction(send: EthSend): Transaction =
|
||||
let
|
||||
source = send.source.toAddress
|
||||
destination = send.to.toAddress
|
||||
data = nimcrypto.utils.fromHex(send.data.string)
|
||||
contractCreation = false # TODO: Check if has code
|
||||
v = 0.byte # TODO
|
||||
r = 0.u256
|
||||
s = 0.u256
|
||||
result = initTransaction(send.nonce, send.gasPrice, send.gas, destination, send.value, data, v, r, s, contractCreation)
|
||||
# proc setupTransaction(send: EthSend): Transaction =
|
||||
# let
|
||||
# source = send.source.toAddress
|
||||
# destination = send.to.toAddress
|
||||
# data = nimcrypto.utils.fromHex(send.data.string)
|
||||
# contractCreation = false # TODO: Check if has code
|
||||
# v = 0.byte # TODO
|
||||
# r = 0.u256
|
||||
# s = 0.u256
|
||||
# result = initTransaction(send.nonce, send.gasPrice, send.gas, destination, send.value, data, v, r, s, contractCreation)
|
||||
|
||||
rpcsrv.rpc("eth_sendTransaction") do(obj: EthSend) -> HexDataStr:
|
||||
## Creates new message call transaction or a contract creation, if the data field contains code.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import
|
||||
times,
|
||||
eth/common, stint,
|
||||
times, eth/common, stint,
|
||||
../constants, ../config
|
||||
|
||||
const
|
||||
|
|
|
@ -7,15 +7,18 @@
|
|||
|
||||
import
|
||||
chronicles, strformat, macros, options, times,
|
||||
sets, eth/[common, keys], eth/trie/db as triedb,
|
||||
sets, eth/[common, keys],
|
||||
../constants, ../errors, ../vm_state, ../vm_types,
|
||||
./interpreter/[opcode_values, gas_meter, gas_costs, vm_forks],
|
||||
./code_stream, ./memory, ./message, ./stack, ../db/[accounts_cache, db_chain],
|
||||
../utils/header, stew/[byteutils, ranges/ptr_arith], precompiles,
|
||||
../utils/header, precompiles,
|
||||
transaction_tracer, ../utils
|
||||
|
||||
when defined(chronicles_log_level):
|
||||
import stew/byteutils
|
||||
|
||||
when defined(evmc_enabled):
|
||||
import evmc/evmc, evmc_helpers, evmc_api
|
||||
import evmc/evmc, evmc_helpers, evmc_api, stew/ranges/ptr_arith
|
||||
|
||||
logScope:
|
||||
topics = "vm computation"
|
||||
|
|
|
@ -30,7 +30,7 @@ proc hostAccountExistsImpl(ctx: Computation, address: EthAddress): bool {.cdecl.
|
|||
db.accountExists(address)
|
||||
|
||||
proc hostGetStorageImpl(ctx: Computation, address: EthAddress, key: var evmc_bytes32): evmc_bytes32 {.cdecl.} =
|
||||
ctx.vmState.accountDB.getStorage(address, Uint256.fromEvmc(key))[0].toEvmc()
|
||||
ctx.vmState.accountDB.getStorage(address, Uint256.fromEvmc(key)).toEvmc()
|
||||
|
||||
proc hostSetStorageImpl(ctx: Computation, address: EthAddress,
|
||||
key, value: var evmc_bytes32): evmc_storage_status {.cdecl.} =
|
||||
|
@ -38,7 +38,7 @@ proc hostSetStorageImpl(ctx: Computation, address: EthAddress,
|
|||
slot = Uint256.fromEvmc(key)
|
||||
newValue = Uint256.fromEvmc(value)
|
||||
statedb = ctx.vmState.readOnlyStateDb
|
||||
currValue = statedb.getStorage(address, slot)[0]
|
||||
currValue = statedb.getStorage(address, slot)
|
||||
|
||||
assert address == ctx.msg.contractAddress
|
||||
|
||||
|
@ -100,7 +100,7 @@ proc hostCopyCodeImpl(ctx: Computation, address: EthAddress,
|
|||
let maxToCopy = code.len - codeOffset
|
||||
let numToCopy = min(maxToCopy, bufferSize)
|
||||
if numToCopy > 0:
|
||||
copyMem(bufferData, code.slice(codeOffset).baseAddr, numToCopy)
|
||||
copyMem(bufferData, code[codeOffset].addr, numToCopy)
|
||||
result = numToCopy
|
||||
|
||||
proc hostSelfdestructImpl(ctx: Computation, address, beneficiary: EthAddress) {.cdecl.} =
|
||||
|
|
|
@ -219,7 +219,7 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
|
|||
|
||||
when defined(evmc_enabled):
|
||||
const
|
||||
sstoreLoad = FeeSchedule[GasSload]
|
||||
sstoreLoad {.used.} = FeeSchedule[GasSload]
|
||||
sstoreSet = FeeSchedule[GasSset]
|
||||
sstoreReset= FeeSchedule[GasSreset]
|
||||
sstoreDirty= when fork < FkConstantinople or fork == FkPetersburg: sstoreReset
|
||||
|
|
|
@ -429,20 +429,21 @@ op sload, inline = true, slot:
|
|||
## 0x54, Load word from storage.
|
||||
push: c.getStorage(slot)
|
||||
|
||||
template sstoreImpl(c: Computation, slot, newValue: Uint256) =
|
||||
let currentValue {.inject.} = c.getStorage(slot)
|
||||
when not evmc_enabled:
|
||||
template sstoreImpl(c: Computation, slot, newValue: Uint256) =
|
||||
let currentValue {.inject.} = c.getStorage(slot)
|
||||
|
||||
let
|
||||
gasParam = GasParams(kind: Op.Sstore, s_isStorageEmpty: currentValue.isZero)
|
||||
(gasCost, gasRefund) = c.gasCosts[Sstore].c_handler(newValue, gasParam)
|
||||
let
|
||||
gasParam = GasParams(kind: Op.Sstore, s_isStorageEmpty: currentValue.isZero)
|
||||
(gasCost, gasRefund) = c.gasCosts[Sstore].c_handler(newValue, gasParam)
|
||||
|
||||
c.gasMeter.consumeGas(gasCost, &"SSTORE: {c.msg.contractAddress}[{slot}] -> {newValue} ({currentValue})")
|
||||
c.gasMeter.consumeGas(gasCost, &"SSTORE: {c.msg.contractAddress}[{slot}] -> {newValue} ({currentValue})")
|
||||
|
||||
if gasRefund > 0:
|
||||
c.gasMeter.refundGas(gasRefund)
|
||||
if gasRefund > 0:
|
||||
c.gasMeter.refundGas(gasRefund)
|
||||
|
||||
c.vmState.mutateStateDB:
|
||||
db.setStorage(c.msg.contractAddress, slot, newValue)
|
||||
c.vmState.mutateStateDB:
|
||||
db.setStorage(c.msg.contractAddress, slot, newValue)
|
||||
|
||||
when evmc_enabled:
|
||||
template sstoreEvmc(c: Computation, slot, newValue: Uint256) =
|
||||
|
@ -462,25 +463,26 @@ op sstore, inline = false, slot, newValue:
|
|||
else:
|
||||
sstoreImpl(c, slot, newValue)
|
||||
|
||||
template sstoreNetGasMeteringImpl(c: Computation, slot, newValue: Uint256) =
|
||||
let stateDB = c.vmState.readOnlyStateDB
|
||||
let currentValue {.inject.} = c.getStorage(slot)
|
||||
when not evmc_enabled:
|
||||
template sstoreNetGasMeteringImpl(c: Computation, slot, newValue: Uint256) =
|
||||
let stateDB = c.vmState.readOnlyStateDB
|
||||
let currentValue {.inject.} = c.getStorage(slot)
|
||||
|
||||
let
|
||||
gasParam = GasParams(kind: Op.Sstore,
|
||||
s_isStorageEmpty: currentValue.isZero,
|
||||
s_currentValue: currentValue,
|
||||
s_originalValue: stateDB.getCommittedStorage(c.msg.contractAddress, slot)
|
||||
)
|
||||
(gasCost, gasRefund) = c.gasCosts[Sstore].c_handler(newValue, gasParam)
|
||||
let
|
||||
gasParam = GasParams(kind: Op.Sstore,
|
||||
s_isStorageEmpty: currentValue.isZero,
|
||||
s_currentValue: currentValue,
|
||||
s_originalValue: stateDB.getCommittedStorage(c.msg.contractAddress, slot)
|
||||
)
|
||||
(gasCost, gasRefund) = c.gasCosts[Sstore].c_handler(newValue, gasParam)
|
||||
|
||||
c.gasMeter.consumeGas(gasCost, &"SSTORE EIP2200: {c.msg.contractAddress}[{slot}] -> {newValue} ({currentValue})")
|
||||
c.gasMeter.consumeGas(gasCost, &"SSTORE EIP2200: {c.msg.contractAddress}[{slot}] -> {newValue} ({currentValue})")
|
||||
|
||||
if gasRefund != 0:
|
||||
c.gasMeter.refundGas(gasRefund)
|
||||
if gasRefund != 0:
|
||||
c.gasMeter.refundGas(gasRefund)
|
||||
|
||||
c.vmState.mutateStateDB:
|
||||
db.setStorage(c.msg.contractAddress, slot, newValue)
|
||||
c.vmState.mutateStateDB:
|
||||
db.setStorage(c.msg.contractAddress, slot, newValue)
|
||||
|
||||
op sstoreEIP2200, inline = false, slot, newValue:
|
||||
checkInStaticContext(c)
|
||||
|
|
|
@ -9,9 +9,8 @@ import
|
|||
tables, macros,
|
||||
chronicles,
|
||||
./interpreter/[opcode_values, opcodes_impl, vm_forks, gas_costs, gas_meter, utils/macros_gen_opcodes],
|
||||
./code_stream,
|
||||
../vm_types, ../errors, precompiles,
|
||||
./stack, terminal # Those are only needed for logging
|
||||
./code_stream, ../vm_types, ../errors, precompiles, ./stack,
|
||||
terminal # Those are only needed for logging
|
||||
|
||||
logScope:
|
||||
topics = "vm opcode"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
chronicles, strformat, strutils, sequtils, macros, eth/[rlp, common], nimcrypto,
|
||||
chronicles, strformat, strutils, sequtils, macros, eth/common, nimcrypto,
|
||||
../errors, ../validation
|
||||
|
||||
logScope:
|
||||
|
@ -130,6 +130,6 @@ proc `[]`*(stack: Stack, i: BackwardsIndex, T: typedesc): T =
|
|||
proc peekInt*(stack: Stack): UInt256 =
|
||||
ensurePop(stack, 1)
|
||||
fromStackElement(stack.values[^1], result)
|
||||
|
||||
|
||||
proc top*(stack: Stack, value: uint | int | GasInt | UInt256 | EthAddress | Hash256) {.inline.} =
|
||||
toStackElement(value, stack.values[^1])
|
||||
|
|
|
@ -11,7 +11,7 @@ import
|
|||
vm/interpreter/[vm_forks, gas_costs], ./errors,
|
||||
./constants, ./db/[db_chain, accounts_cache],
|
||||
./utils, json, vm_types, vm/transaction_tracer,
|
||||
./config, ../stateless/[multi_keys, witness_from_tree, witness_types]
|
||||
./config, ../stateless/[witness_from_tree, witness_types]
|
||||
|
||||
proc newAccessLogs*: AccessLogs =
|
||||
AccessLogs(reads: initTable[string, string](), writes: initTable[string, string]())
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
tables, eth/common, eth/trie/db,
|
||||
tables, eth/common,
|
||||
options, json, sets,
|
||||
./vm/[memory, stack, code_stream],
|
||||
./vm/interpreter/[gas_costs, opcode_values, vm_forks], # TODO - will be hidden at a lower layer
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
import
|
||||
configuration, stint, eth/common,
|
||||
../nimbus/db/[storage_types, db_chain, select_backend, capturedb],
|
||||
eth/trie/[hexary, db, trie_defs], ../nimbus/p2p/executor,
|
||||
../nimbus/db/[db_chain, select_backend, capturedb],
|
||||
eth/trie/[hexary, db], ../nimbus/p2p/executor,
|
||||
../nimbus/[tracer, vm_state]
|
||||
|
||||
proc dumpDebug(chainDB: BaseChainDB, blockNumber: Uint256) =
|
||||
|
@ -27,12 +27,12 @@ proc dumpDebug(chainDB: BaseChainDB, blockNumber: Uint256) =
|
|||
vmState = newBaseVMState(parent.stateRoot, header, captureChainDB)
|
||||
|
||||
captureChainDB.setHead(parent, true)
|
||||
let validationResult = processBlock(captureChainDB, header, body, vmState)
|
||||
discard processBlock(captureChainDB, header, body, vmState)
|
||||
|
||||
transaction.rollback()
|
||||
dumpDebuggingMetaData(captureChainDB, header, body, vmState, false)
|
||||
|
||||
proc main() =
|
||||
proc main() {.used.} =
|
||||
let conf = getConfiguration()
|
||||
let db = newChainDb(conf.dataDir)
|
||||
let trieDB = trieDB db
|
||||
|
|
|
@ -6,7 +6,6 @@ import
|
|||
|
||||
const
|
||||
emptyCodeHash = blankStringHash
|
||||
emptyStorageHash = emptyRlpHash
|
||||
|
||||
proc store(memoryDB: TrieDatabaseRef, branch: JsonNode) =
|
||||
for p in branch:
|
||||
|
@ -106,7 +105,7 @@ proc huntProblematicBlock(blockNumber: Uint256): ValidationResult =
|
|||
|
||||
result = validationResult
|
||||
|
||||
proc main() =
|
||||
proc main() {.used.} =
|
||||
let conf = getConfiguration()
|
||||
|
||||
if conf.head == 0.u256:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import
|
||||
eth/[common, rlp], stint,
|
||||
chronicles, downloader, configuration,
|
||||
../nimbus/[errors, config]
|
||||
../nimbus/errors
|
||||
|
||||
import
|
||||
eth/trie/[hexary, db],
|
||||
|
@ -21,7 +21,7 @@ template persistToDb(db: ChainDB, body: untyped) =
|
|||
when manualCommit:
|
||||
if not db.txCommit(): doAssert(false)
|
||||
|
||||
proc main() =
|
||||
proc main() {.used.} =
|
||||
# 97 block with uncles
|
||||
# 46147 block with first transaction
|
||||
# 46400 block with transaction
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import
|
||||
json, downloader, stint, strutils, os,
|
||||
../nimbus/tracer, chronicles, prestate,
|
||||
js_tracer, eth/common, stew/byteutils, parser,
|
||||
nimcrypto, premixcore
|
||||
eth/common, premixcore
|
||||
|
||||
proc generateGethData(thisBlock: Block, blockNumber: Uint256, accounts: JsonNode): JsonNode =
|
||||
let
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import
|
||||
json, downloader, stint, eth/trie/db, stew/byteutils,
|
||||
json, stint, eth/trie/db, stew/byteutils,
|
||||
../nimbus/db/[db_chain, storage_types], eth/[rlp, common],
|
||||
../nimbus/p2p/chain, ../nimbus/tracer
|
||||
../nimbus/tracer
|
||||
|
||||
proc generatePrestate*(nimbus, geth: JsonNode, blockNumber: Uint256, parent, header: BlockHeader, body: BlockBody) =
|
||||
let
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import
|
||||
eth/[common, rlp], stint, stew/byteutils,
|
||||
nimcrypto, chronicles, configuration,
|
||||
eth/trie/[hexary, db, trie_defs]
|
||||
eth/[common, rlp], stint,
|
||||
chronicles, configuration,
|
||||
eth/trie/[hexary, db]
|
||||
|
||||
import
|
||||
../nimbus/db/[storage_types, db_chain, select_backend],
|
||||
../nimbus/[utils, vm_state, errors],
|
||||
../nimbus/db/[db_chain, select_backend],
|
||||
../nimbus/vm_state,
|
||||
../nimbus/p2p/executor
|
||||
|
||||
const
|
||||
|
@ -41,7 +41,7 @@ proc validateBlock(chainDB: BaseChainDB, blockNumber: BlockNumber): BlockNumber
|
|||
transaction.rollback()
|
||||
result = blockNumber + numBlocks.u256
|
||||
|
||||
proc main() =
|
||||
proc main() {.used.} =
|
||||
let
|
||||
conf = getConfiguration()
|
||||
db = newChainDb(conf.dataDir)
|
||||
|
|
|
@ -129,18 +129,21 @@ proc runTest(filePath, fileName: string) =
|
|||
check root == t.rootHash
|
||||
check t.error == false
|
||||
except ParsingError, ContractCodeError:
|
||||
echo "Exception detected ", getCurrentExceptionMsg()
|
||||
# echo "Exception detected ", getCurrentExceptionMsg()
|
||||
check t.error == true
|
||||
|
||||
proc writeFuzzData(filePath, fileName: string) =
|
||||
var testStatusIMPL: TestStatus
|
||||
let t = parseTester(filePath, testStatusIMPL)
|
||||
|
||||
# this block below check the parsed json
|
||||
var db = newMemoryDB()
|
||||
var tb = initTreeBuilder(t.output, db, {wfEIP170})
|
||||
let root = tb.buildTree()
|
||||
discard tb.buildTree()
|
||||
|
||||
writeFile(filename, t.output)
|
||||
|
||||
proc fuzzTool(): bool =
|
||||
proc fuzzTool(): bool {.used.} =
|
||||
var filename: string
|
||||
var numArg = 0
|
||||
|
||||
|
|
|
@ -103,11 +103,12 @@ proc safeReadByte(t: var TreeBuilder): byte =
|
|||
else:
|
||||
raise newException(ParsingError, "Cannot read byte from input stream")
|
||||
|
||||
proc safeReadU32(t: var TreeBuilder): uint32 =
|
||||
if t.readable(4):
|
||||
result = fromBytesBE(uint32, t.read(4))
|
||||
else:
|
||||
raise newException(ParsingError, "Cannot read U32 from input stream")
|
||||
when defined(debugHash):
|
||||
proc safeReadU32(t: var TreeBuilder): uint32 =
|
||||
if t.readable(4):
|
||||
result = fromBytesBE(uint32, t.read(4))
|
||||
else:
|
||||
raise newException(ParsingError, "Cannot read U32 from input stream")
|
||||
|
||||
template safeReadEnum(t: var TreeBuilder, T: type): untyped =
|
||||
let typ = t.safeReadByte.int
|
||||
|
|
|
@ -54,11 +54,12 @@ proc rlpListToBitmask(r: var Rlp): uint =
|
|||
template write(wb: var WitnessBuilder, x: untyped) =
|
||||
wb.output.write(x)
|
||||
|
||||
proc writeU32Impl(wb: var WitnessBuilder, x: uint32) =
|
||||
wb.write(toBytesBE(x))
|
||||
when defined(debugHash):
|
||||
proc writeU32Impl(wb: var WitnessBuilder, x: uint32) =
|
||||
wb.write(toBytesBE(x))
|
||||
|
||||
template writeU32(wb: var WitnessBuilder, x: untyped) =
|
||||
wb.writeU32Impl(uint32(x))
|
||||
template writeU32(wb: var WitnessBuilder, x: untyped) =
|
||||
wb.writeU32Impl(uint32(x))
|
||||
|
||||
template writeByte(wb: var WitnessBuilder, x: untyped) =
|
||||
wb.write(byte(x))
|
||||
|
|
|
@ -86,6 +86,8 @@ macro cliBuilder(stmtList: typed): untyped =
|
|||
# repeatedly until all sub-tests are executed.
|
||||
# you can execute the sub-test by a number start from zero.
|
||||
|
||||
{. warning[UnusedImport]:off .}
|
||||
|
||||
cliBuilder:
|
||||
import ./test_code_stream,
|
||||
./test_gas_meter,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import
|
||||
macrocache, strutils, unittest2,
|
||||
stew/byteutils, chronicles, stew/ranges, eth/common,
|
||||
stew/byteutils, chronicles, eth/common,
|
||||
../nimbus/vm/interpreter/opcode_values,
|
||||
stew/shims/macros, ../nimbus/config
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import
|
||||
json, os, eth/common, stint, chronicles, stew/byteutils, nimcrypto, eth/rlp,
|
||||
eth/trie/db, ../nimbus/db/[db_chain, capturedb, storage_types, select_backend],
|
||||
../nimbus/[tracer, vm_types, config],
|
||||
json, eth/common, stint, chronicles, eth/rlp,
|
||||
eth/trie/db, ../nimbus/db/[db_chain, capturedb, select_backend],
|
||||
../nimbus/[tracer, config],
|
||||
../nimbus/p2p/chain
|
||||
|
||||
proc dumpTest(chainDB: BaseChainDB, blockNumber: int) =
|
||||
|
@ -34,7 +34,7 @@ proc dumpTest(chainDB: BaseChainDB, blockNumber: int) =
|
|||
metaData.dumpMemoryDB(memoryDB)
|
||||
writeFile("block" & $blockNumber & ".json", metaData.pretty())
|
||||
|
||||
proc main() =
|
||||
proc main() {.used.} =
|
||||
# 97 block with uncles
|
||||
# 46147 block with first transaction
|
||||
# 46400 block with transaction
|
||||
|
|
|
@ -715,7 +715,6 @@ proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus, debugMode = fal
|
|||
var tester = parseTester(fixture, testStatusIMPL)
|
||||
var chainDB = newBaseChainDB(newMemoryDb(), pruneTrie = test_config.getConfiguration().pruning)
|
||||
|
||||
echo "TESTING: ", fixtureName
|
||||
if not tester.good: continue
|
||||
|
||||
var vmState = newBaseVMState(emptyRlpHash,
|
||||
|
@ -741,7 +740,7 @@ proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus, debugMode = fal
|
|||
if latestBlockHash != tester.lastBlockHash:
|
||||
verifyStateDB(fixture["postState"], tester.vmState.readOnlyStateDB)
|
||||
except ValidationError as E:
|
||||
echo "ERROR: ", E.msg
|
||||
echo fixtureName, " ERROR: ", E.msg
|
||||
success = false
|
||||
|
||||
if tester.debugMode:
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import
|
||||
unittest2, strutils, tables, json, times, os, sets,
|
||||
stew/ranges/typedranges, nimcrypto, options,
|
||||
nimcrypto, options,
|
||||
eth/[rlp, common], eth/trie/[db, trie_defs], chronicles,
|
||||
./test_helpers, ./test_allowed_to_fail,
|
||||
../nimbus/p2p/executor, test_config,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import
|
||||
os, macros, json, strformat, strutils, parseutils, os, tables,
|
||||
stew/byteutils, stew/ranges/typedranges, net, eth/[common, keys, rlp, p2p], unittest2,
|
||||
stew/byteutils, net, eth/[common, keys, rlp, p2p], unittest2,
|
||||
testutils/markdown_reports,
|
||||
../nimbus/[config, transaction, utils, errors],
|
||||
../nimbus/vm/interpreter/vm_forks,
|
||||
|
@ -103,8 +103,8 @@ proc jsonTestImpl*(inputFolder, outputName: string, handler, skipTest: NimNode):
|
|||
status[last][name] = Status.Skip
|
||||
skip()
|
||||
else:
|
||||
when not paralleliseTests:
|
||||
echo filename
|
||||
# when not paralleliseTests:
|
||||
# echo filename
|
||||
`handler`(fixtures, `testStatusIMPL`)
|
||||
if `testStatusIMPL` == OK:
|
||||
status[last][name] = Status.OK
|
||||
|
|
|
@ -46,7 +46,7 @@ proc memoryMain*() =
|
|||
# var mem = memory32()
|
||||
# mem.write(startPosition = 0.u256, size = pow(2.u256, 256), value = @[1.byte, 0.byte])
|
||||
|
||||
test "write rejects valyes beyond memory size":
|
||||
test "write rejects values beyond memory size":
|
||||
expect(ValidationError):
|
||||
var mem = memory128()
|
||||
mem.write(startPos = 128, value = @[1.byte, 0.byte, 1.byte, 0.byte])
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import
|
||||
macro_assembler, unittest2, macros,
|
||||
stew/byteutils, eth/common, stew/ranges
|
||||
stew/byteutils, eth/common
|
||||
|
||||
proc opCustomMain*() =
|
||||
suite "Custom Opcodes Test":
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import
|
||||
macro_assembler, unittest2, macros,
|
||||
stew/byteutils, eth/common, ../nimbus/db/state_db,
|
||||
../nimbus/db/db_chain, stew/ranges
|
||||
../nimbus/db/db_chain
|
||||
|
||||
proc opEnvMain*() =
|
||||
suite "Environmental Information Opcodes":
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import
|
||||
macro_assembler, unittest2, macros,
|
||||
stew/byteutils, eth/common, stew/ranges
|
||||
stew/byteutils, eth/common
|
||||
|
||||
proc opMiscMain*() =
|
||||
suite "Misc Opcodes":
|
||||
|
|
|
@ -46,7 +46,7 @@ template doTest(fixture: JsonNode, address: byte, action: untyped): untyped =
|
|||
data: data
|
||||
)
|
||||
computation = newComputation(vmState, message)
|
||||
echo "Running ", action.astToStr, " - ", test["name"]
|
||||
# echo "Running ", action.astToStr, " - ", test["name"]
|
||||
`action`(computation)
|
||||
let c = computation.output == expected
|
||||
if not c: echo "Output : " & computation.output.toHex & "\nExpected: " & expected.toHex
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import unittest2, eth/trie/[hexary, db],
|
||||
../nimbus/db/state_db, stew/byteutils, eth/common,
|
||||
stew/ranges
|
||||
../nimbus/db/state_db, stew/byteutils, eth/common
|
||||
|
||||
include ../nimbus/db/accounts_cache
|
||||
|
||||
|
@ -17,16 +16,16 @@ func initAddr(z: int): EthAddress =
|
|||
proc stateDBMain*() =
|
||||
suite "Account State DB":
|
||||
setup:
|
||||
const emptyAcc = newAccount()
|
||||
const emptyAcc {.used.} = newAccount()
|
||||
|
||||
var
|
||||
memDB = newMemoryDB()
|
||||
acDB = newMemoryDB()
|
||||
acDB {.used.} = newMemoryDB()
|
||||
trie = initHexaryTrie(memDB)
|
||||
stateDB = newAccountStateDB(memDB, trie.rootHash, true)
|
||||
address = hexToByteArray[20]("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6")
|
||||
code = hexToSeqByte("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6")
|
||||
rootHash: KeccakHash
|
||||
stateDB {.used.} = newAccountStateDB(memDB, trie.rootHash, true)
|
||||
address {.used.} = hexToByteArray[20]("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6")
|
||||
code {.used.} = hexToSeqByte("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6")
|
||||
rootHash {.used.} : KeccakHash
|
||||
|
||||
test "accountExists and isDeadAccount":
|
||||
check stateDB.accountExists(address) == false
|
||||
|
@ -146,9 +145,9 @@ proc stateDBMain*() =
|
|||
var addr2 = initAddr(2)
|
||||
ac.setCode(addr2, code)
|
||||
ac.persist()
|
||||
check ac.getCode(addr2) == code
|
||||
let key = contractHashKey(hexary.keccak(code))
|
||||
check ac.getCode(addr2) == code
|
||||
let key = contractHashKey(hexary.keccak(code))
|
||||
check acDB.get(key.toOpenArray) == code
|
||||
|
||||
|
||||
when isMainModule:
|
||||
stateDBMain()
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import
|
||||
unittest2, strformat, strutils, tables, json, os, times, sequtils,
|
||||
stew/byteutils, stew/ranges/typedranges, eth/[rlp, common], eth/trie/db,
|
||||
stew/byteutils, eth/[rlp, common], eth/trie/db,
|
||||
./test_helpers, ./test_allowed_to_fail, ../nimbus/vm/interpreter,
|
||||
../nimbus/[constants, vm_state, vm_types, utils],
|
||||
../nimbus/db/[db_chain]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import
|
||||
json, os, eth/common, stint, chronicles, stew/byteutils, nimcrypto,
|
||||
json, eth/common, stint, chronicles,
|
||||
eth/trie/db, ../nimbus/db/[db_chain, capturedb, select_backend],
|
||||
../nimbus/[tracer, vm_types, config]
|
||||
|
||||
|
@ -33,7 +33,7 @@ proc dumpTest(chainDB: BaseChainDB, blockNumber: int) =
|
|||
metaData.dumpMemoryDB(memoryDB)
|
||||
writeFile("block" & $blockNumber & ".json", metaData.pretty())
|
||||
|
||||
proc main() =
|
||||
proc main() {.used.} =
|
||||
# 97 block with uncles
|
||||
# 46147 block with first transaction
|
||||
# 46400 block with transaction
|
||||
|
|
Loading…
Reference in New Issue