mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 21:34:33 +00:00
Wire ForkedChainRef properly to TxPool (#2933)
This commit is contained in:
parent
847cc311eb
commit
2e5ef4fb5a
@ -83,10 +83,9 @@ proc newEngineEnv*(conf: var NimbusConf, chainFile: string, enableAuth: bool): E
|
|||||||
let
|
let
|
||||||
node = setupEthNode(conf, ctx)
|
node = setupEthNode(conf, ctx)
|
||||||
com = makeCom(conf)
|
com = makeCom(conf)
|
||||||
head = com.db.getCanonicalHead().expect("canonical head exists")
|
chain = ForkedChainRef.init(com)
|
||||||
chain = newForkedChain(com, head)
|
|
||||||
|
|
||||||
let txPool = TxPoolRef.new(com)
|
let txPool = TxPoolRef.new(chain)
|
||||||
|
|
||||||
node.addEthHandlerCapability(
|
node.addEthHandlerCapability(
|
||||||
node.peerPool,
|
node.peerPool,
|
||||||
@ -95,7 +94,7 @@ proc newEngineEnv*(conf: var NimbusConf, chainFile: string, enableAuth: bool): E
|
|||||||
|
|
||||||
# txPool must be informed of active head
|
# txPool must be informed of active head
|
||||||
# so it can know the latest account state
|
# so it can know the latest account state
|
||||||
doAssert txPool.smartHead(head, chain)
|
doAssert txPool.smartHead(chain.latestHeader)
|
||||||
|
|
||||||
var key: JwtSharedKey
|
var key: JwtSharedKey
|
||||||
key.fromHex(jwtSecret).isOkOr:
|
key.fromHex(jwtSecret).isOkOr:
|
||||||
|
@ -83,8 +83,9 @@ proc main() =
|
|||||||
conf.networkId,
|
conf.networkId,
|
||||||
conf.networkParams
|
conf.networkParams
|
||||||
)
|
)
|
||||||
|
chain = ForkedChainRef.init(com)
|
||||||
|
txPool = TxPoolRef.new(chain)
|
||||||
|
|
||||||
let txPool = TxPoolRef.new(com)
|
|
||||||
discard importRlpBlock(blocksFile, com)
|
discard importRlpBlock(blocksFile, com)
|
||||||
let ctx = setupGraphqlContext(com, ethNode, txPool)
|
let ctx = setupGraphqlContext(com, ethNode, txPool)
|
||||||
|
|
||||||
@ -94,9 +95,7 @@ proc main() =
|
|||||||
# txPool must be informed of active head
|
# txPool must be informed of active head
|
||||||
# so it can know the latest account state
|
# so it can know the latest account state
|
||||||
# e.g. "sendRawTransaction Nonce too low" case
|
# e.g. "sendRawTransaction Nonce too low" case
|
||||||
let head = com.db.getCanonicalHead()
|
doAssert txPool.smartHead(chain.latestHeader)
|
||||||
let chainRef = newForkedChain(com, head)
|
|
||||||
doAssert txPool.smartHead(head, chainRef)
|
|
||||||
|
|
||||||
for fileName in walkDirRec(
|
for fileName in walkDirRec(
|
||||||
caseFolder, yieldFilter = {pcFile,pcLinkToFile}):
|
caseFolder, yieldFilter = {pcFile,pcLinkToFile}):
|
||||||
|
@ -52,7 +52,7 @@ proc setupELClient*(conf: ChainConfig, node: JsonNode): TestEnv =
|
|||||||
doAssert(head.blockHash == genesisHeader.blockHash)
|
doAssert(head.blockHash == genesisHeader.blockHash)
|
||||||
|
|
||||||
let
|
let
|
||||||
txPool = TxPoolRef.new(com)
|
txPool = TxPoolRef.new(chain)
|
||||||
beaconEngine = BeaconEngineRef.new(txPool, chain)
|
beaconEngine = BeaconEngineRef.new(txPool, chain)
|
||||||
serverApi = newServerAPI(chain, txPool)
|
serverApi = newServerAPI(chain, txPool)
|
||||||
rpcServer = newRpcHttpServer(["127.0.0.1:0"])
|
rpcServer = newRpcHttpServer(["127.0.0.1:0"])
|
||||||
|
@ -87,15 +87,14 @@ proc setupEnv*(): TestEnv =
|
|||||||
|
|
||||||
manageAccounts(ethCtx, conf)
|
manageAccounts(ethCtx, conf)
|
||||||
|
|
||||||
let head = com.db.getCanonicalHead().expect("canonical head exists")
|
let chain = ForkedChainRef.init(com)
|
||||||
let chainRef = newForkedChain(com, head)
|
let txPool = TxPoolRef.new(chain)
|
||||||
let txPool = TxPoolRef.new(com)
|
|
||||||
|
|
||||||
# txPool must be informed of active head
|
# txPool must be informed of active head
|
||||||
# so it can know the latest account state
|
# so it can know the latest account state
|
||||||
doAssert txPool.smartHead(head, chainRef)
|
doAssert txPool.smartHead(chain.latestHeader)
|
||||||
|
|
||||||
let rpcServer = setupRpcServer(ethCtx, com, ethNode, txPool, conf, chainRef)
|
let rpcServer = setupRpcServer(ethCtx, com, ethNode, txPool, conf, chain)
|
||||||
let rpcClient = newRpcHttpClient()
|
let rpcClient = newRpcHttpClient()
|
||||||
waitFor rpcClient.connect("127.0.0.1", Port(8545), false)
|
waitFor rpcClient.connect("127.0.0.1", Port(8545), false)
|
||||||
let stopServer = stopRpcHttpServer
|
let stopServer = stopRpcHttpServer
|
||||||
|
@ -160,7 +160,7 @@ proc generateExecutionBundle*(ben: BeaconEngineRef,
|
|||||||
|
|
||||||
if headBlock.blockHash != xp.head.blockHash:
|
if headBlock.blockHash != xp.head.blockHash:
|
||||||
# reorg
|
# reorg
|
||||||
discard xp.smartHead(headBlock, ben.chain)
|
discard xp.smartHead(headBlock)
|
||||||
|
|
||||||
if pos.timestamp <= headBlock.timestamp:
|
if pos.timestamp <= headBlock.timestamp:
|
||||||
return err "timestamp must be strictly later than parent"
|
return err "timestamp must be strictly later than parent"
|
||||||
|
@ -226,14 +226,11 @@
|
|||||||
## A piece of code using this pool architecture could look like as follows:
|
## A piece of code using this pool architecture could look like as follows:
|
||||||
## ::
|
## ::
|
||||||
## # see also unit test examples, e.g. "Block packer tests"
|
## # see also unit test examples, e.g. "Block packer tests"
|
||||||
## var db: CoreDbRef # to be initialised
|
## var chain: ForkedChainRef # to be initialised
|
||||||
## var txs: seq[Transaction] # to be initialised
|
## var txs: seq[Transaction] # to be initialised
|
||||||
##
|
##
|
||||||
## proc mineThatBlock(blk: EthBlock) # external function
|
|
||||||
##
|
##
|
||||||
## ..
|
## var xq = TxPoolRef.new(chain) # initialise tx-pool
|
||||||
##
|
|
||||||
## var xq = TxPoolRef.new(db) # initialise tx-pool
|
|
||||||
## ..
|
## ..
|
||||||
##
|
##
|
||||||
## xq.add(txs) # add transactions ..
|
## xq.add(txs) # add transactions ..
|
||||||
@ -241,10 +238,6 @@
|
|||||||
##
|
##
|
||||||
## let newBlock = xq.assembleBlock # fetch current mining block
|
## let newBlock = xq.assembleBlock # fetch current mining block
|
||||||
##
|
##
|
||||||
## ..
|
|
||||||
## mineThatBlock(newBlock) ... # external mining & signing process
|
|
||||||
## ..
|
|
||||||
##
|
|
||||||
## xp.smartHead(newBlock.header) # update pool, new insertion point
|
## xp.smartHead(newBlock.header) # update pool, new insertion point
|
||||||
##
|
##
|
||||||
##
|
##
|
||||||
@ -252,7 +245,7 @@
|
|||||||
## ---------------------
|
## ---------------------
|
||||||
## In the example, transactions are processed into buckets via `add()`.
|
## In the example, transactions are processed into buckets via `add()`.
|
||||||
##
|
##
|
||||||
## The `ethBlock()` directive assembles and retrieves a new block for mining
|
## The `assembleBlock()` directive assembles and retrieves a new block for mining
|
||||||
## derived from the current pool state. It invokes the block packer which
|
## derived from the current pool state. It invokes the block packer which
|
||||||
## accumulates txs from the `pending` buscket into the `packed` bucket which
|
## accumulates txs from the `pending` buscket into the `packed` bucket which
|
||||||
## then go into the block.
|
## then go into the block.
|
||||||
@ -389,11 +382,11 @@ proc setHead(xp: TxPoolRef; val: Header)
|
|||||||
# Public constructor/destructor
|
# Public constructor/destructor
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc new*(T: type TxPoolRef; com: CommonRef): T
|
proc new*(T: type TxPoolRef; chain: ForkedChainRef): T
|
||||||
{.gcsafe,raises: [].} =
|
{.gcsafe,raises: [].} =
|
||||||
## Constructor, returns a new tx-pool descriptor.
|
## Constructor, returns a new tx-pool descriptor.
|
||||||
new result
|
new result
|
||||||
result.init(com)
|
result.init(chain)
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Public functions, task manager, pool actions serialiser
|
# Public functions, task manager, pool actions serialiser
|
||||||
@ -422,7 +415,7 @@ proc add*(xp: TxPoolRef; tx: PooledTransaction; info = "")
|
|||||||
## Variant of `add()` for a single transaction.
|
## Variant of `add()` for a single transaction.
|
||||||
xp.add(@[tx], info)
|
xp.add(@[tx], info)
|
||||||
|
|
||||||
proc smartHead*(xp: TxPoolRef; pos: Header, chain: ForkedChainRef): bool
|
proc smartHead*(xp: TxPoolRef; pos: Header): bool
|
||||||
{.gcsafe,raises: [CatchableError].} =
|
{.gcsafe,raises: [CatchableError].} =
|
||||||
## This function moves the internal head cache (i.e. tx insertion point,
|
## This function moves the internal head cache (i.e. tx insertion point,
|
||||||
## vmState) and ponts it to a now block on the chain.
|
## vmState) and ponts it to a now block on the chain.
|
||||||
@ -434,7 +427,7 @@ proc smartHead*(xp: TxPoolRef; pos: Header, chain: ForkedChainRef): bool
|
|||||||
## the internal head cache, the previously calculated actions will be
|
## the internal head cache, the previously calculated actions will be
|
||||||
## applied.
|
## applied.
|
||||||
##
|
##
|
||||||
let rcDiff = xp.headDiff(pos, chain)
|
let rcDiff = xp.headDiff(pos, xp.chain)
|
||||||
if rcDiff.isOk:
|
if rcDiff.isOk:
|
||||||
let changes = rcDiff.value
|
let changes = rcDiff.value
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import
|
|||||||
../../evm/types,
|
../../evm/types,
|
||||||
../../db/ledger,
|
../../db/ledger,
|
||||||
../../constants,
|
../../constants,
|
||||||
|
../../core/chain/forked_chain,
|
||||||
../pow/header,
|
../pow/header,
|
||||||
../eip4844,
|
../eip4844,
|
||||||
../casper,
|
../casper,
|
||||||
@ -56,6 +57,7 @@ type
|
|||||||
|
|
||||||
lifeTime*: times.Duration ## Maximum life time of a tx in the system
|
lifeTime*: times.Duration ## Maximum life time of a tx in the system
|
||||||
priceBump*: uint ## Min precentage price when superseding
|
priceBump*: uint ## Min precentage price when superseding
|
||||||
|
chain*: ForkedChainRef
|
||||||
|
|
||||||
const
|
const
|
||||||
txItemLifeTime = ##\
|
txItemLifeTime = ##\
|
||||||
@ -137,12 +139,12 @@ proc update(xp: TxPoolRef; parent: Header) =
|
|||||||
# Public functions, constructor
|
# Public functions, constructor
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc init*(xp: TxPoolRef; com: CommonRef) =
|
proc init*(xp: TxPoolRef; chain: ForkedChainRef) =
|
||||||
## Constructor, returns new tx-pool descriptor.
|
## Constructor, returns new tx-pool descriptor.
|
||||||
xp.startDate = getTime().utc.toTime
|
xp.startDate = getTime().utc.toTime
|
||||||
|
|
||||||
let head = com.db.getCanonicalHead.expect("Canonicalhead exists")
|
let head = chain.latestHeader
|
||||||
xp.vmState = setupVMState(com, head)
|
xp.vmState = setupVMState(chain.com, head)
|
||||||
xp.txDB = TxTabsRef.new
|
xp.txDB = TxTabsRef.new
|
||||||
|
|
||||||
xp.lifeTime = txItemLifeTime
|
xp.lifeTime = txItemLifeTime
|
||||||
@ -150,6 +152,7 @@ proc init*(xp: TxPoolRef; com: CommonRef) =
|
|||||||
|
|
||||||
xp.param.reset
|
xp.param.reset
|
||||||
xp.param.flags = txPoolFlags
|
xp.param.flags = txPoolFlags
|
||||||
|
xp.chain = chain
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Public functions
|
# Public functions
|
||||||
|
@ -43,13 +43,13 @@ when defined(evmc_enabled):
|
|||||||
proc basicServices(nimbus: NimbusNode,
|
proc basicServices(nimbus: NimbusNode,
|
||||||
conf: NimbusConf,
|
conf: NimbusConf,
|
||||||
com: CommonRef) =
|
com: CommonRef) =
|
||||||
nimbus.txPool = TxPoolRef.new(com)
|
nimbus.chainRef = ForkedChainRef.init(com)
|
||||||
|
|
||||||
# txPool must be informed of active head
|
# txPool must be informed of active head
|
||||||
# so it can know the latest account state
|
# so it can know the latest account state
|
||||||
# e.g. sender nonce, etc
|
# e.g. sender nonce, etc
|
||||||
nimbus.chainRef = ForkedChainRef.init(com)
|
nimbus.txPool = TxPoolRef.new(nimbus.chainRef)
|
||||||
doAssert nimbus.txPool.smartHead(nimbus.chainRef.latestHeader,nimbus.chainRef)
|
doAssert nimbus.txPool.smartHead(nimbus.chainRef.latestHeader)
|
||||||
|
|
||||||
nimbus.beaconEngine = BeaconEngineRef.new(nimbus.txPool, nimbus.chainRef)
|
nimbus.beaconEngine = BeaconEngineRef.new(nimbus.txPool, nimbus.chainRef)
|
||||||
|
|
||||||
|
@ -89,13 +89,12 @@ proc setupEnv(envFork: HardFork = MergeFork,
|
|||||||
|
|
||||||
let
|
let
|
||||||
com = setupCom(conf)
|
com = setupCom(conf)
|
||||||
head = com.db.getCanonicalHead().expect("canonical head exists")
|
|
||||||
chain = ForkedChainRef.init(com)
|
chain = ForkedChainRef.init(com)
|
||||||
txPool = TxPoolRef.new(com)
|
txPool = TxPoolRef.new(chain)
|
||||||
|
|
||||||
# txPool must be informed of active head
|
# txPool must be informed of active head
|
||||||
# so it can know the latest account state
|
# so it can know the latest account state
|
||||||
doAssert txPool.smartHead(head, chain)
|
doAssert txPool.smartHead(chain.latestHeader)
|
||||||
|
|
||||||
let
|
let
|
||||||
server = newRpcHttpServerWithParams("127.0.0.1:0").valueOr:
|
server = newRpcHttpServerWithParams("127.0.0.1:0").valueOr:
|
||||||
|
@ -18,29 +18,23 @@ import
|
|||||||
../nimbus/common/[common, context],
|
../nimbus/common/[common, context],
|
||||||
./test_helpers
|
./test_helpers
|
||||||
|
|
||||||
type
|
|
||||||
EthBlock = object
|
|
||||||
header: BlockHeader
|
|
||||||
transactions: seq[Transaction]
|
|
||||||
uncles: seq[BlockHeader]
|
|
||||||
|
|
||||||
const
|
const
|
||||||
caseFolder = "tests/graphql"
|
caseFolder = "tests/graphql"
|
||||||
dataFolder = "tests/fixtures/eth_tests/BlockchainTests/ValidBlocks/bcUncleTest"
|
dataFolder = "tests/fixtures/eth_tests/BlockchainTests/ValidBlocks/bcUncleTest"
|
||||||
|
|
||||||
proc toBlock(n: JsonNode, key: string): EthBlock =
|
proc toBlock(n: JsonNode, key: string): Block =
|
||||||
let rlpBlob = hexToSeqByte(n[key].str)
|
let rlpBlob = hexToSeqByte(n[key].str)
|
||||||
rlp.decode(rlpBlob, EthBlock)
|
rlp.decode(rlpBlob, Block)
|
||||||
|
|
||||||
proc setupChain(): CommonRef =
|
proc setupChain(): ForkedChainRef =
|
||||||
let config = ChainConfig(
|
let config = ChainConfig(
|
||||||
chainId : MainNet.ChainId,
|
chainId : MainNet.ChainId,
|
||||||
byzantiumBlock : some(0.BlockNumber),
|
byzantiumBlock : Opt.some(0.BlockNumber),
|
||||||
constantinopleBlock : some(0.BlockNumber),
|
constantinopleBlock : Opt.some(0.BlockNumber),
|
||||||
petersburgBlock : some(0.BlockNumber),
|
petersburgBlock : Opt.some(0.BlockNumber),
|
||||||
istanbulBlock : some(0.BlockNumber),
|
istanbulBlock : Opt.some(0.BlockNumber),
|
||||||
muirGlacierBlock : some(0.BlockNumber),
|
muirGlacierBlock : Opt.some(0.BlockNumber),
|
||||||
berlinBlock : some(10.BlockNumber)
|
berlinBlock : Opt.some(10.BlockNumber)
|
||||||
)
|
)
|
||||||
|
|
||||||
var jn = json.parseFile(dataFolder & "/oneUncle.json")
|
var jn = json.parseFile(dataFolder & "/oneUncle.json")
|
||||||
@ -58,48 +52,41 @@ proc setupChain(): CommonRef =
|
|||||||
mixHash : gen.header.mixHash,
|
mixHash : gen.header.mixHash,
|
||||||
coinBase : gen.header.coinbase,
|
coinBase : gen.header.coinbase,
|
||||||
timestamp : gen.header.timestamp,
|
timestamp : gen.header.timestamp,
|
||||||
baseFeePerGas: gen.header.fee
|
baseFeePerGas: gen.header.baseFeePerGas
|
||||||
)
|
)
|
||||||
if not parseGenesisAlloc($(jn["pre"]), genesis.alloc):
|
if not parseGenesisAlloc($(jn["pre"]), genesis.alloc):
|
||||||
quit(QuitFailure)
|
quit(QuitFailure)
|
||||||
|
|
||||||
let customNetwork = NetworkParams(
|
let
|
||||||
config: config,
|
customNetwork = NetworkParams(
|
||||||
genesis: genesis
|
config: config,
|
||||||
)
|
genesis: genesis
|
||||||
|
|
||||||
let com = CommonRef.new(
|
|
||||||
newCoreDbRef DefaultDbMemory, nil,
|
|
||||||
CustomNet,
|
|
||||||
customNetwork
|
|
||||||
)
|
|
||||||
|
|
||||||
let blocks = jn["blocks"]
|
|
||||||
var headers: seq[BlockHeader]
|
|
||||||
var bodies: seq[BlockBody]
|
|
||||||
for n in blocks:
|
|
||||||
let ethBlock = n.toBlock("rlp")
|
|
||||||
headers.add ethBlock.header
|
|
||||||
bodies.add BlockBody(
|
|
||||||
transactions: ethBlock.transactions,
|
|
||||||
uncles: ethBlock.uncles
|
|
||||||
)
|
)
|
||||||
|
com = CommonRef.new(
|
||||||
|
newCoreDbRef DefaultDbMemory,
|
||||||
|
taskpool = nil,
|
||||||
|
CustomNet,
|
||||||
|
customNetwork
|
||||||
|
)
|
||||||
|
chain = ForkedChainRef.init(com)
|
||||||
|
blocks = jn["blocks"]
|
||||||
|
|
||||||
let chain = newChain(com)
|
for n in blocks:
|
||||||
let res = chain.persistBlocks(headers, bodies)
|
let blk = n.toBlock("rlp")
|
||||||
assert res.isOk(), res.error()
|
chain.importBlock(blk).isOkOr:
|
||||||
|
doAssert(false, error)
|
||||||
|
|
||||||
com
|
chain
|
||||||
|
|
||||||
proc graphqlMain*() =
|
proc graphqlMain*() =
|
||||||
let
|
let
|
||||||
conf = makeTestConfig()
|
conf = makeTestConfig()
|
||||||
ethCtx = newEthContext()
|
ethCtx = newEthContext()
|
||||||
ethNode = setupEthNode(conf, ethCtx, eth)
|
ethNode = setupEthNode(conf, ethCtx, eth)
|
||||||
com = setupChain()
|
chain = setupChain()
|
||||||
txPool = TxPoolRef.new(com)
|
txPool = TxPoolRef.new(chain)
|
||||||
|
|
||||||
let ctx = setupGraphqlContext(com, ethNode, txPool)
|
let ctx = setupGraphqlContext(chain.com, ethNode, txPool)
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
ctx.main(caseFolder, purgeSchema = false)
|
ctx.main(caseFolder, purgeSchema = false)
|
||||||
else:
|
else:
|
||||||
|
@ -101,6 +101,7 @@ proc initEnv(): TestEnv =
|
|||||||
conf.networkId,
|
conf.networkId,
|
||||||
conf.networkParams
|
conf.networkParams
|
||||||
)
|
)
|
||||||
|
chain = newForkedChain(com, com.genesisHeader)
|
||||||
|
|
||||||
TestEnv(
|
TestEnv(
|
||||||
com : com,
|
com : com,
|
||||||
@ -108,8 +109,8 @@ proc initEnv(): TestEnv =
|
|||||||
vaultKey: privKey(hexPrivKey),
|
vaultKey: privKey(hexPrivKey),
|
||||||
nonce : 0'u64,
|
nonce : 0'u64,
|
||||||
chainId : conf.networkParams.config.chainId,
|
chainId : conf.networkParams.config.chainId,
|
||||||
xp : TxPoolRef.new(com),
|
xp : TxPoolRef.new(chain),
|
||||||
chain : newForkedChain(com, com.genesisHeader),
|
chain : chain,
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeTx(
|
func makeTx(
|
||||||
@ -334,7 +335,7 @@ proc runLedgerTransactionTests(noisy = true) =
|
|||||||
)
|
)
|
||||||
env.importBlock(Block.init(blk.header, body))
|
env.importBlock(Block.init(blk.header, body))
|
||||||
|
|
||||||
check env.xp.smartHead(blk.header, env.chain)
|
check env.xp.smartHead(blk.header)
|
||||||
for tx in body.transactions:
|
for tx in body.transactions:
|
||||||
env.txs.add tx
|
env.txs.add tx
|
||||||
|
|
||||||
|
@ -245,11 +245,11 @@ proc rpcMain*() =
|
|||||||
let
|
let
|
||||||
env = setupEnv(signer, ks2, ctx, com)
|
env = setupEnv(signer, ks2, ctx, com)
|
||||||
chain = ForkedChainRef.init(com)
|
chain = ForkedChainRef.init(com)
|
||||||
txPool = TxPoolRef.new(com)
|
txPool = TxPoolRef.new(chain)
|
||||||
|
|
||||||
# txPool must be informed of active head
|
# txPool must be informed of active head
|
||||||
# so it can know the latest account state
|
# so it can know the latest account state
|
||||||
doAssert txPool.smartHead(chain.latestHeader, chain)
|
doAssert txPool.smartHead(chain.latestHeader)
|
||||||
|
|
||||||
let
|
let
|
||||||
server = newRpcHttpServerWithParams("127.0.0.1:0").valueOr:
|
server = newRpcHttpServerWithParams("127.0.0.1:0").valueOr:
|
||||||
|
@ -131,7 +131,7 @@ proc initEnv(envFork: HardFork): TestEnv =
|
|||||||
conf: conf,
|
conf: conf,
|
||||||
com: com,
|
com: com,
|
||||||
chain: chain,
|
chain: chain,
|
||||||
xp: TxPoolRef.new(com),
|
xp: TxPoolRef.new(chain),
|
||||||
vaultKey: privKey(vaultKeyHex),
|
vaultKey: privKey(vaultKeyHex),
|
||||||
chainId: conf.networkParams.config.chainId,
|
chainId: conf.networkParams.config.chainId,
|
||||||
nonce: 0'u64,
|
nonce: 0'u64,
|
||||||
@ -262,7 +262,7 @@ proc runTxPoolBlobhashTest() =
|
|||||||
tx4 = env.signTxWithNonce(tx3, AccountNonce(env.nonce - 2))
|
tx4 = env.signTxWithNonce(tx3, AccountNonce(env.nonce - 2))
|
||||||
xp = env.xp
|
xp = env.xp
|
||||||
|
|
||||||
check xp.smartHead(blk.header, chain)
|
check xp.smartHead(blk.header)
|
||||||
xp.add(PooledTransaction(tx: tx4))
|
xp.add(PooledTransaction(tx: tx4))
|
||||||
|
|
||||||
check inPoolAndOk(xp, rlpHash(tx4)) == false
|
check inPoolAndOk(xp, rlpHash(tx4)) == false
|
||||||
@ -318,7 +318,7 @@ proc runTxHeadDelta(noisy = true) =
|
|||||||
# Synchronise TxPool against new chain head, register txs differences.
|
# Synchronise TxPool against new chain head, register txs differences.
|
||||||
# In this particular case, these differences will simply flush the
|
# In this particular case, these differences will simply flush the
|
||||||
# packer bucket.
|
# packer bucket.
|
||||||
check xp.smartHead(blk.header, chain)
|
check xp.smartHead(blk.header)
|
||||||
|
|
||||||
# Move TxPool chain head to new chain head and apply delta jobs
|
# Move TxPool chain head to new chain head and apply delta jobs
|
||||||
check xp.nItems.staged == 0
|
check xp.nItems.staged == 0
|
||||||
@ -362,7 +362,7 @@ proc runGetBlockBodyTest() =
|
|||||||
let blk = r.get.blk
|
let blk = r.get.blk
|
||||||
check env.chain.importBlock(blk).isOk
|
check env.chain.importBlock(blk).isOk
|
||||||
parentHeader = blk.header
|
parentHeader = blk.header
|
||||||
check env.xp.smartHead(parentHeader, env.chain)
|
check env.xp.smartHead(parentHeader)
|
||||||
check blk.transactions.len == 2
|
check blk.transactions.len == 2
|
||||||
|
|
||||||
test "TxPool create second block":
|
test "TxPool create second block":
|
||||||
@ -387,7 +387,7 @@ proc runGetBlockBodyTest() =
|
|||||||
let blk = r.get.blk
|
let blk = r.get.blk
|
||||||
check env.chain.importBlock(blk).isOk
|
check env.chain.importBlock(blk).isOk
|
||||||
currentHeader = blk.header
|
currentHeader = blk.header
|
||||||
check env.xp.smartHead(currentHeader, env.chain)
|
check env.xp.smartHead(currentHeader)
|
||||||
check blk.transactions.len == 3
|
check blk.transactions.len == 3
|
||||||
let currHash = currentHeader.blockHash
|
let currHash = currentHeader.blockHash
|
||||||
check env.chain.forkChoice(currHash, currHash).isOk
|
check env.chain.forkChoice(currHash, currHash).isOk
|
||||||
|
Loading…
x
Reference in New Issue
Block a user