@nomicfoundation/edr 0.12.0-next.1 → 0.12.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +4 -5
- package/package.json +24 -20
- package/src/context.rs +30 -19
- package/src/solidity_tests/test_results.rs +7 -9
- package/src/ts/solidity_tests.ts +46 -0
- package/Cargo.toml +0 -92
- package/build.rs +0 -3
package/index.d.ts
CHANGED
|
@@ -982,11 +982,10 @@ export interface CallTrace {
|
|
|
982
982
|
gasUsed: bigint
|
|
983
983
|
/** The amount of native token that was included with the call. */
|
|
984
984
|
value: bigint
|
|
985
|
-
/**
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
contract: string
|
|
985
|
+
/** The target address of the call. */
|
|
986
|
+
address: string
|
|
987
|
+
/** The name of the contract that is the target of the call, if known. */
|
|
988
|
+
contract?: string
|
|
990
989
|
/**
|
|
991
990
|
* The input (calldata) to the call. If it encodes a known function call,
|
|
992
991
|
* it will be decoded into the function name and a list of arguments.
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomicfoundation/edr",
|
|
3
|
-
"version": "0.12.0-next.
|
|
3
|
+
"version": "0.12.0-next.2",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@napi-rs/cli": "^2.18.4",
|
|
6
6
|
"@nomicfoundation/ethereumjs-util": "^9.0.4",
|
|
7
|
+
"@tsconfig/node20": "^20.1.6",
|
|
7
8
|
"@types/chai": "^4.2.0",
|
|
8
9
|
"@types/chai-as-promised": "^7.1.8",
|
|
9
10
|
"@types/mocha": ">=9.1.0",
|
|
@@ -25,14 +26,17 @@
|
|
|
25
26
|
"typescript": "~5.8.2"
|
|
26
27
|
},
|
|
27
28
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
29
|
+
"node": ">= 20"
|
|
30
|
+
},
|
|
31
|
+
"exports": {
|
|
32
|
+
".": "./index.js",
|
|
33
|
+
"./solidity-tests": "./dist/src/ts/solidity_tests.js"
|
|
29
34
|
},
|
|
30
35
|
"files": [
|
|
31
36
|
"index.js",
|
|
32
37
|
"index.d.ts",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"src/"
|
|
38
|
+
"src/",
|
|
39
|
+
"dist/src/"
|
|
36
40
|
],
|
|
37
41
|
"license": "MIT",
|
|
38
42
|
"main": "index.js",
|
|
@@ -54,31 +58,31 @@
|
|
|
54
58
|
"repository": "NomicFoundation/edr.git",
|
|
55
59
|
"types": "index.d.ts",
|
|
56
60
|
"optionalDependencies": {
|
|
57
|
-
"@nomicfoundation/edr-darwin-arm64": "0.12.0-next.
|
|
58
|
-
"@nomicfoundation/edr-darwin-x64": "0.12.0-next.
|
|
59
|
-
"@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.
|
|
60
|
-
"@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.
|
|
61
|
-
"@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.
|
|
62
|
-
"@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.
|
|
63
|
-
"@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.
|
|
61
|
+
"@nomicfoundation/edr-darwin-arm64": "0.12.0-next.2",
|
|
62
|
+
"@nomicfoundation/edr-darwin-x64": "0.12.0-next.2",
|
|
63
|
+
"@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.2",
|
|
64
|
+
"@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.2",
|
|
65
|
+
"@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.2",
|
|
66
|
+
"@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.2",
|
|
67
|
+
"@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.2"
|
|
64
68
|
},
|
|
65
69
|
"scripts": {
|
|
66
70
|
"artifacts": "napi artifacts",
|
|
67
71
|
"build": "pnpm run build:publish",
|
|
68
|
-
"build:debug": "
|
|
69
|
-
"build:dev": "
|
|
70
|
-
"build:publish": "
|
|
71
|
-
"build:scenarios": "
|
|
72
|
-
"build:tracing": "
|
|
73
|
-
"build:typingFile": "
|
|
72
|
+
"build:debug": "bash ../../scripts/build_edr_napi.sh --features op",
|
|
73
|
+
"build:dev": "bash ../../scripts/build_edr_napi.sh --release --features op,test-mock",
|
|
74
|
+
"build:publish": "bash ../../scripts/build_edr_napi.sh --profile napi-publish --features op",
|
|
75
|
+
"build:scenarios": "bash ../../scripts/build_edr_napi.sh --release --features op,scenarios",
|
|
76
|
+
"build:tracing": "bash ../../scripts/build_edr_napi.sh --release --features op,tracing",
|
|
77
|
+
"build:typingFile": "bash ../../scripts/build_edr_napi.sh --features op",
|
|
74
78
|
"clean": "rm -rf @nomicfoundation/edr.node",
|
|
75
79
|
"eslint": "eslint 'test/**/*.ts'",
|
|
76
80
|
"lint": "pnpm run prettier && pnpm run eslint",
|
|
77
81
|
"lint:fix": "pnpm run prettier --write",
|
|
78
82
|
"pretest": "pnpm build:dev",
|
|
79
83
|
"prettier": "prettier --check \"test/**.ts\"",
|
|
80
|
-
"test": "
|
|
81
|
-
"testNoBuild": "
|
|
84
|
+
"test": "node --max-old-space-size=8192 node_modules/mocha/bin/_mocha --recursive \"test/**/*.ts\"",
|
|
85
|
+
"testNoBuild": "node --max-old-space-size=8192 node_modules/mocha/bin/_mocha --recursive \"test/**/{,!(mock)}.ts\"",
|
|
82
86
|
"universal": "napi universal",
|
|
83
87
|
"version": "napi version"
|
|
84
88
|
}
|
package/src/context.rs
CHANGED
|
@@ -281,11 +281,12 @@ impl EdrContext {
|
|
|
281
281
|
|
|
282
282
|
let include_traces = config.include_traces.into();
|
|
283
283
|
|
|
284
|
+
let runtime_for_factory = runtime.clone();
|
|
284
285
|
let test_runner = try_or_reject_deferred!(runtime
|
|
285
286
|
.clone()
|
|
286
287
|
.spawn_blocking(move || {
|
|
287
288
|
factory.create_test_runner(
|
|
288
|
-
|
|
289
|
+
runtime_for_factory,
|
|
289
290
|
config,
|
|
290
291
|
contracts,
|
|
291
292
|
linking_output.known_contracts,
|
|
@@ -297,28 +298,38 @@ impl EdrContext {
|
|
|
297
298
|
.await
|
|
298
299
|
.expect("Failed to join test runner factory thread"));
|
|
299
300
|
|
|
300
|
-
let
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
301
|
+
let runtime_for_runner = runtime.clone();
|
|
302
|
+
let () = try_or_reject_deferred!(runtime
|
|
303
|
+
.clone()
|
|
304
|
+
.spawn_blocking(move || {
|
|
305
|
+
test_runner.run_tests(
|
|
306
|
+
runtime_for_runner,
|
|
307
|
+
test_filter,
|
|
308
|
+
Arc::new(
|
|
309
|
+
move |SuiteResultAndArtifactId {
|
|
310
|
+
artifact_id,
|
|
311
|
+
result,
|
|
312
|
+
}| {
|
|
313
|
+
let suite_result =
|
|
314
|
+
SuiteResult::new(artifact_id, result, include_traces);
|
|
315
|
+
|
|
316
|
+
let status = on_test_suite_completed_callback
|
|
317
|
+
.call(suite_result, ThreadsafeFunctionCallMode::Blocking);
|
|
318
|
+
|
|
319
|
+
// This should always succeed since we're using an unbounded queue.
|
|
320
|
+
// We add an assertion for
|
|
321
|
+
// completeness.
|
|
322
|
+
assert_eq!(
|
|
315
323
|
status,
|
|
316
324
|
napi::Status::Ok,
|
|
317
325
|
"Failed to call on_test_suite_completed_callback with status: {status}"
|
|
318
326
|
);
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
327
|
+
},
|
|
328
|
+
),
|
|
329
|
+
)
|
|
330
|
+
})
|
|
331
|
+
.await
|
|
332
|
+
.expect("Failed to join test runner thread"));
|
|
322
333
|
|
|
323
334
|
deferred.resolve(move |_env| Ok(()));
|
|
324
335
|
});
|
|
@@ -470,9 +470,10 @@ pub struct CallTrace {
|
|
|
470
470
|
pub gas_used: BigInt,
|
|
471
471
|
/// The amount of native token that was included with the call.
|
|
472
472
|
pub value: BigInt,
|
|
473
|
-
/// The target of the call.
|
|
474
|
-
|
|
475
|
-
|
|
473
|
+
/// The target address of the call.
|
|
474
|
+
pub address: String,
|
|
475
|
+
/// The name of the contract that is the target of the call, if known.
|
|
476
|
+
pub contract: Option<String>,
|
|
476
477
|
/// The input (calldata) to the call. If it encodes a known function call,
|
|
477
478
|
/// it will be decoded into the function name and a list of arguments.
|
|
478
479
|
/// For example, `{ name: "ownerOf", arguments: ["1"] }`. Note that the
|
|
@@ -541,12 +542,8 @@ impl CallTrace {
|
|
|
541
542
|
/// Instantiates a `CallTrace` with the details from a node and the supplied
|
|
542
543
|
/// children.
|
|
543
544
|
fn new(node: &traces::CallTraceNode, children: Vec<Either<CallTrace, LogTrace>>) -> Self {
|
|
544
|
-
let contract = node
|
|
545
|
-
|
|
546
|
-
.decoded
|
|
547
|
-
.label
|
|
548
|
-
.clone()
|
|
549
|
-
.unwrap_or(node.trace.address.to_checksum(None));
|
|
545
|
+
let contract = node.trace.decoded.label.clone();
|
|
546
|
+
let address = node.trace.address.to_checksum(None);
|
|
550
547
|
|
|
551
548
|
let inputs = match &node.trace.decoded.call_data {
|
|
552
549
|
Some(traces::DecodedCallData { signature, args }) => {
|
|
@@ -579,6 +576,7 @@ impl CallTrace {
|
|
|
579
576
|
gas_used: node.trace.gas_used.into(),
|
|
580
577
|
value: u256_to_bigint(&node.trace.value),
|
|
581
578
|
contract,
|
|
579
|
+
address,
|
|
582
580
|
inputs,
|
|
583
581
|
outputs,
|
|
584
582
|
children,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { StandardTestKind, FuzzTestKind, InvariantTestKind } from "../../index";
|
|
2
|
+
|
|
3
|
+
export enum SortOrder {
|
|
4
|
+
Ascending,
|
|
5
|
+
Descending,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface GasUsageFilter {
|
|
9
|
+
minThreshold?: bigint;
|
|
10
|
+
maxThreshold?: bigint;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function extractGasUsage(
|
|
14
|
+
testResults: {
|
|
15
|
+
name: string;
|
|
16
|
+
kind: StandardTestKind | FuzzTestKind | InvariantTestKind;
|
|
17
|
+
}[],
|
|
18
|
+
filter?: GasUsageFilter,
|
|
19
|
+
ordering?: SortOrder
|
|
20
|
+
): { name: string; gas: bigint }[] {
|
|
21
|
+
const gasUsage: { name: string; gas: bigint }[] = [];
|
|
22
|
+
|
|
23
|
+
for (const result of testResults) {
|
|
24
|
+
// Default to zero gas for invariant tests
|
|
25
|
+
const gas = "consumedGas" in result.kind
|
|
26
|
+
? result.kind.consumedGas
|
|
27
|
+
: "medianGas" in result.kind
|
|
28
|
+
? result.kind.medianGas
|
|
29
|
+
: BigInt(0);
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
(!filter?.minThreshold || gas >= filter.minThreshold) &&
|
|
33
|
+
(!filter?.maxThreshold || gas <= filter.maxThreshold)
|
|
34
|
+
) {
|
|
35
|
+
gasUsage.push({ name: result.name, gas });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (ordering === SortOrder.Ascending) {
|
|
40
|
+
gasUsage.sort((a, b) => (a.gas < b.gas ? -1 : a.gas > b.gas ? 1 : 0));
|
|
41
|
+
} else if (ordering === SortOrder.Descending) {
|
|
42
|
+
gasUsage.sort((a, b) => (a.gas > b.gas ? -1 : a.gas < b.gas ? 1 : 0));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return gasUsage;
|
|
46
|
+
}
|
package/Cargo.toml
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "edr_napi"
|
|
3
|
-
version.workspace = true
|
|
4
|
-
edition.workspace = true
|
|
5
|
-
|
|
6
|
-
[lib]
|
|
7
|
-
crate-type = ["cdylib"]
|
|
8
|
-
|
|
9
|
-
[dependencies]
|
|
10
|
-
alloy-dyn-abi.workspace = true
|
|
11
|
-
alloy-json-abi.workspace = true
|
|
12
|
-
alloy-sol-types.workspace = true
|
|
13
|
-
derive_more.workspace = true
|
|
14
|
-
derive-where.workspace = true
|
|
15
|
-
edr_coverage.workspace = true
|
|
16
|
-
edr_defaults = { path = "../edr_defaults" }
|
|
17
|
-
edr_eth = { path = "../edr_eth" }
|
|
18
|
-
edr_evm = { path = "../edr_evm" }
|
|
19
|
-
edr_generic = { path = "../edr_generic" }
|
|
20
|
-
edr_instrument = { path = "../edr_instrument" }
|
|
21
|
-
edr_napi_core = { path = "../edr_napi_core" }
|
|
22
|
-
edr_op = { path = "../edr_op", optional = true }
|
|
23
|
-
edr_provider = { path = "../edr_provider" }
|
|
24
|
-
edr_rpc_client = { path = "../edr_rpc_client" }
|
|
25
|
-
edr_scenarios = { version = "0.3.5", path = "../edr_scenarios", optional = true }
|
|
26
|
-
edr_solidity = { version = "0.3.5", path = "../edr_solidity" }
|
|
27
|
-
k256 = { version = "0.13.1", default-features = false, features = [
|
|
28
|
-
"arithmetic",
|
|
29
|
-
"ecdsa",
|
|
30
|
-
"pkcs8",
|
|
31
|
-
] }
|
|
32
|
-
mimalloc = { version = "0.1.39", default-features = false, features = [
|
|
33
|
-
"local_dynamic_tls",
|
|
34
|
-
] }
|
|
35
|
-
# The `async` feature ensures that a tokio runtime is available
|
|
36
|
-
napi = { version = "2.16.17", default-features = false, features = [
|
|
37
|
-
"async",
|
|
38
|
-
"error_anyhow",
|
|
39
|
-
"napi8",
|
|
40
|
-
"serde-json",
|
|
41
|
-
] }
|
|
42
|
-
napi-derive = "2.16.13"
|
|
43
|
-
rand = { version = "0.8.4", optional = true }
|
|
44
|
-
semver = "1.0.22"
|
|
45
|
-
serde.workspace = true
|
|
46
|
-
serde_json.workspace = true
|
|
47
|
-
static_assertions = "1.1.0"
|
|
48
|
-
strum = { version = "0.26.0", features = ["derive"] }
|
|
49
|
-
thiserror = { version = "1.0.37", default-features = false }
|
|
50
|
-
tracing = { version = "0.1.37", default-features = false, features = ["std"] }
|
|
51
|
-
tracing-flame = { version = "0.2.0", default-features = false, features = [
|
|
52
|
-
"smallvec",
|
|
53
|
-
] }
|
|
54
|
-
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
|
|
55
|
-
"ansi",
|
|
56
|
-
"env-filter",
|
|
57
|
-
"fmt",
|
|
58
|
-
"parking_lot",
|
|
59
|
-
"smallvec",
|
|
60
|
-
"std",
|
|
61
|
-
] }
|
|
62
|
-
|
|
63
|
-
# Solidity tests
|
|
64
|
-
edr_solidity_tests.workspace = true
|
|
65
|
-
foundry-cheatcodes.workspace = true
|
|
66
|
-
foundry-compilers.workspace = true
|
|
67
|
-
edr_common.workspace = true
|
|
68
|
-
tempfile = "3.10.1"
|
|
69
|
-
|
|
70
|
-
[target.x86_64-unknown-linux-gnu.dependencies]
|
|
71
|
-
openssl-sys = { version = "0.9.93", features = ["vendored"] }
|
|
72
|
-
|
|
73
|
-
[target.x86_64-unknown-linux-musl.dependencies]
|
|
74
|
-
openssl-sys = { version = "0.9.93", features = ["vendored"] }
|
|
75
|
-
|
|
76
|
-
[target.aarch64-unknown-linux-gnu.dependencies]
|
|
77
|
-
openssl-sys = { version = "0.9.93", features = ["vendored"] }
|
|
78
|
-
|
|
79
|
-
[target.aarch64-unknown-linux-musl.dependencies]
|
|
80
|
-
openssl-sys = { version = "0.9.93", features = ["vendored"] }
|
|
81
|
-
|
|
82
|
-
[build-dependencies]
|
|
83
|
-
napi-build = "2.0.1"
|
|
84
|
-
|
|
85
|
-
[features]
|
|
86
|
-
op = ["dep:edr_op"]
|
|
87
|
-
scenarios = ["dep:edr_scenarios", "dep:rand"]
|
|
88
|
-
tracing = ["edr_evm/tracing", "edr_napi_core/tracing", "edr_provider/tracing"]
|
|
89
|
-
test-mock = []
|
|
90
|
-
|
|
91
|
-
[lints]
|
|
92
|
-
workspace = true
|
package/build.rs
DELETED