-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix weight limits in evm tracing runtimes (#3210)
* Improve tracing logs and fix the transaction indexes in evm traces * fix block weight limits in evm tracing runtimes * re-add comment * improve compilation error * small improvement * test weight limits in tracing * disable evm-tracing feature when running unit tests * Revert unecessary changes This reverts commit a58f24a. * update lock file * Add minimal fix * Also reset block weights when tracing a specific transaction
- Loading branch information
Showing
7 changed files
with
144 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
test/suites/tracing-tests/test-trace-filter-weight-limits.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { afterAll, customDevRpcRequest, describeSuite, expect } from "@moonwall/cli"; | ||
import { ALITH_ADDRESS, createEthersTransaction } from "@moonwall/util"; | ||
import { sleep } from "../../helpers"; | ||
import { encodeFunctionData } from "viem"; | ||
|
||
describeSuite({ | ||
id: "T18", | ||
title: "Trace filter - Test block weight limits with evm-tracing enabled", | ||
foundationMethods: "dev", | ||
testCases: ({ context, it }) => { | ||
afterAll(async () => { | ||
await sleep(500); // Add sleep to allow for graceful teardown | ||
}); | ||
|
||
it({ | ||
id: "T01", | ||
title: | ||
"The number of unique transaction traces should be the same as the number of transactions included in a block", | ||
test: async function () { | ||
const { abi, contractAddress } = await context.deployContract!("BloatedContract"); | ||
|
||
let nonce = await context.viem().getTransactionCount({ address: ALITH_ADDRESS }); | ||
const tx = []; | ||
for (let i = 0; i < 500; i++) { | ||
tx.push( | ||
await createEthersTransaction(context, { | ||
to: contractAddress, | ||
data: encodeFunctionData({ abi, functionName: "doSomething", args: [] }), | ||
gasLimit: 10_000_000, | ||
nonce: nonce++, | ||
}) | ||
); | ||
} | ||
|
||
const substrateBlock = await context.createBlock(tx, { allowFailures: false }); | ||
const txHashes = (substrateBlock.result || []) | ||
.filter((result) => result.successful) | ||
.map((result) => result.hash); | ||
|
||
const blockNumber = (await context.polkadotJs().query.ethereum.currentBlock()) | ||
.unwrap() | ||
.header.number.toNumber(); | ||
const blockNumberHex = blockNumber.toString(16); | ||
const ethBlock = await customDevRpcRequest("eth_getBlockByNumber", [blockNumberHex, false]); | ||
|
||
// Confirm that all transactions were included in the ethereum block | ||
expect(ethBlock.transactions.length).to.equal(txHashes.length); | ||
|
||
const traceFilterResponse = await customDevRpcRequest("trace_filter", [ | ||
{ | ||
fromBlock: blockNumberHex, | ||
toBlock: blockNumberHex, | ||
}, | ||
]); | ||
const uniqueTxsInTraces = Object.keys( | ||
traceFilterResponse.reduce( | ||
(prev, cur) => ({ | ||
...prev, | ||
[cur.transactionHash]: true, | ||
}), | ||
{} | ||
) | ||
); | ||
|
||
console.log(` | ||
Ethereum transactions count: ${ethBlock.transactions.length}, | ||
Ethereum traces count: ${traceFilterResponse.length}, | ||
Ethereum unique transactions in traces count: ${uniqueTxsInTraces.length} | ||
`); | ||
|
||
// Assert that all eth transactions were traced | ||
expect(ethBlock.transactions.length).to.equal(uniqueTxsInTraces.length); | ||
}, | ||
}); | ||
}, | ||
}); |