@nomicfoundation/edr 0.12.0-alpha.0 → 0.12.0-next.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/Cargo.toml +47 -16
- package/LICENSE +5 -1
- package/index.d.ts +773 -104
- package/index.js +31 -1
- package/package.json +20 -17
- package/src/account.rs +102 -55
- package/src/block.rs +2 -103
- package/src/call_override.rs +8 -8
- package/src/cast.rs +7 -29
- package/src/chains/generic.rs +1 -1
- package/src/chains/l1.rs +20 -18
- package/src/chains/op.rs +95 -38
- package/src/config.rs +305 -161
- package/src/context.rs +260 -21
- package/src/debug_trace.rs +2 -2
- package/src/instrument.rs +109 -0
- package/src/lib.rs +10 -0
- package/src/log.rs +12 -14
- package/src/logger.rs +28 -30
- package/src/mock.rs +68 -0
- package/src/precompile.rs +50 -0
- package/src/provider/response.rs +8 -5
- package/src/provider.rs +14 -8
- package/src/result.rs +18 -27
- package/src/scenarios.rs +2 -2
- package/src/serde.rs +57 -0
- package/src/solidity_tests/artifact.rs +184 -0
- package/src/solidity_tests/config.rs +725 -0
- package/src/solidity_tests/factory.rs +22 -0
- package/src/solidity_tests/l1.rs +68 -0
- package/src/solidity_tests/op.rs +69 -0
- package/src/solidity_tests/runner.rs +51 -0
- package/src/solidity_tests/test_results.rs +668 -0
- package/src/solidity_tests.rs +56 -0
- package/src/subscription.rs +1 -1
- package/src/trace/debug.rs +1 -1
- package/src/trace/exit.rs +4 -4
- package/src/trace/library_utils.rs +7 -2
- package/src/trace/return_data.rs +10 -10
- package/src/trace/solidity_stack_trace.rs +7 -5
- package/src/trace.rs +29 -38
- package/src/withdrawal.rs +3 -3
package/src/chains/op.rs
CHANGED
|
@@ -6,13 +6,13 @@ use edr_napi_core::{
|
|
|
6
6
|
provider::{self, ProviderBuilder, SyncProviderFactory},
|
|
7
7
|
subscription,
|
|
8
8
|
};
|
|
9
|
-
use edr_op::{OpChainSpec, OpSpecId};
|
|
9
|
+
use edr_op::{predeploys::GAS_PRICE_ORACLE_ADDRESS, OpChainSpec, OpSpecId};
|
|
10
10
|
use edr_solidity::contract_decoder::ContractDecoder;
|
|
11
|
-
use napi::bindgen_prelude::BigInt;
|
|
11
|
+
use napi::bindgen_prelude::{BigInt, Uint8Array};
|
|
12
12
|
use napi_derive::napi;
|
|
13
13
|
|
|
14
14
|
use crate::{
|
|
15
|
-
account::{
|
|
15
|
+
account::{AccountOverride, StorageSlot},
|
|
16
16
|
provider::ProviderFactory,
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -96,13 +96,13 @@ impl FromStr for OpHardfork {
|
|
|
96
96
|
/// instance.
|
|
97
97
|
///
|
|
98
98
|
/// Returns an error if the string does not match any known hardfork.
|
|
99
|
-
#[napi]
|
|
99
|
+
#[napi(catch_unwind)]
|
|
100
100
|
pub fn op_hardfork_from_string(hardfork: String) -> napi::Result<OpHardfork> {
|
|
101
101
|
hardfork.parse()
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/// Returns the string representation of the provided OP hardfork.
|
|
105
|
-
#[napi]
|
|
105
|
+
#[napi(catch_unwind)]
|
|
106
106
|
pub fn op_hardfork_to_string(hardfork: OpHardfork) -> &'static str {
|
|
107
107
|
match hardfork {
|
|
108
108
|
OpHardfork::Bedrock => edr_op::hardfork::name::BEDROCK,
|
|
@@ -119,7 +119,7 @@ pub fn op_hardfork_to_string(hardfork: OpHardfork) -> &'static str {
|
|
|
119
119
|
/// Returns the latest supported OP hardfork.
|
|
120
120
|
///
|
|
121
121
|
/// The returned value will be updated after each network upgrade.
|
|
122
|
-
#[napi]
|
|
122
|
+
#[napi(catch_unwind)]
|
|
123
123
|
pub fn op_latest_hardfork() -> OpHardfork {
|
|
124
124
|
OpHardfork::Holocene
|
|
125
125
|
}
|
|
@@ -127,35 +127,16 @@ pub fn op_latest_hardfork() -> OpHardfork {
|
|
|
127
127
|
#[napi]
|
|
128
128
|
pub const OP_CHAIN_TYPE: &str = edr_op::CHAIN_TYPE;
|
|
129
129
|
|
|
130
|
-
#[napi]
|
|
131
|
-
pub fn op_genesis_state(
|
|
132
|
-
let gas_price_oracle_code = hex::decode(include_str!(
|
|
133
|
-
"../../data/op/predeploys/gas_price_oracle.txt"
|
|
134
|
-
))
|
|
135
|
-
.expect("The bytecode for the GasPriceOracle predeploy should be a valid hex string");
|
|
136
|
-
let gas_price_oracle = Account {
|
|
137
|
-
address: hex!("420000000000000000000000000000000000000F").into(),
|
|
138
|
-
balance: BigInt::from(0u64),
|
|
139
|
-
nonce: BigInt::from(0u64),
|
|
140
|
-
code: Some(gas_price_oracle_code.into()),
|
|
141
|
-
storage: vec![StorageSlot {
|
|
142
|
-
index: BigInt::from(0u64),
|
|
143
|
-
// bool isEcotone = true
|
|
144
|
-
// bool isFjord = true
|
|
145
|
-
value: BigInt::from(
|
|
146
|
-
0x0000000000000000000000000000000000000000000000000000000000000101u64,
|
|
147
|
-
),
|
|
148
|
-
}],
|
|
149
|
-
};
|
|
150
|
-
|
|
130
|
+
#[napi(catch_unwind)]
|
|
131
|
+
pub fn op_genesis_state(hardfork: OpHardfork) -> Vec<AccountOverride> {
|
|
151
132
|
let l1_block_code = hex::decode(include_str!("../../data/op/predeploys/l1_block.txt"))
|
|
152
133
|
.expect("The bytecode for the L1Block predeploy should be a valid hex string");
|
|
153
|
-
let l1_block =
|
|
134
|
+
let l1_block = AccountOverride {
|
|
154
135
|
address: hex!("4200000000000000000000000000000000000015").into(),
|
|
155
|
-
balance: BigInt::from(0u64),
|
|
156
|
-
nonce: BigInt::from(0u64),
|
|
136
|
+
balance: Some(BigInt::from(0u64)),
|
|
137
|
+
nonce: Some(BigInt::from(0u64)),
|
|
157
138
|
code: Some(l1_block_code.into()),
|
|
158
|
-
storage: vec![
|
|
139
|
+
storage: Some(vec![
|
|
159
140
|
StorageSlot {
|
|
160
141
|
index: BigInt::from(0u64),
|
|
161
142
|
// uint64 public number = 1
|
|
@@ -213,7 +194,7 @@ pub fn op_genesis_state(_hardfork: OpHardfork) -> Vec<Account> {
|
|
|
213
194
|
// uint256 blobBaseFee = 10 gwei
|
|
214
195
|
value: BigInt::from(0x00000002540be400_u64),
|
|
215
196
|
},
|
|
216
|
-
],
|
|
197
|
+
]),
|
|
217
198
|
};
|
|
218
199
|
|
|
219
200
|
/* The rest of the predeploys use a stubbed bytecode that reverts with a
|
|
@@ -324,29 +305,105 @@ pub fn op_genesis_state(_hardfork: OpHardfork) -> Vec<Account> {
|
|
|
324
305
|
|
|
325
306
|
let stubbed_predeploys = stubbed_predeploys_data
|
|
326
307
|
.iter()
|
|
327
|
-
.map(|(name, address, code)|
|
|
308
|
+
.map(|(name, address, code)| AccountOverride {
|
|
328
309
|
address: address.into(),
|
|
329
|
-
balance: BigInt::from(0u64),
|
|
330
|
-
nonce: BigInt::from(0u64),
|
|
310
|
+
balance: Some(BigInt::from(0u64)),
|
|
311
|
+
nonce: Some(BigInt::from(0u64)),
|
|
331
312
|
code: Some(
|
|
332
313
|
hex::decode(code)
|
|
333
314
|
.unwrap_or_else(|e| panic!("The bytecode for the {name} predeploy should be a valid hex string, got error: {e}"))
|
|
334
315
|
.into(),
|
|
335
316
|
),
|
|
336
|
-
storage: vec![],
|
|
317
|
+
storage: Some(vec![]),
|
|
337
318
|
});
|
|
338
319
|
|
|
339
|
-
let predeploys = vec![
|
|
320
|
+
let predeploys = vec![gas_price_oracle_override(hardfork.into()), l1_block];
|
|
340
321
|
|
|
341
322
|
predeploys.into_iter().chain(stubbed_predeploys).collect()
|
|
342
323
|
}
|
|
343
324
|
|
|
344
|
-
#[napi]
|
|
325
|
+
#[napi(catch_unwind)]
|
|
345
326
|
pub fn op_provider_factory() -> ProviderFactory {
|
|
346
327
|
let factory: Arc<dyn SyncProviderFactory> = Arc::new(OpProviderFactory);
|
|
347
328
|
factory.into()
|
|
348
329
|
}
|
|
349
330
|
|
|
331
|
+
fn gas_price_oracle_override(hardfork: OpSpecId) -> AccountOverride {
|
|
332
|
+
if hardfork >= OpSpecId::ISTHMUS {
|
|
333
|
+
gas_price_oracle_isthmus()
|
|
334
|
+
} else if hardfork >= OpSpecId::FJORD {
|
|
335
|
+
gas_price_oracle_fjord()
|
|
336
|
+
} else {
|
|
337
|
+
gas_price_oracle_ecotone()
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
fn gas_price_oracle_ecotone() -> AccountOverride {
|
|
342
|
+
let gas_price_oracle_code = hex::decode(include_str!(
|
|
343
|
+
"../../data/op/predeploys/gas_price_oracle/ecotone.txt"
|
|
344
|
+
))
|
|
345
|
+
.expect("The bytecode for the GasPriceOracle predeploy should be a valid hex string");
|
|
346
|
+
|
|
347
|
+
AccountOverride {
|
|
348
|
+
address: Uint8Array::with_data_copied(GAS_PRICE_ORACLE_ADDRESS),
|
|
349
|
+
balance: None,
|
|
350
|
+
nonce: None,
|
|
351
|
+
code: Some(gas_price_oracle_code.into()),
|
|
352
|
+
storage: Some(vec![StorageSlot {
|
|
353
|
+
index: BigInt::from(0u64),
|
|
354
|
+
// bool isEcotone = true
|
|
355
|
+
value: BigInt::from(
|
|
356
|
+
0x0000000000000000000000000000000000000000000000000000000000000001u64,
|
|
357
|
+
),
|
|
358
|
+
}]),
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
fn gas_price_oracle_fjord() -> AccountOverride {
|
|
363
|
+
let gas_price_oracle_code = hex::decode(include_str!(
|
|
364
|
+
"../../data/op/predeploys/gas_price_oracle/fjord.txt"
|
|
365
|
+
))
|
|
366
|
+
.expect("The bytecode for the GasPriceOracle predeploy should be a valid hex string");
|
|
367
|
+
|
|
368
|
+
AccountOverride {
|
|
369
|
+
address: Uint8Array::with_data_copied(GAS_PRICE_ORACLE_ADDRESS),
|
|
370
|
+
balance: None,
|
|
371
|
+
nonce: None,
|
|
372
|
+
code: Some(gas_price_oracle_code.into()),
|
|
373
|
+
storage: Some(vec![StorageSlot {
|
|
374
|
+
index: BigInt::from(0u64),
|
|
375
|
+
// bool isEcotone = true
|
|
376
|
+
// bool isFjord = true
|
|
377
|
+
value: BigInt::from(
|
|
378
|
+
0x0000000000000000000000000000000000000000000000000000000000000101u64,
|
|
379
|
+
),
|
|
380
|
+
}]),
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
fn gas_price_oracle_isthmus() -> AccountOverride {
|
|
385
|
+
let gas_price_oracle_code = hex::decode(include_str!(
|
|
386
|
+
"../../data/op/predeploys/gas_price_oracle/isthmus.txt"
|
|
387
|
+
))
|
|
388
|
+
.expect("The bytecode for the GasPriceOracle predeploy should be a valid hex string");
|
|
389
|
+
|
|
390
|
+
AccountOverride {
|
|
391
|
+
address: Uint8Array::with_data_copied(GAS_PRICE_ORACLE_ADDRESS),
|
|
392
|
+
balance: None,
|
|
393
|
+
nonce: None,
|
|
394
|
+
code: Some(gas_price_oracle_code.into()),
|
|
395
|
+
storage: Some(vec![StorageSlot {
|
|
396
|
+
index: BigInt::from(0u64),
|
|
397
|
+
// bool isEcotone = true
|
|
398
|
+
// bool isFjord = true
|
|
399
|
+
// bool isIsthmus = true
|
|
400
|
+
value: BigInt::from(
|
|
401
|
+
0x0000000000000000000000000000000000000000000000000000000000010101u64,
|
|
402
|
+
),
|
|
403
|
+
}]),
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
350
407
|
macro_rules! export_spec_id {
|
|
351
408
|
($($variant:ident,)*) => {
|
|
352
409
|
$(
|