@nomicfoundation/edr 0.12.0-next.8 → 0.12.0
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/coverage.sol +38 -0
- package/dist/src/ts/coverage.d.ts +6 -0
- package/dist/src/ts/coverage.d.ts.map +1 -0
- package/dist/src/ts/coverage.js +51 -0
- package/dist/src/ts/coverage.js.map +1 -0
- package/index.d.ts +267 -27
- package/index.js +5 -2
- package/package.json +23 -12
- package/src/account.rs +0 -124
- package/src/block.rs +0 -28
- package/src/call_override.rs +0 -116
- package/src/cast.rs +0 -165
- package/src/chains/generic.rs +0 -58
- package/src/chains/l1.rs +0 -268
- package/src/chains/op.rs +0 -424
- package/src/chains.rs +0 -7
- package/src/config.rs +0 -700
- package/src/context.rs +0 -447
- package/src/contract_decoder.rs +0 -57
- package/src/debug_trace.rs +0 -40
- package/src/gas_report.rs +0 -92
- package/src/instrument.rs +0 -109
- package/src/lib.rs +0 -50
- package/src/log.rs +0 -28
- package/src/logger.rs +0 -120
- package/src/mock/time.rs +0 -134
- package/src/mock.rs +0 -71
- package/src/precompile.rs +0 -50
- package/src/provider/factory.rs +0 -22
- package/src/provider/response.rs +0 -73
- package/src/provider.rs +0 -162
- package/src/result.rs +0 -212
- package/src/scenarios.rs +0 -53
- package/src/serde.rs +0 -57
- package/src/solidity_tests/artifact.rs +0 -184
- package/src/solidity_tests/config.rs +0 -793
- package/src/solidity_tests/factory.rs +0 -22
- package/src/solidity_tests/l1.rs +0 -68
- package/src/solidity_tests/op.rs +0 -69
- package/src/solidity_tests/runner.rs +0 -51
- package/src/solidity_tests/test_results.rs +0 -736
- package/src/solidity_tests.rs +0 -56
- package/src/subscription.rs +0 -32
- package/src/trace/debug.rs +0 -61
- package/src/trace/exit.rs +0 -89
- package/src/trace/library_utils.rs +0 -11
- package/src/trace/model.rs +0 -59
- package/src/trace/return_data.rs +0 -96
- package/src/trace/solidity_stack_trace.rs +0 -869
- package/src/trace.rs +0 -199
- package/src/ts/solidity_tests.ts +0 -46
- package/src/withdrawal.rs +0 -49
package/src/trace.rs
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
// In contrast to the functions in the `#[napi] impl XYZ` block,
|
|
2
|
-
// the free functions `#[napi] pub fn` are exported by napi-rs but
|
|
3
|
-
// are considered dead code in the (lib test) target.
|
|
4
|
-
// For now, we silence the relevant warnings, as we need to mimick
|
|
5
|
-
// the original API while we rewrite the stack trace refinement to Rust.
|
|
6
|
-
#![cfg_attr(test, allow(dead_code))]
|
|
7
|
-
|
|
8
|
-
use std::sync::Arc;
|
|
9
|
-
|
|
10
|
-
use edr_evm::trace::BeforeMessage;
|
|
11
|
-
use edr_evm_spec::EvmHaltReason;
|
|
12
|
-
use edr_primitives::bytecode::opcode::OpCode;
|
|
13
|
-
use napi::bindgen_prelude::{BigInt, Either3, Uint8Array};
|
|
14
|
-
use napi_derive::napi;
|
|
15
|
-
|
|
16
|
-
use crate::result::ExecutionResult;
|
|
17
|
-
|
|
18
|
-
mod library_utils;
|
|
19
|
-
|
|
20
|
-
mod debug;
|
|
21
|
-
mod exit;
|
|
22
|
-
mod model;
|
|
23
|
-
mod return_data;
|
|
24
|
-
pub mod solidity_stack_trace;
|
|
25
|
-
|
|
26
|
-
#[napi(object)]
|
|
27
|
-
pub struct TracingMessage {
|
|
28
|
-
/// Sender address
|
|
29
|
-
#[napi(readonly)]
|
|
30
|
-
pub caller: Uint8Array,
|
|
31
|
-
|
|
32
|
-
/// Recipient address. None if it is a Create message.
|
|
33
|
-
#[napi(readonly)]
|
|
34
|
-
pub to: Option<Uint8Array>,
|
|
35
|
-
|
|
36
|
-
/// Whether it's a static call
|
|
37
|
-
#[napi(readonly)]
|
|
38
|
-
pub is_static_call: bool,
|
|
39
|
-
|
|
40
|
-
/// Transaction gas limit
|
|
41
|
-
#[napi(readonly)]
|
|
42
|
-
pub gas_limit: BigInt,
|
|
43
|
-
|
|
44
|
-
/// Depth of the message
|
|
45
|
-
#[napi(readonly)]
|
|
46
|
-
pub depth: u8,
|
|
47
|
-
|
|
48
|
-
/// Input data of the message
|
|
49
|
-
#[napi(readonly)]
|
|
50
|
-
pub data: Uint8Array,
|
|
51
|
-
|
|
52
|
-
/// Value sent in the message
|
|
53
|
-
#[napi(readonly)]
|
|
54
|
-
pub value: BigInt,
|
|
55
|
-
|
|
56
|
-
/// Address of the code that is being executed. Can be different from `to`
|
|
57
|
-
/// if a delegate call is being done.
|
|
58
|
-
#[napi(readonly)]
|
|
59
|
-
pub code_address: Option<Uint8Array>,
|
|
60
|
-
|
|
61
|
-
/// Code of the contract that is being executed.
|
|
62
|
-
#[napi(readonly)]
|
|
63
|
-
pub code: Option<Uint8Array>,
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
impl From<&BeforeMessage> for TracingMessage {
|
|
67
|
-
fn from(value: &BeforeMessage) -> Self {
|
|
68
|
-
// Deconstruct to make sure all fields are handled
|
|
69
|
-
let BeforeMessage {
|
|
70
|
-
depth,
|
|
71
|
-
caller,
|
|
72
|
-
to,
|
|
73
|
-
is_static_call,
|
|
74
|
-
gas_limit,
|
|
75
|
-
data,
|
|
76
|
-
value,
|
|
77
|
-
code_address,
|
|
78
|
-
code,
|
|
79
|
-
} = value;
|
|
80
|
-
|
|
81
|
-
let data = Uint8Array::with_data_copied(data);
|
|
82
|
-
|
|
83
|
-
let code = code
|
|
84
|
-
.as_ref()
|
|
85
|
-
.map(|code| Uint8Array::with_data_copied(code.original_bytes()));
|
|
86
|
-
|
|
87
|
-
TracingMessage {
|
|
88
|
-
caller: Uint8Array::with_data_copied(caller),
|
|
89
|
-
to: to.as_ref().map(Uint8Array::with_data_copied),
|
|
90
|
-
gas_limit: BigInt::from(*gas_limit),
|
|
91
|
-
is_static_call: *is_static_call,
|
|
92
|
-
depth: *depth as u8,
|
|
93
|
-
data,
|
|
94
|
-
value: BigInt {
|
|
95
|
-
sign_bit: false,
|
|
96
|
-
words: value.into_limbs().to_vec(),
|
|
97
|
-
},
|
|
98
|
-
code_address: code_address.as_ref().map(Uint8Array::with_data_copied),
|
|
99
|
-
code,
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
#[napi(object)]
|
|
105
|
-
pub struct TracingStep {
|
|
106
|
-
/// Call depth
|
|
107
|
-
#[napi(readonly)]
|
|
108
|
-
pub depth: u8,
|
|
109
|
-
/// The program counter
|
|
110
|
-
#[napi(readonly)]
|
|
111
|
-
pub pc: BigInt,
|
|
112
|
-
/// The executed op code
|
|
113
|
-
#[napi(readonly)]
|
|
114
|
-
pub opcode: String,
|
|
115
|
-
/// The entries on the stack. It only contains the top element unless
|
|
116
|
-
/// verbose tracing is enabled. The vector is empty if there are no elements
|
|
117
|
-
/// on the stack.
|
|
118
|
-
#[napi(readonly)]
|
|
119
|
-
pub stack: Vec<BigInt>,
|
|
120
|
-
/// The memory at the step. None if verbose tracing is disabled.
|
|
121
|
-
#[napi(readonly)]
|
|
122
|
-
pub memory: Option<Uint8Array>,
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
impl TracingStep {
|
|
126
|
-
pub fn new(step: &edr_evm::trace::Step) -> Self {
|
|
127
|
-
let stack = step.stack.full().map_or_else(
|
|
128
|
-
|| {
|
|
129
|
-
step.stack
|
|
130
|
-
.top()
|
|
131
|
-
.map(u256_to_bigint)
|
|
132
|
-
.map_or_else(Vec::default, |top| vec![top])
|
|
133
|
-
},
|
|
134
|
-
|stack| stack.iter().map(u256_to_bigint).collect(),
|
|
135
|
-
);
|
|
136
|
-
let memory = step.memory.as_ref().map(Uint8Array::with_data_copied);
|
|
137
|
-
|
|
138
|
-
Self {
|
|
139
|
-
depth: step.depth as u8,
|
|
140
|
-
pc: BigInt::from(u64::from(step.pc)),
|
|
141
|
-
opcode: OpCode::name_by_op(step.opcode).to_string(),
|
|
142
|
-
stack,
|
|
143
|
-
memory,
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
pub(crate) fn u256_to_bigint(v: &edr_primitives::U256) -> BigInt {
|
|
149
|
-
BigInt {
|
|
150
|
-
sign_bit: false,
|
|
151
|
-
words: v.into_limbs().to_vec(),
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
#[napi(object)]
|
|
156
|
-
pub struct TracingMessageResult {
|
|
157
|
-
/// Execution result
|
|
158
|
-
#[napi(readonly)]
|
|
159
|
-
pub execution_result: ExecutionResult,
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
#[napi]
|
|
163
|
-
#[derive(Clone)]
|
|
164
|
-
pub struct RawTrace {
|
|
165
|
-
inner: Arc<edr_evm::trace::Trace<EvmHaltReason>>,
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
impl From<Arc<edr_evm::trace::Trace<EvmHaltReason>>> for RawTrace {
|
|
169
|
-
fn from(value: Arc<edr_evm::trace::Trace<EvmHaltReason>>) -> Self {
|
|
170
|
-
Self { inner: value }
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
#[napi]
|
|
175
|
-
impl RawTrace {
|
|
176
|
-
#[napi(getter)]
|
|
177
|
-
pub fn trace(&self) -> Vec<Either3<TracingMessage, TracingStep, TracingMessageResult>> {
|
|
178
|
-
self.inner
|
|
179
|
-
.messages
|
|
180
|
-
.iter()
|
|
181
|
-
.map(|message| match message {
|
|
182
|
-
edr_evm::trace::TraceMessage::Before(message) => {
|
|
183
|
-
Either3::A(TracingMessage::from(message))
|
|
184
|
-
}
|
|
185
|
-
edr_evm::trace::TraceMessage::Step(step) => Either3::B(TracingStep::new(step)),
|
|
186
|
-
edr_evm::trace::TraceMessage::After(message) => Either3::C(TracingMessageResult {
|
|
187
|
-
execution_result: ExecutionResult::from(message),
|
|
188
|
-
}),
|
|
189
|
-
})
|
|
190
|
-
.collect()
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
#[napi]
|
|
195
|
-
/// Returns the latest version of solc that EDR officially
|
|
196
|
-
/// supports and is tested against.
|
|
197
|
-
pub fn get_latest_supported_solc_version() -> String {
|
|
198
|
-
"0.8.28".to_string()
|
|
199
|
-
}
|
package/src/ts/solidity_tests.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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/src/withdrawal.rs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
use edr_primitives::Address;
|
|
2
|
-
use napi::bindgen_prelude::{BigInt, Uint8Array};
|
|
3
|
-
use napi_derive::napi;
|
|
4
|
-
|
|
5
|
-
use crate::cast::TryCast as _;
|
|
6
|
-
|
|
7
|
-
#[napi(object)]
|
|
8
|
-
pub struct Withdrawal {
|
|
9
|
-
/// The index of withdrawal
|
|
10
|
-
pub index: BigInt,
|
|
11
|
-
/// The index of the validator that generated the withdrawal
|
|
12
|
-
pub validator_index: BigInt,
|
|
13
|
-
/// The recipient address for withdrawal value
|
|
14
|
-
pub address: Uint8Array,
|
|
15
|
-
/// The value contained in withdrawal
|
|
16
|
-
pub amount: BigInt,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
impl From<edr_block_header::Withdrawal> for Withdrawal {
|
|
20
|
-
fn from(withdrawal: edr_block_header::Withdrawal) -> Self {
|
|
21
|
-
Self {
|
|
22
|
-
index: BigInt::from(withdrawal.index),
|
|
23
|
-
validator_index: BigInt::from(withdrawal.validator_index),
|
|
24
|
-
address: Uint8Array::with_data_copied(withdrawal.address),
|
|
25
|
-
amount: BigInt {
|
|
26
|
-
sign_bit: false,
|
|
27
|
-
words: vec![withdrawal.amount],
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
impl TryFrom<Withdrawal> for edr_block_header::Withdrawal {
|
|
34
|
-
type Error = napi::Error;
|
|
35
|
-
|
|
36
|
-
fn try_from(value: Withdrawal) -> Result<Self, Self::Error> {
|
|
37
|
-
let index: u64 = BigInt::try_cast(value.index)?;
|
|
38
|
-
let validator_index: u64 = BigInt::try_cast(value.validator_index)?;
|
|
39
|
-
let amount = BigInt::try_cast(value.amount)?;
|
|
40
|
-
let address = Address::from_slice(&value.address);
|
|
41
|
-
|
|
42
|
-
Ok(Self {
|
|
43
|
-
index,
|
|
44
|
-
validator_index,
|
|
45
|
-
address,
|
|
46
|
-
amount,
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
}
|