@nomicfoundation/edr 0.12.0-next.2 → 0.12.0-next.20
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 +220 -62
- package/index.js +5 -1
- package/package.json +12 -12
- package/src/account.rs +7 -6
- package/src/block.rs +1 -1
- package/src/call_override.rs +1 -1
- package/src/cast.rs +1 -1
- package/src/chains/generic.rs +27 -20
- package/src/chains/l1.rs +93 -81
- package/src/chains/op.rs +140 -115
- package/src/config.rs +182 -15
- package/src/context.rs +69 -73
- package/src/contract_decoder.rs +57 -0
- package/src/debug_trace.rs +2 -0
- package/src/gas_report.rs +92 -0
- package/src/lib.rs +4 -1
- package/src/log.rs +2 -2
- package/src/logger.rs +4 -2
- package/src/mock/time.rs +134 -0
- package/src/mock.rs +4 -1
- package/src/precompile.rs +7 -7
- package/src/provider/response.rs +4 -4
- package/src/provider.rs +51 -4
- package/src/result.rs +42 -83
- package/src/serde.rs +1 -1
- package/src/solidity_tests/config.rs +93 -19
- package/src/solidity_tests/l1.rs +11 -7
- package/src/solidity_tests/op.rs +11 -8
- package/src/solidity_tests/runner.rs +1 -1
- package/src/solidity_tests/test_results.rs +122 -37
- package/src/solidity_tests.rs +1 -1
- package/src/trace/debug.rs +29 -26
- package/src/trace/exit.rs +9 -8
- package/src/trace/return_data.rs +19 -7
- package/src/trace/solidity_stack_trace.rs +56 -28
- package/src/trace.rs +11 -10
- package/src/withdrawal.rs +5 -5
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
use std::convert::Infallible;
|
|
5
5
|
|
|
6
|
-
use
|
|
7
|
-
use napi::bindgen_prelude::{BigInt,
|
|
6
|
+
use edr_primitives::{hex, U256};
|
|
7
|
+
use napi::bindgen_prelude::{BigInt, Either25, FromNapiValue, ToNapiValue, Uint8Array, Undefined};
|
|
8
8
|
use napi_derive::napi;
|
|
9
9
|
use serde::{Serialize, Serializer};
|
|
10
10
|
|
|
@@ -45,6 +45,7 @@ pub enum StackTraceEntryType {
|
|
|
45
45
|
CONTRACT_TOO_LARGE_ERROR,
|
|
46
46
|
INTERNAL_FUNCTION_CALLSTACK_ENTRY,
|
|
47
47
|
CONTRACT_CALL_RUN_OUT_OF_GAS_ERROR,
|
|
48
|
+
CHEATCODE_ERROR,
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
#[napi(catch_unwind)]
|
|
@@ -155,7 +156,7 @@ pub struct CallstackEntryStackTraceEntry {
|
|
|
155
156
|
|
|
156
157
|
impl From<CallstackEntryStackTraceEntry> for SolidityStackTraceEntry {
|
|
157
158
|
fn from(val: CallstackEntryStackTraceEntry) -> Self {
|
|
158
|
-
|
|
159
|
+
Either25::A(val)
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
|
|
@@ -174,7 +175,7 @@ pub struct UnrecognizedCreateCallstackEntryStackTraceEntry {
|
|
|
174
175
|
|
|
175
176
|
impl From<UnrecognizedCreateCallstackEntryStackTraceEntry> for SolidityStackTraceEntry {
|
|
176
177
|
fn from(val: UnrecognizedCreateCallstackEntryStackTraceEntry) -> Self {
|
|
177
|
-
|
|
178
|
+
Either25::B(val)
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
|
|
@@ -195,7 +196,7 @@ pub struct UnrecognizedContractCallstackEntryStackTraceEntry {
|
|
|
195
196
|
|
|
196
197
|
impl From<UnrecognizedContractCallstackEntryStackTraceEntry> for SolidityStackTraceEntry {
|
|
197
198
|
fn from(val: UnrecognizedContractCallstackEntryStackTraceEntry) -> Self {
|
|
198
|
-
|
|
199
|
+
Either25::C(val)
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
202
|
|
|
@@ -210,7 +211,7 @@ pub struct PrecompileErrorStackTraceEntry {
|
|
|
210
211
|
|
|
211
212
|
impl From<PrecompileErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
212
213
|
fn from(val: PrecompileErrorStackTraceEntry) -> Self {
|
|
213
|
-
|
|
214
|
+
Either25::D(val)
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
|
|
@@ -227,7 +228,7 @@ pub struct RevertErrorStackTraceEntry {
|
|
|
227
228
|
|
|
228
229
|
impl From<RevertErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
229
230
|
fn from(val: RevertErrorStackTraceEntry) -> Self {
|
|
230
|
-
|
|
231
|
+
Either25::E(val)
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
|
|
@@ -243,7 +244,7 @@ pub struct PanicErrorStackTraceEntry {
|
|
|
243
244
|
|
|
244
245
|
impl From<PanicErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
245
246
|
fn from(val: PanicErrorStackTraceEntry) -> Self {
|
|
246
|
-
|
|
247
|
+
Either25::F(val)
|
|
247
248
|
}
|
|
248
249
|
}
|
|
249
250
|
|
|
@@ -259,7 +260,7 @@ pub struct CustomErrorStackTraceEntry {
|
|
|
259
260
|
|
|
260
261
|
impl From<CustomErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
261
262
|
fn from(val: CustomErrorStackTraceEntry) -> Self {
|
|
262
|
-
|
|
263
|
+
Either25::G(val)
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
266
|
|
|
@@ -278,7 +279,7 @@ pub struct FunctionNotPayableErrorStackTraceEntry {
|
|
|
278
279
|
|
|
279
280
|
impl From<FunctionNotPayableErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
280
281
|
fn from(val: FunctionNotPayableErrorStackTraceEntry) -> Self {
|
|
281
|
-
|
|
282
|
+
Either25::H(val)
|
|
282
283
|
}
|
|
283
284
|
}
|
|
284
285
|
|
|
@@ -292,7 +293,7 @@ pub struct InvalidParamsErrorStackTraceEntry {
|
|
|
292
293
|
|
|
293
294
|
impl From<InvalidParamsErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
294
295
|
fn from(val: InvalidParamsErrorStackTraceEntry) -> Self {
|
|
295
|
-
|
|
296
|
+
Either25::I(val)
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
|
|
@@ -311,7 +312,7 @@ pub struct FallbackNotPayableErrorStackTraceEntry {
|
|
|
311
312
|
|
|
312
313
|
impl From<FallbackNotPayableErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
313
314
|
fn from(val: FallbackNotPayableErrorStackTraceEntry) -> Self {
|
|
314
|
-
|
|
315
|
+
Either25::J(val)
|
|
315
316
|
}
|
|
316
317
|
}
|
|
317
318
|
|
|
@@ -332,7 +333,7 @@ pub struct FallbackNotPayableAndNoReceiveErrorStackTraceEntry {
|
|
|
332
333
|
|
|
333
334
|
impl From<FallbackNotPayableAndNoReceiveErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
334
335
|
fn from(val: FallbackNotPayableAndNoReceiveErrorStackTraceEntry) -> Self {
|
|
335
|
-
|
|
336
|
+
Either25::K(val)
|
|
336
337
|
}
|
|
337
338
|
}
|
|
338
339
|
|
|
@@ -351,7 +352,7 @@ pub struct UnrecognizedFunctionWithoutFallbackErrorStackTraceEntry {
|
|
|
351
352
|
|
|
352
353
|
impl From<UnrecognizedFunctionWithoutFallbackErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
353
354
|
fn from(val: UnrecognizedFunctionWithoutFallbackErrorStackTraceEntry) -> Self {
|
|
354
|
-
|
|
355
|
+
Either25::L(val)
|
|
355
356
|
}
|
|
356
357
|
}
|
|
357
358
|
|
|
@@ -369,7 +370,7 @@ pub struct MissingFallbackOrReceiveErrorStackTraceEntry {
|
|
|
369
370
|
|
|
370
371
|
impl From<MissingFallbackOrReceiveErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
371
372
|
fn from(val: MissingFallbackOrReceiveErrorStackTraceEntry) -> Self {
|
|
372
|
-
|
|
373
|
+
Either25::M(val)
|
|
373
374
|
}
|
|
374
375
|
}
|
|
375
376
|
|
|
@@ -386,7 +387,7 @@ pub struct ReturndataSizeErrorStackTraceEntry {
|
|
|
386
387
|
|
|
387
388
|
impl From<ReturndataSizeErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
388
389
|
fn from(val: ReturndataSizeErrorStackTraceEntry) -> Self {
|
|
389
|
-
|
|
390
|
+
Either25::N(val)
|
|
390
391
|
}
|
|
391
392
|
}
|
|
392
393
|
|
|
@@ -404,7 +405,7 @@ pub struct NonContractAccountCalledErrorStackTraceEntry {
|
|
|
404
405
|
|
|
405
406
|
impl From<NonContractAccountCalledErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
406
407
|
fn from(val: NonContractAccountCalledErrorStackTraceEntry) -> Self {
|
|
407
|
-
|
|
408
|
+
Either25::O(val)
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
411
|
|
|
@@ -418,7 +419,7 @@ pub struct CallFailedErrorStackTraceEntry {
|
|
|
418
419
|
|
|
419
420
|
impl From<CallFailedErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
420
421
|
fn from(val: CallFailedErrorStackTraceEntry) -> Self {
|
|
421
|
-
|
|
422
|
+
Either25::P(val)
|
|
422
423
|
}
|
|
423
424
|
}
|
|
424
425
|
|
|
@@ -435,7 +436,7 @@ pub struct DirectLibraryCallErrorStackTraceEntry {
|
|
|
435
436
|
|
|
436
437
|
impl From<DirectLibraryCallErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
437
438
|
fn from(val: DirectLibraryCallErrorStackTraceEntry) -> Self {
|
|
438
|
-
|
|
439
|
+
Either25::Q(val)
|
|
439
440
|
}
|
|
440
441
|
}
|
|
441
442
|
|
|
@@ -455,7 +456,7 @@ pub struct UnrecognizedCreateErrorStackTraceEntry {
|
|
|
455
456
|
|
|
456
457
|
impl From<UnrecognizedCreateErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
457
458
|
fn from(val: UnrecognizedCreateErrorStackTraceEntry) -> Self {
|
|
458
|
-
|
|
459
|
+
Either25::R(val)
|
|
459
460
|
}
|
|
460
461
|
}
|
|
461
462
|
|
|
@@ -477,7 +478,7 @@ pub struct UnrecognizedContractErrorStackTraceEntry {
|
|
|
477
478
|
|
|
478
479
|
impl From<UnrecognizedContractErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
479
480
|
fn from(val: UnrecognizedContractErrorStackTraceEntry) -> Self {
|
|
480
|
-
|
|
481
|
+
Either25::S(val)
|
|
481
482
|
}
|
|
482
483
|
}
|
|
483
484
|
|
|
@@ -494,7 +495,7 @@ pub struct OtherExecutionErrorStackTraceEntry {
|
|
|
494
495
|
|
|
495
496
|
impl From<OtherExecutionErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
496
497
|
fn from(val: OtherExecutionErrorStackTraceEntry) -> Self {
|
|
497
|
-
|
|
498
|
+
Either25::T(val)
|
|
498
499
|
}
|
|
499
500
|
}
|
|
500
501
|
|
|
@@ -512,7 +513,7 @@ pub struct UnmappedSolc063RevertErrorStackTraceEntry {
|
|
|
512
513
|
|
|
513
514
|
impl From<UnmappedSolc063RevertErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
514
515
|
fn from(val: UnmappedSolc063RevertErrorStackTraceEntry) -> Self {
|
|
515
|
-
|
|
516
|
+
Either25::U(val)
|
|
516
517
|
}
|
|
517
518
|
}
|
|
518
519
|
|
|
@@ -529,7 +530,7 @@ pub struct ContractTooLargeErrorStackTraceEntry {
|
|
|
529
530
|
|
|
530
531
|
impl From<ContractTooLargeErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
531
532
|
fn from(val: ContractTooLargeErrorStackTraceEntry) -> Self {
|
|
532
|
-
|
|
533
|
+
Either25::V(val)
|
|
533
534
|
}
|
|
534
535
|
}
|
|
535
536
|
|
|
@@ -548,7 +549,7 @@ pub struct InternalFunctionCallStackEntry {
|
|
|
548
549
|
|
|
549
550
|
impl From<InternalFunctionCallStackEntry> for SolidityStackTraceEntry {
|
|
550
551
|
fn from(val: InternalFunctionCallStackEntry) -> Self {
|
|
551
|
-
|
|
552
|
+
Either25::W(val)
|
|
552
553
|
}
|
|
553
554
|
}
|
|
554
555
|
|
|
@@ -566,7 +567,23 @@ pub struct ContractCallRunOutOfGasError {
|
|
|
566
567
|
|
|
567
568
|
impl From<ContractCallRunOutOfGasError> for SolidityStackTraceEntry {
|
|
568
569
|
fn from(val: ContractCallRunOutOfGasError) -> Self {
|
|
569
|
-
|
|
570
|
+
Either25::X(val)
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
#[napi(object)]
|
|
575
|
+
#[derive(Clone, Serialize)]
|
|
576
|
+
pub struct CheatcodeErrorStackTraceEntry {
|
|
577
|
+
#[napi(js_name = "type", ts_type = "StackTraceEntryType.CHEATCODE_ERROR")]
|
|
578
|
+
pub type_: StackTraceEntryTypeConst<{ StackTraceEntryType::CHEATCODE_ERROR as u8 }>,
|
|
579
|
+
// The parsed cheatcode error message that can be displayed to the user
|
|
580
|
+
pub message: String,
|
|
581
|
+
pub source_reference: SourceReference,
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
impl From<CheatcodeErrorStackTraceEntry> for SolidityStackTraceEntry {
|
|
585
|
+
fn from(val: CheatcodeErrorStackTraceEntry) -> Self {
|
|
586
|
+
Either25::Y(val)
|
|
570
587
|
}
|
|
571
588
|
}
|
|
572
589
|
|
|
@@ -580,7 +597,7 @@ impl From<ContractCallRunOutOfGasError> for SolidityStackTraceEntry {
|
|
|
580
597
|
// Rather, we just bite the bullet for now and use the type alias directly
|
|
581
598
|
// (which falls back to `any` as it's not recognized in the context of the
|
|
582
599
|
// index.d.ts file) until we finish the porting work.
|
|
583
|
-
pub type SolidityStackTraceEntry =
|
|
600
|
+
pub type SolidityStackTraceEntry = Either25<
|
|
584
601
|
CallstackEntryStackTraceEntry,
|
|
585
602
|
UnrecognizedCreateCallstackEntryStackTraceEntry,
|
|
586
603
|
UnrecognizedContractCallstackEntryStackTraceEntry,
|
|
@@ -605,6 +622,7 @@ pub type SolidityStackTraceEntry = Either24<
|
|
|
605
622
|
ContractTooLargeErrorStackTraceEntry,
|
|
606
623
|
InternalFunctionCallStackEntry,
|
|
607
624
|
ContractCallRunOutOfGasError,
|
|
625
|
+
CheatcodeErrorStackTraceEntry,
|
|
608
626
|
>;
|
|
609
627
|
|
|
610
628
|
impl TryCast<SolidityStackTraceEntry> for edr_solidity::solidity_stack_trace::StackTraceEntry {
|
|
@@ -663,6 +681,15 @@ impl TryCast<SolidityStackTraceEntry> for edr_solidity::solidity_stack_trace::St
|
|
|
663
681
|
source_reference: source_reference.map(std::convert::Into::into),
|
|
664
682
|
}
|
|
665
683
|
.into(),
|
|
684
|
+
StackTraceEntry::CheatCodeError {
|
|
685
|
+
message,
|
|
686
|
+
source_reference,
|
|
687
|
+
} => CheatcodeErrorStackTraceEntry {
|
|
688
|
+
type_: StackTraceEntryTypeConst,
|
|
689
|
+
message,
|
|
690
|
+
source_reference: source_reference.into(),
|
|
691
|
+
}
|
|
692
|
+
.into(),
|
|
666
693
|
StackTraceEntry::CustomError {
|
|
667
694
|
message,
|
|
668
695
|
source_reference,
|
|
@@ -821,7 +848,8 @@ const _: () = {
|
|
|
821
848
|
assert_to_from_napi_value::<SolidityStackTraceEntry>();
|
|
822
849
|
};
|
|
823
850
|
|
|
824
|
-
/// Serializes a [`BigInt`] that represents an EVM value as a
|
|
851
|
+
/// Serializes a [`BigInt`] that represents an EVM value as a
|
|
852
|
+
/// [`edr_primitives::U256`].
|
|
825
853
|
fn serialize_evm_value_bigint_using_u256<S>(bigint: &BigInt, s: S) -> Result<S::Ok, S::Error>
|
|
826
854
|
where
|
|
827
855
|
S: Serializer,
|
package/src/trace.rs
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
use std::sync::Arc;
|
|
9
9
|
|
|
10
|
-
use
|
|
11
|
-
use
|
|
10
|
+
use edr_chain_spec::EvmHaltReason;
|
|
11
|
+
use edr_primitives::bytecode::opcode::OpCode;
|
|
12
|
+
use edr_tracing::BeforeMessage;
|
|
12
13
|
use napi::bindgen_prelude::{BigInt, Either3, Uint8Array};
|
|
13
14
|
use napi_derive::napi;
|
|
14
15
|
|
|
@@ -122,7 +123,7 @@ pub struct TracingStep {
|
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
impl TracingStep {
|
|
125
|
-
pub fn new(step: &
|
|
126
|
+
pub fn new(step: &edr_tracing::Step) -> Self {
|
|
126
127
|
let stack = step.stack.full().map_or_else(
|
|
127
128
|
|| {
|
|
128
129
|
step.stack
|
|
@@ -144,7 +145,7 @@ impl TracingStep {
|
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
pub(crate) fn u256_to_bigint(v: &
|
|
148
|
+
pub(crate) fn u256_to_bigint(v: &edr_primitives::U256) -> BigInt {
|
|
148
149
|
BigInt {
|
|
149
150
|
sign_bit: false,
|
|
150
151
|
words: v.into_limbs().to_vec(),
|
|
@@ -161,11 +162,11 @@ pub struct TracingMessageResult {
|
|
|
161
162
|
#[napi]
|
|
162
163
|
#[derive(Clone)]
|
|
163
164
|
pub struct RawTrace {
|
|
164
|
-
inner: Arc<
|
|
165
|
+
inner: Arc<edr_tracing::Trace<EvmHaltReason>>,
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
impl From<Arc<
|
|
168
|
-
fn from(value: Arc<
|
|
168
|
+
impl From<Arc<edr_tracing::Trace<EvmHaltReason>>> for RawTrace {
|
|
169
|
+
fn from(value: Arc<edr_tracing::Trace<EvmHaltReason>>) -> Self {
|
|
169
170
|
Self { inner: value }
|
|
170
171
|
}
|
|
171
172
|
}
|
|
@@ -178,11 +179,11 @@ impl RawTrace {
|
|
|
178
179
|
.messages
|
|
179
180
|
.iter()
|
|
180
181
|
.map(|message| match message {
|
|
181
|
-
|
|
182
|
+
edr_tracing::TraceMessage::Before(message) => {
|
|
182
183
|
Either3::A(TracingMessage::from(message))
|
|
183
184
|
}
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
edr_tracing::TraceMessage::Step(step) => Either3::B(TracingStep::new(step)),
|
|
186
|
+
edr_tracing::TraceMessage::After(message) => Either3::C(TracingMessageResult {
|
|
186
187
|
execution_result: ExecutionResult::from(message),
|
|
187
188
|
}),
|
|
188
189
|
})
|
package/src/withdrawal.rs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
use
|
|
1
|
+
use edr_primitives::Address;
|
|
2
2
|
use napi::bindgen_prelude::{BigInt, Uint8Array};
|
|
3
3
|
use napi_derive::napi;
|
|
4
4
|
|
|
@@ -16,21 +16,21 @@ pub struct Withdrawal {
|
|
|
16
16
|
pub amount: BigInt,
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
impl From<
|
|
20
|
-
fn from(withdrawal:
|
|
19
|
+
impl From<edr_block_header::Withdrawal> for Withdrawal {
|
|
20
|
+
fn from(withdrawal: edr_block_header::Withdrawal) -> Self {
|
|
21
21
|
Self {
|
|
22
22
|
index: BigInt::from(withdrawal.index),
|
|
23
23
|
validator_index: BigInt::from(withdrawal.validator_index),
|
|
24
24
|
address: Uint8Array::with_data_copied(withdrawal.address),
|
|
25
25
|
amount: BigInt {
|
|
26
26
|
sign_bit: false,
|
|
27
|
-
words: withdrawal.amount
|
|
27
|
+
words: vec![withdrawal.amount],
|
|
28
28
|
},
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
impl TryFrom<Withdrawal> for
|
|
33
|
+
impl TryFrom<Withdrawal> for edr_block_header::Withdrawal {
|
|
34
34
|
type Error = napi::Error;
|
|
35
35
|
|
|
36
36
|
fn try_from(value: Withdrawal) -> Result<Self, Self::Error> {
|