@nomicfoundation/edr 0.12.0-next.5 → 0.12.0-next.7
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 +79 -31
- package/index.js +3 -1
- package/package.json +8 -8
- package/src/chains/generic.rs +1 -2
- package/src/chains/l1.rs +62 -62
- package/src/chains/op.rs +15 -14
- package/src/config.rs +62 -21
- package/src/context.rs +3 -3
- package/src/contract_decoder.rs +57 -0
- package/src/debug_trace.rs +2 -0
- package/src/lib.rs +2 -0
- package/src/log.rs +2 -2
- package/src/mock/time.rs +8 -7
- package/src/mock.rs +2 -10
- package/src/provider/response.rs +4 -4
- package/src/provider.rs +28 -7
- package/src/result.rs +24 -48
- package/src/solidity_tests/config.rs +31 -1
- package/src/solidity_tests/l1.rs +6 -6
- package/src/solidity_tests/op.rs +4 -4
- package/src/solidity_tests/runner.rs +1 -1
- package/src/solidity_tests/test_results.rs +46 -32
- package/src/trace/debug.rs +3 -1
- package/src/trace/exit.rs +9 -8
- package/src/trace/return_data.rs +3 -5
- package/src/trace.rs +5 -4
package/src/solidity_tests/op.rs
CHANGED
|
@@ -34,14 +34,14 @@ impl SyncTestRunnerFactory for OpTestRunnerFactory {
|
|
|
34
34
|
let runner = tokio::task::block_in_place(|| {
|
|
35
35
|
runtime
|
|
36
36
|
.block_on(MultiContractRunner::<
|
|
37
|
-
|
|
37
|
+
edr_op::BlockEnv,
|
|
38
38
|
_,
|
|
39
39
|
OpEvmBuilder,
|
|
40
|
-
edr_op::
|
|
41
|
-
edr_op::
|
|
40
|
+
edr_op::HaltReason,
|
|
41
|
+
edr_op::Hardfork,
|
|
42
42
|
_,
|
|
43
43
|
edr_op::transaction::InvalidTransaction,
|
|
44
|
-
edr_op::transaction::OpTxEnv<
|
|
44
|
+
edr_op::transaction::OpTxEnv<edr_chain_l1::TxEnv>,
|
|
45
45
|
>::new(
|
|
46
46
|
config.try_into()?,
|
|
47
47
|
contracts,
|
|
@@ -42,7 +42,7 @@ pub struct ValueSnapshotEntry {
|
|
|
42
42
|
pub value: String,
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/// See [edr_solidity_tests::result::SuiteResult]
|
|
45
|
+
/// See [`edr_solidity_tests::result::SuiteResult`]
|
|
46
46
|
#[napi]
|
|
47
47
|
#[derive(Clone, Debug)]
|
|
48
48
|
pub struct SuiteResult {
|
|
@@ -50,13 +50,13 @@ pub struct SuiteResult {
|
|
|
50
50
|
/// callback
|
|
51
51
|
#[napi(readonly)]
|
|
52
52
|
pub id: ArtifactId,
|
|
53
|
-
/// See [edr_solidity_tests::result::SuiteResult::duration]
|
|
53
|
+
/// See [`edr_solidity_tests::result::SuiteResult::duration`]
|
|
54
54
|
#[napi(readonly)]
|
|
55
55
|
pub duration_ns: BigInt,
|
|
56
|
-
/// See [edr_solidity_tests::result::SuiteResult::test_results]
|
|
56
|
+
/// See [`edr_solidity_tests::result::SuiteResult::test_results`]
|
|
57
57
|
#[napi(readonly)]
|
|
58
58
|
pub test_results: Vec<TestResult>,
|
|
59
|
-
/// See [edr_solidity_tests::result::SuiteResult::warnings]
|
|
59
|
+
/// See [`edr_solidity_tests::result::SuiteResult::warnings`]
|
|
60
60
|
#[napi(readonly)]
|
|
61
61
|
pub warnings: Vec<String>,
|
|
62
62
|
}
|
|
@@ -80,29 +80,29 @@ impl SuiteResult {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
/// See [edr_solidity_tests::result::TestResult]
|
|
83
|
+
/// See [`edr_solidity_tests::result::TestResult`]
|
|
84
84
|
#[napi]
|
|
85
85
|
#[derive(Clone, Debug)]
|
|
86
86
|
pub struct TestResult {
|
|
87
87
|
/// The name of the test.
|
|
88
88
|
#[napi(readonly)]
|
|
89
89
|
pub name: String,
|
|
90
|
-
/// See [edr_solidity_tests::result::TestResult::status]
|
|
90
|
+
/// See [`edr_solidity_tests::result::TestResult::status`]
|
|
91
91
|
#[napi(readonly)]
|
|
92
92
|
pub status: TestStatus,
|
|
93
|
-
/// See [edr_solidity_tests::result::TestResult::reason]
|
|
93
|
+
/// See [`edr_solidity_tests::result::TestResult::reason`]
|
|
94
94
|
#[napi(readonly)]
|
|
95
95
|
pub reason: Option<String>,
|
|
96
|
-
/// See [edr_solidity_tests::result::TestResult::counterexample]
|
|
96
|
+
/// See [`edr_solidity_tests::result::TestResult::counterexample`]
|
|
97
97
|
#[napi(readonly)]
|
|
98
98
|
pub counterexample: Option<Either<BaseCounterExample, CounterExampleSequence>>,
|
|
99
|
-
/// See [edr_solidity_tests::result::TestResult::decoded_logs]
|
|
99
|
+
/// See [`edr_solidity_tests::result::TestResult::decoded_logs`]
|
|
100
100
|
#[napi(readonly)]
|
|
101
101
|
pub decoded_logs: Vec<String>,
|
|
102
|
-
/// See [edr_solidity_tests::result::TestResult::kind]
|
|
102
|
+
/// See [`edr_solidity_tests::result::TestResult::kind`]
|
|
103
103
|
#[napi(readonly)]
|
|
104
104
|
pub kind: Either3<StandardTestKind, FuzzTestKind, InvariantTestKind>,
|
|
105
|
-
/// See [edr_solidity_tests::result::TestResult::duration]
|
|
105
|
+
/// See [`edr_solidity_tests::result::TestResult::duration`]
|
|
106
106
|
#[napi(readonly)]
|
|
107
107
|
pub duration_ns: BigInt,
|
|
108
108
|
/// Groups of value snapshot entries (incl. gas).
|
|
@@ -335,7 +335,7 @@ impl From<edr_solidity_tests::result::TestStatus> for TestStatus {
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
/// See [edr_solidity_tests::result::TestKind::Standard]
|
|
338
|
+
/// See [`edr_solidity_tests::result::TestKind::Standard`]
|
|
339
339
|
#[napi(object)]
|
|
340
340
|
#[derive(Debug, Clone)]
|
|
341
341
|
pub struct StandardTestKind {
|
|
@@ -344,22 +344,22 @@ pub struct StandardTestKind {
|
|
|
344
344
|
pub consumed_gas: BigInt,
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
/// See [edr_solidity_tests::result::TestKind::Fuzz]
|
|
347
|
+
/// See [`edr_solidity_tests::result::TestKind::Fuzz`]
|
|
348
348
|
#[napi(object)]
|
|
349
349
|
#[derive(Debug, Clone)]
|
|
350
350
|
pub struct FuzzTestKind {
|
|
351
|
-
/// See [edr_solidity_tests::result::TestKind::Fuzz]
|
|
351
|
+
/// See [`edr_solidity_tests::result::TestKind::Fuzz`]
|
|
352
352
|
#[napi(readonly)]
|
|
353
353
|
pub runs: BigInt,
|
|
354
|
-
/// See [edr_solidity_tests::result::TestKind::Fuzz]
|
|
354
|
+
/// See [`edr_solidity_tests::result::TestKind::Fuzz`]
|
|
355
355
|
#[napi(readonly)]
|
|
356
356
|
pub mean_gas: BigInt,
|
|
357
|
-
/// See [edr_solidity_tests::result::TestKind::Fuzz]
|
|
357
|
+
/// See [`edr_solidity_tests::result::TestKind::Fuzz`]
|
|
358
358
|
#[napi(readonly)]
|
|
359
359
|
pub median_gas: BigInt,
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
/// See [edr_solidity_tests::fuzz::FuzzCase]
|
|
362
|
+
/// See [`edr_solidity_tests::fuzz::FuzzCase`]
|
|
363
363
|
#[napi(object)]
|
|
364
364
|
#[derive(Clone)]
|
|
365
365
|
pub struct FuzzCase {
|
|
@@ -383,17 +383,17 @@ impl Debug for FuzzCase {
|
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
-
/// See [edr_solidity_tests::result::TestKind::Invariant]
|
|
386
|
+
/// See [`edr_solidity_tests::result::TestKind::Invariant`]
|
|
387
387
|
#[napi(object)]
|
|
388
388
|
#[derive(Debug, Clone)]
|
|
389
389
|
pub struct InvariantTestKind {
|
|
390
|
-
/// See [edr_solidity_tests::result::TestKind::Invariant]
|
|
390
|
+
/// See [`edr_solidity_tests::result::TestKind::Invariant`]
|
|
391
391
|
#[napi(readonly)]
|
|
392
392
|
pub runs: BigInt,
|
|
393
|
-
/// See [edr_solidity_tests::result::TestKind::Invariant]
|
|
393
|
+
/// See [`edr_solidity_tests::result::TestKind::Invariant`]
|
|
394
394
|
#[napi(readonly)]
|
|
395
395
|
pub calls: BigInt,
|
|
396
|
-
/// See [edr_solidity_tests::result::TestKind::Invariant]
|
|
396
|
+
/// See [`edr_solidity_tests::result::TestKind::Invariant`]
|
|
397
397
|
#[napi(readonly)]
|
|
398
398
|
pub reverts: BigInt,
|
|
399
399
|
}
|
|
@@ -409,26 +409,26 @@ pub struct CounterExampleSequence {
|
|
|
409
409
|
pub sequence: Vec<BaseCounterExample>,
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
/// See [edr_solidity_tests::fuzz::BaseCounterExample]
|
|
412
|
+
/// See [`edr_solidity_tests::fuzz::BaseCounterExample`]
|
|
413
413
|
#[napi(object)]
|
|
414
414
|
#[derive(Clone)]
|
|
415
415
|
pub struct BaseCounterExample {
|
|
416
|
-
/// See [edr_solidity_tests::fuzz::BaseCounterExample::sender]
|
|
416
|
+
/// See [`edr_solidity_tests::fuzz::BaseCounterExample::sender`]
|
|
417
417
|
#[napi(readonly)]
|
|
418
418
|
pub sender: Option<Uint8Array>,
|
|
419
|
-
/// See [edr_solidity_tests::fuzz::BaseCounterExample::addr]
|
|
419
|
+
/// See [`edr_solidity_tests::fuzz::BaseCounterExample::addr`]
|
|
420
420
|
#[napi(readonly)]
|
|
421
421
|
pub address: Option<Uint8Array>,
|
|
422
|
-
/// See [edr_solidity_tests::fuzz::BaseCounterExample::calldata]
|
|
422
|
+
/// See [`edr_solidity_tests::fuzz::BaseCounterExample::calldata`]
|
|
423
423
|
#[napi(readonly)]
|
|
424
424
|
pub calldata: Uint8Array,
|
|
425
|
-
/// See [edr_solidity_tests::fuzz::BaseCounterExample::contract_name]
|
|
425
|
+
/// See [`edr_solidity_tests::fuzz::BaseCounterExample::contract_name`]
|
|
426
426
|
#[napi(readonly)]
|
|
427
427
|
pub contract_name: Option<String>,
|
|
428
|
-
/// See [edr_solidity_tests::fuzz::BaseCounterExample::signature]
|
|
428
|
+
/// See [`edr_solidity_tests::fuzz::BaseCounterExample::signature`]
|
|
429
429
|
#[napi(readonly)]
|
|
430
430
|
pub signature: Option<String>,
|
|
431
|
-
/// See [edr_solidity_tests::fuzz::BaseCounterExample::args]
|
|
431
|
+
/// See [`edr_solidity_tests::fuzz::BaseCounterExample::args`]
|
|
432
432
|
#[napi(readonly)]
|
|
433
433
|
pub args: Option<String>,
|
|
434
434
|
}
|
|
@@ -604,7 +604,10 @@ impl CallTrace {
|
|
|
604
604
|
loop {
|
|
605
605
|
// We will break out of the loop before the stack goes empty.
|
|
606
606
|
let mut item = stack.pop().unwrap();
|
|
607
|
-
let node =
|
|
607
|
+
let node = arena
|
|
608
|
+
.nodes()
|
|
609
|
+
.get(item.arena_index)
|
|
610
|
+
.expect("Arena index should be valid");
|
|
608
611
|
|
|
609
612
|
if item.visited {
|
|
610
613
|
let mut logs = node
|
|
@@ -618,11 +621,20 @@ impl CallTrace {
|
|
|
618
621
|
.iter()
|
|
619
622
|
.filter_map(|ord| match *ord {
|
|
620
623
|
traces::TraceMemberOrder::Log(i) => {
|
|
621
|
-
let log = logs
|
|
624
|
+
let log = logs
|
|
625
|
+
.get_mut(i)
|
|
626
|
+
.expect("Log index should be valid")
|
|
627
|
+
.take()
|
|
628
|
+
.unwrap();
|
|
622
629
|
Some(Either::B(log))
|
|
623
630
|
}
|
|
624
631
|
traces::TraceMemberOrder::Call(i) => {
|
|
625
|
-
let child_trace = item
|
|
632
|
+
let child_trace = item
|
|
633
|
+
.child_traces
|
|
634
|
+
.get_mut(i)
|
|
635
|
+
.expect("Child trace index should be valid")
|
|
636
|
+
.take()
|
|
637
|
+
.unwrap();
|
|
626
638
|
Some(Either::A(child_trace))
|
|
627
639
|
}
|
|
628
640
|
traces::TraceMemberOrder::Step(_) => None,
|
|
@@ -632,7 +644,9 @@ impl CallTrace {
|
|
|
632
644
|
let trace = CallTrace::new(node, children);
|
|
633
645
|
|
|
634
646
|
if let Some(parent_stack_index) = item.parent_stack_index {
|
|
635
|
-
let parent =
|
|
647
|
+
let parent = stack
|
|
648
|
+
.get_mut(parent_stack_index)
|
|
649
|
+
.expect("Parent stack index should be valid");
|
|
636
650
|
parent.child_traces.push(Some(trace));
|
|
637
651
|
} else {
|
|
638
652
|
return trace;
|
package/src/trace/debug.rs
CHANGED
|
@@ -46,7 +46,9 @@ fn print_stack_trace(trace: SolidityStackTrace) -> napi::Result<()> {
|
|
|
46
46
|
})?;
|
|
47
47
|
|
|
48
48
|
let mut value = serde_json::to_value(entry)?;
|
|
49
|
-
|
|
49
|
+
if let Some(obj) = value.as_object_mut() {
|
|
50
|
+
obj.insert("message".to_string(), decoded_error_msg.into());
|
|
51
|
+
}
|
|
50
52
|
Ok(value)
|
|
51
53
|
}
|
|
52
54
|
})
|
package/src/trace/exit.rs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
use std::fmt;
|
|
5
5
|
|
|
6
|
+
use edr_evm_spec::EvmHaltReason;
|
|
6
7
|
use napi_derive::napi;
|
|
7
8
|
|
|
8
9
|
#[napi]
|
|
@@ -50,20 +51,20 @@ impl fmt::Display for ExitCode {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
#[allow(clippy::fallible_impl_from)] // naively ported for now
|
|
53
|
-
impl From<edr_solidity::exit_code::ExitCode<
|
|
54
|
-
fn from(code: edr_solidity::exit_code::ExitCode<
|
|
54
|
+
impl From<edr_solidity::exit_code::ExitCode<EvmHaltReason>> for ExitCode {
|
|
55
|
+
fn from(code: edr_solidity::exit_code::ExitCode<EvmHaltReason>) -> Self {
|
|
55
56
|
use edr_solidity::exit_code::ExitCode;
|
|
56
57
|
|
|
57
58
|
match code {
|
|
58
59
|
ExitCode::Success => Self::SUCCESS,
|
|
59
60
|
ExitCode::Revert => Self::REVERT,
|
|
60
|
-
ExitCode::Halt(
|
|
61
|
-
ExitCode::Halt(
|
|
61
|
+
ExitCode::Halt(EvmHaltReason::OutOfGas(_)) => Self::OUT_OF_GAS,
|
|
62
|
+
ExitCode::Halt(EvmHaltReason::OpcodeNotFound | EvmHaltReason::InvalidFEOpcode
|
|
62
63
|
// Returned when an opcode is not implemented for the hardfork
|
|
63
|
-
|
|
|
64
|
-
ExitCode::Halt(
|
|
65
|
-
ExitCode::Halt(
|
|
66
|
-
ExitCode::Halt(
|
|
64
|
+
| EvmHaltReason::NotActivated) => Self::INVALID_OPCODE,
|
|
65
|
+
ExitCode::Halt(EvmHaltReason::StackUnderflow) => Self::STACK_UNDERFLOW,
|
|
66
|
+
ExitCode::Halt(EvmHaltReason::CreateContractSizeLimit) => Self::CODESIZE_EXCEEDS_MAXIMUM,
|
|
67
|
+
ExitCode::Halt(EvmHaltReason::CreateCollision) => Self::CREATE_COLLISION,
|
|
67
68
|
_ => Self::UNKNOWN_HALT_REASON,
|
|
68
69
|
}
|
|
69
70
|
}
|
package/src/trace/return_data.rs
CHANGED
|
@@ -22,11 +22,9 @@ pub struct ReturnData {
|
|
|
22
22
|
impl ReturnData {
|
|
23
23
|
#[napi(catch_unwind, constructor)]
|
|
24
24
|
pub fn new(value: Uint8Array) -> Self {
|
|
25
|
-
let selector =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
None
|
|
29
|
-
};
|
|
25
|
+
let selector = value
|
|
26
|
+
.get(0..4)
|
|
27
|
+
.map(|selector| selector.try_into().expect("selector is 4 bytes"));
|
|
30
28
|
|
|
31
29
|
Self { value, selector }
|
|
32
30
|
}
|
package/src/trace.rs
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
use std::sync::Arc;
|
|
9
9
|
|
|
10
|
-
use edr_eth::
|
|
10
|
+
use edr_eth::bytecode::opcode::OpCode;
|
|
11
11
|
use edr_evm::trace::BeforeMessage;
|
|
12
|
+
use edr_evm_spec::EvmHaltReason;
|
|
12
13
|
use napi::bindgen_prelude::{BigInt, Either3, Uint8Array};
|
|
13
14
|
use napi_derive::napi;
|
|
14
15
|
|
|
@@ -161,11 +162,11 @@ pub struct TracingMessageResult {
|
|
|
161
162
|
#[napi]
|
|
162
163
|
#[derive(Clone)]
|
|
163
164
|
pub struct RawTrace {
|
|
164
|
-
inner: Arc<edr_evm::trace::Trace<
|
|
165
|
+
inner: Arc<edr_evm::trace::Trace<EvmHaltReason>>,
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
impl From<Arc<edr_evm::trace::Trace<
|
|
168
|
-
fn from(value: Arc<edr_evm::trace::Trace<
|
|
168
|
+
impl From<Arc<edr_evm::trace::Trace<EvmHaltReason>>> for RawTrace {
|
|
169
|
+
fn from(value: Arc<edr_evm::trace::Trace<EvmHaltReason>>) -> Self {
|
|
169
170
|
Self { inner: value }
|
|
170
171
|
}
|
|
171
172
|
}
|