@nomicfoundation/edr 0.12.0-next.14 → 0.12.0-next.16

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 CHANGED
@@ -91,7 +91,9 @@ export enum SpecId {
91
91
  /** Cancun */
92
92
  Cancun = 17,
93
93
  /** Prague */
94
- Prague = 18
94
+ Prague = 18,
95
+ /** Osaka */
96
+ Osaka = 19
95
97
  }
96
98
  /**
97
99
  * Tries to parse the provided string to create a [`SpecId`] instance.
@@ -125,6 +127,7 @@ export const MERGE: string
125
127
  export const SHANGHAI: string
126
128
  export const CANCUN: string
127
129
  export const PRAGUE: string
130
+ export const OSAKA: string
128
131
  /** Enumeration of supported OP hardforks. */
129
132
  export enum OpHardfork {
130
133
  Bedrock = 100,
@@ -333,6 +336,14 @@ export interface ProviderConfig {
333
336
  ownedAccounts: Array<string>
334
337
  /** Overrides for precompiles */
335
338
  precompileOverrides: Array<Precompile>
339
+ /**
340
+ * Transaction gas cap, introduced in [EIP-7825].
341
+ *
342
+ * When not set, will default to value defined by the used hardfork
343
+ *
344
+ * [EIP-7825]: https://eips.ethereum.org/EIPS/eip-7825
345
+ */
346
+ transactionGasCap?: bigint
336
347
  }
337
348
  /** Tracing config for Solidity stack trace generation. */
338
349
  export interface TracingConfigWithBuffers {
@@ -586,8 +597,6 @@ export interface SolidityTestRunnerConfigArgs {
586
597
  projectRoot: string
587
598
  /** Configures the permissions of cheat codes that access the file system. */
588
599
  fsPermissions?: Array<PathPermission>
589
- /** Whether to support the `testFail` prefix. Defaults to false. */
590
- testFail?: boolean
591
600
  /** Address labels for traces. Defaults to none. */
592
601
  labels?: Array<AddressLabel>
593
602
  /**
@@ -838,6 +847,12 @@ export interface InvariantConfigArgs {
838
847
  * Defaults to 5000.
839
848
  */
840
849
  shrinkRunLimit?: number
850
+ /**
851
+ * The maximum number of rejects via `vm.assume` which can be encountered
852
+ * during a single invariant run.
853
+ * Defaults to 65536.
854
+ */
855
+ maxAssumeRejects?: number
841
856
  }
842
857
  /** Settings to configure caching of remote RPC endpoints. */
843
858
  export interface StorageCachingConfig {
@@ -1003,7 +1018,7 @@ export enum TestStatus {
1003
1018
  /**Test skipped */
1004
1019
  Skipped = 'Skipped'
1005
1020
  }
1006
- /** See [`edr_solidity_tests::result::TestKind::Standard`] */
1021
+ /** See [`edr_solidity_tests::result::TestKind::Unit`] */
1007
1022
  export interface StandardTestKind {
1008
1023
  /** The gas consumed by the test. */
1009
1024
  readonly consumedGas: bigint
@@ -1034,6 +1049,16 @@ export interface InvariantTestKind {
1034
1049
  readonly calls: bigint
1035
1050
  /** See [`edr_solidity_tests::result::TestKind::Invariant`] */
1036
1051
  readonly reverts: bigint
1052
+ /** See [`edr_solidity_tests::result::TestKind::Invariant`] */
1053
+ readonly metrics: Record<string, InvariantMetrics>
1054
+ /** See [`edr_solidity_tests::result::TestKind::Invariant`] */
1055
+ readonly failedCorpusReplays: bigint
1056
+ }
1057
+ /** See [`edr_solidity_tests::result::InvariantMetrics`] */
1058
+ export interface InvariantMetrics {
1059
+ readonly calls: bigint
1060
+ readonly reverts: bigint
1061
+ readonly discards: bigint
1037
1062
  }
1038
1063
  /**
1039
1064
  * Original sequence size and sequence of calls used as a counter example
package/index.js CHANGED
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { GENERIC_CHAIN_TYPE, genericChainProviderFactory, L1_CHAIN_TYPE, l1GenesisState, l1ProviderFactory, SpecId, l1HardforkFromString, l1HardforkToString, l1HardforkLatest, FRONTIER, FRONTIER_THAWING, HOMESTEAD, DAO_FORK, TANGERINE, SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, ISTANBUL, MUIR_GLACIER, BERLIN, LONDON, ARROW_GLACIER, GRAY_GLACIER, MERGE, SHANGHAI, CANCUN, PRAGUE, OpHardfork, opHardforkFromString, opHardforkToString, opLatestHardfork, OP_CHAIN_TYPE, opGenesisState, opProviderFactory, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, MineOrdering, EdrContext, ContractDecoder, GasReportExecutionStatus, addStatementCoverageInstrumentation, Precompile, precompileP256Verify, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, CachedChains, CachedEndpoints, FsAccessPermission, CollectStackTraces, IncludeTraces, SolidityTestRunnerFactory, l1SolidityTestRunnerFactory, opSolidityTestRunnerFactory, SuiteResult, TestResult, TestStatus, CallKind, LogKind, linkHexStringBytecode, printStackTrace, Exit, ExitCode, BytecodeWrapper, ContractFunctionType, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, RawTrace, getLatestSupportedSolcVersion } = nativeBinding
313
+ const { GENERIC_CHAIN_TYPE, genericChainProviderFactory, L1_CHAIN_TYPE, l1GenesisState, l1ProviderFactory, SpecId, l1HardforkFromString, l1HardforkToString, l1HardforkLatest, FRONTIER, FRONTIER_THAWING, HOMESTEAD, DAO_FORK, TANGERINE, SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, ISTANBUL, MUIR_GLACIER, BERLIN, LONDON, ARROW_GLACIER, GRAY_GLACIER, MERGE, SHANGHAI, CANCUN, PRAGUE, OSAKA, OpHardfork, opHardforkFromString, opHardforkToString, opLatestHardfork, OP_CHAIN_TYPE, opGenesisState, opProviderFactory, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, MineOrdering, EdrContext, ContractDecoder, GasReportExecutionStatus, addStatementCoverageInstrumentation, Precompile, precompileP256Verify, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, CachedChains, CachedEndpoints, FsAccessPermission, CollectStackTraces, IncludeTraces, SolidityTestRunnerFactory, l1SolidityTestRunnerFactory, opSolidityTestRunnerFactory, SuiteResult, TestResult, TestStatus, CallKind, LogKind, linkHexStringBytecode, printStackTrace, Exit, ExitCode, BytecodeWrapper, ContractFunctionType, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, RawTrace, getLatestSupportedSolcVersion } = nativeBinding
314
314
 
315
315
  module.exports.GENERIC_CHAIN_TYPE = GENERIC_CHAIN_TYPE
316
316
  module.exports.genericChainProviderFactory = genericChainProviderFactory
@@ -340,6 +340,7 @@ module.exports.MERGE = MERGE
340
340
  module.exports.SHANGHAI = SHANGHAI
341
341
  module.exports.CANCUN = CANCUN
342
342
  module.exports.PRAGUE = PRAGUE
343
+ module.exports.OSAKA = OSAKA
343
344
  module.exports.OpHardfork = OpHardfork
344
345
  module.exports.opHardforkFromString = opHardforkFromString
345
346
  module.exports.opHardforkToString = opHardforkToString
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomicfoundation/edr",
3
- "version": "0.12.0-next.14",
3
+ "version": "0.12.0-next.16",
4
4
  "devDependencies": {
5
5
  "@napi-rs/cli": "^2.18.4",
6
6
  "@nomicfoundation/ethereumjs-util": "^9.0.4",
@@ -58,13 +58,13 @@
58
58
  "repository": "NomicFoundation/edr.git",
59
59
  "types": "index.d.ts",
60
60
  "dependencies": {
61
- "@nomicfoundation/edr-darwin-arm64": "0.12.0-next.14",
62
- "@nomicfoundation/edr-darwin-x64": "0.12.0-next.14",
63
- "@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.14",
64
- "@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.14",
65
- "@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.14",
66
- "@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.14",
67
- "@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.14"
61
+ "@nomicfoundation/edr-darwin-arm64": "0.12.0-next.16",
62
+ "@nomicfoundation/edr-darwin-x64": "0.12.0-next.16",
63
+ "@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.16",
64
+ "@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.16",
65
+ "@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.16",
66
+ "@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.16",
67
+ "@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.16"
68
68
  },
69
69
  "scripts": {
70
70
  "artifacts": "napi artifacts",
package/src/account.rs CHANGED
@@ -82,7 +82,7 @@ impl TryFrom<AccountOverride> for Predeploy {
82
82
  fn try_from(value: AccountOverride) -> Result<Self, Self::Error> {
83
83
  let (address, account_override) = value.try_into()?;
84
84
 
85
- let storage = account_override.storage.unwrap_or_else(HashMap::new);
85
+ let storage = account_override.storage.unwrap_or_else(HashMap::default);
86
86
  let balance = account_override.balance.unwrap_or(U256::ZERO);
87
87
  let nonce = account_override.nonce.unwrap_or(0);
88
88
  let code = account_override.code.ok_or_else(|| {
package/src/chains/l1.rs CHANGED
@@ -135,6 +135,8 @@ pub enum SpecId {
135
135
  Cancun = 17,
136
136
  /// Prague
137
137
  Prague = 18,
138
+ /// Osaka
139
+ Osaka = 19,
138
140
  }
139
141
 
140
142
  impl FromStr for SpecId {
@@ -161,6 +163,7 @@ impl FromStr for SpecId {
161
163
  edr_chain_l1::chains::name::SHANGHAI => Ok(SpecId::Shanghai),
162
164
  edr_chain_l1::chains::name::CANCUN => Ok(SpecId::Cancun),
163
165
  edr_chain_l1::chains::name::PRAGUE => Ok(SpecId::Prague),
166
+ edr_chain_l1::chains::name::OSAKA => Ok(SpecId::Osaka),
164
167
  _ => Err(napi::Error::new(
165
168
  napi::Status::InvalidArg,
166
169
  format!("The provided hardfork `{s}` is not supported."),
@@ -191,6 +194,7 @@ impl From<SpecId> for edr_chain_l1::Hardfork {
191
194
  SpecId::Shanghai => edr_chain_l1::Hardfork::SHANGHAI,
192
195
  SpecId::Cancun => edr_chain_l1::Hardfork::CANCUN,
193
196
  SpecId::Prague => edr_chain_l1::Hardfork::PRAGUE,
197
+ SpecId::Osaka => edr_chain_l1::Hardfork::OSAKA,
194
198
  }
195
199
  }
196
200
  }
@@ -225,6 +229,7 @@ pub fn l1_hardfork_to_string(harfork: SpecId) -> &'static str {
225
229
  SpecId::Shanghai => edr_chain_l1::chains::name::SHANGHAI,
226
230
  SpecId::Cancun => edr_chain_l1::chains::name::CANCUN,
227
231
  SpecId::Prague => edr_chain_l1::chains::name::PRAGUE,
232
+ SpecId::Osaka => edr_chain_l1::chains::name::OSAKA,
228
233
  }
229
234
  }
230
235
 
@@ -264,5 +269,6 @@ export_spec_id!(
264
269
  MERGE,
265
270
  SHANGHAI,
266
271
  CANCUN,
267
- PRAGUE
272
+ PRAGUE,
273
+ OSAKA
268
274
  );
package/src/chains/op.rs CHANGED
@@ -8,7 +8,8 @@ use edr_napi_core::{
8
8
  use edr_op::{
9
9
  predeploys::{
10
10
  gas_price_oracle_code_ecotone, gas_price_oracle_code_fjord, gas_price_oracle_code_isthmus,
11
- GAS_PRICE_ORACLE_ADDRESS,
11
+ l1_block_code_bedrock, l1_block_code_ecotone, l1_block_code_isthmus,
12
+ GAS_PRICE_ORACLE_ADDRESS, L1_BLOCK_PREDEPLOY_ADDRESS,
12
13
  },
13
14
  OpChainSpec,
14
15
  };
@@ -143,72 +144,13 @@ pub const OP_CHAIN_TYPE: &str = edr_op::CHAIN_TYPE;
143
144
 
144
145
  #[napi(catch_unwind)]
145
146
  pub fn op_genesis_state(hardfork: OpHardfork) -> Vec<AccountOverride> {
146
- let l1_block_code = hex::decode(include_str!("../../data/op/predeploys/l1_block.txt"))
147
- .expect("The bytecode for the L1Block predeploy should be a valid hex string");
147
+ let l1_block_code = l1_block_code(hardfork.into());
148
148
  let l1_block = AccountOverride {
149
- address: hex!("4200000000000000000000000000000000000015").into(),
149
+ address: Uint8Array::with_data_copied(L1_BLOCK_PREDEPLOY_ADDRESS),
150
150
  balance: Some(BigInt::from(0u64)),
151
151
  nonce: Some(BigInt::from(0u64)),
152
- code: Some(l1_block_code.into()),
153
- storage: Some(vec![
154
- StorageSlot {
155
- index: BigInt::from(0u64),
156
- // uint64 public number = 1
157
- // uint64 public timestamp = 1
158
- value: BigInt {
159
- words: vec![
160
- 0x0000000000000001_u64, // least significative
161
- 0x0000000000000001_u64,
162
- ],
163
- sign_bit: false,
164
- },
165
- },
166
- StorageSlot {
167
- index: BigInt::from(1u64),
168
- // uint256 baseFee = 10 gwei
169
- value: BigInt::from(0x00000002540be400_u64),
170
- },
171
- StorageSlot {
172
- index: BigInt::from(2u64),
173
- // bytes32 hash = 0
174
- value: BigInt::from(0u64),
175
- },
176
- StorageSlot {
177
- index: BigInt::from(3u64),
178
- // uint64 sequenceNumber = 0
179
- // uint32 blobBaseFeeScalar = 1014213
180
- // uint32 baseFeeScalar = 5227
181
- value: BigInt {
182
- words: vec![
183
- 0x0000000000000000_u64, // least significative
184
- 0x0000000000000000_u64,
185
- 0x00000000000f79c5_u64,
186
- 0x000000000000146b_u64,
187
- ],
188
- sign_bit: false,
189
- },
190
- },
191
- StorageSlot {
192
- index: BigInt::from(4u64),
193
- // bytes32 batcherHash = 0
194
- value: BigInt::from(0u64),
195
- },
196
- StorageSlot {
197
- index: BigInt::from(5u64),
198
- // uint256 l1FeeOverhead = 0
199
- value: BigInt::from(0u64),
200
- },
201
- StorageSlot {
202
- index: BigInt::from(6u64),
203
- // uint256 l1FeeScalar = 0
204
- value: BigInt::from(0u64),
205
- },
206
- StorageSlot {
207
- index: BigInt::from(7u64),
208
- // uint256 blobBaseFee = 10 gwei
209
- value: BigInt::from(0x00000002540be400_u64),
210
- },
211
- ]),
152
+ code: Some(l1_block_code),
153
+ storage: Some(l1_block_storage(hardfork.into())),
212
154
  };
213
155
 
214
156
  /* The rest of the predeploys use a stubbed bytecode that reverts with a
@@ -315,6 +257,11 @@ pub fn op_genesis_state(hardfork: OpHardfork) -> Vec<AccountOverride> {
315
257
  hex!("4200000000000000000000000000000000000021"),
316
258
  "0x60806040526040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401603490607b565b60405180910390fd5b60006048601f836099565b91507f5072656465706c6f7920454153206973206e6f7420737570706f727465642e006000830152602082019050919050565b60006020820190508181036000830152609281603d565b9050919050565b60008282526020820190509291505056fea2646970667358221220afa6c1aa54a8b3f4f979e1297db5838a94353f3b77b5ecc164da19db26ea89f564736f6c63430008000033",
317
259
  ),
260
+ (
261
+ "OperatorFeeVault",
262
+ hex!("0x420000000000000000000000000000000000001b"),
263
+ "0x60806040526040517f08c379a000000000000000000000000000000000000000000000000000000000815260040160349060b9565b60405180910390fd5b5f82825260208201905092915050565b7f5072656465706c6f79204f70657261746f724665655661756c74206973206e6f5f8201527f7420737570706f727465642e0000000000000000000000000000000000000000602082015250565b5f60a5602c83603d565b915060ae82604d565b604082019050919050565b5f6020820190508181035f83015260ce81609b565b905091905056fea2646970667358221220dc3131d0ea77326c36012aee5dd9a870b6f07d76e6f55c8029da9d70a83f50c364736f6c634300081e0033",
264
+ ),
318
265
  ];
319
266
 
320
267
  let stubbed_predeploys = stubbed_predeploys_data
@@ -402,6 +349,85 @@ fn gas_price_oracle_isthmus() -> AccountOverride {
402
349
  }]),
403
350
  }
404
351
  }
352
+ fn l1_block_storage(hardfork: edr_op::Hardfork) -> Vec<StorageSlot> {
353
+ let mut base_storage = vec![
354
+ StorageSlot {
355
+ index: BigInt::from(0u64),
356
+ // uint64 public number = 1
357
+ // uint64 public timestamp = 1
358
+ value: BigInt {
359
+ words: vec![
360
+ 0x0000000000000001_u64, // least significative
361
+ 0x0000000000000001_u64,
362
+ ],
363
+ sign_bit: false,
364
+ },
365
+ },
366
+ StorageSlot {
367
+ index: BigInt::from(1u64),
368
+ // uint256 baseFee = 10 gwei
369
+ value: BigInt::from(0x00000002540be400_u64),
370
+ },
371
+ StorageSlot {
372
+ index: BigInt::from(2u64),
373
+ // bytes32 hash = 0
374
+ value: BigInt::from(0u64),
375
+ },
376
+ StorageSlot {
377
+ index: BigInt::from(3u64),
378
+ // uint64 sequenceNumber = 0
379
+ // uint32 blobBaseFeeScalar = 1014213
380
+ // uint32 baseFeeScalar = 5227
381
+ value: BigInt {
382
+ words: vec![
383
+ 0x0000000000000000_u64, // least significative
384
+ 0x0000000000000000_u64,
385
+ 0x00000000000f79c5_u64,
386
+ 0x000000000000146b_u64,
387
+ ],
388
+ sign_bit: false,
389
+ },
390
+ },
391
+ StorageSlot {
392
+ index: BigInt::from(4u64),
393
+ // bytes32 batcherHash = 0
394
+ value: BigInt::from(0u64),
395
+ },
396
+ StorageSlot {
397
+ index: BigInt::from(5u64),
398
+ // uint256 l1FeeOverhead = 0
399
+ value: BigInt::from(0u64),
400
+ },
401
+ StorageSlot {
402
+ index: BigInt::from(6u64),
403
+ // uint256 l1FeeScalar = 0
404
+ value: BigInt::from(0u64),
405
+ },
406
+ StorageSlot {
407
+ index: BigInt::from(7u64),
408
+ // uint256 blobBaseFee = 10 gwei
409
+ value: BigInt::from(0x00000002540be400_u64),
410
+ },
411
+ ];
412
+ if hardfork >= edr_op::Hardfork::ISTHMUS {
413
+ base_storage.push(StorageSlot {
414
+ // Operator fee parameters
415
+ index: BigInt::from(8u64),
416
+ value: BigInt::from(0u64),
417
+ });
418
+ }
419
+ base_storage
420
+ }
421
+
422
+ fn l1_block_code(hardfork: edr_op::Hardfork) -> Uint8Array {
423
+ if hardfork >= edr_op::Hardfork::ISTHMUS {
424
+ l1_block_code_isthmus().into()
425
+ } else if hardfork >= edr_op::Hardfork::ECOTONE {
426
+ l1_block_code_ecotone().into()
427
+ } else {
428
+ l1_block_code_bedrock().into()
429
+ }
430
+ }
405
431
 
406
432
  macro_rules! export_spec_id {
407
433
  ($($variant:ident,)*) => {
package/src/config.rs CHANGED
@@ -242,6 +242,12 @@ pub struct ProviderConfig {
242
242
  pub owned_accounts: Vec<JsString>,
243
243
  /// Overrides for precompiles
244
244
  pub precompile_overrides: Vec<Reference<Precompile>>,
245
+ /// Transaction gas cap, introduced in [EIP-7825].
246
+ ///
247
+ /// When not set, will default to value defined by the used hardfork
248
+ ///
249
+ /// [EIP-7825]: https://eips.ethereum.org/EIPS/eip-7825
250
+ pub transaction_gas_cap: Option<BigInt>,
245
251
  }
246
252
 
247
253
  impl TryFrom<ForkConfig> for edr_provider::ForkConfig<String> {
@@ -339,7 +345,7 @@ impl From<MemPoolConfig> for edr_provider::MemPoolConfig {
339
345
  }
340
346
  }
341
347
 
342
- impl From<MineOrdering> for edr_runtime::MineOrdering {
348
+ impl From<MineOrdering> for edr_block_miner::MineOrdering {
343
349
  fn from(value: MineOrdering) -> Self {
344
350
  match value {
345
351
  MineOrdering::Fifo => Self::Fifo,
@@ -619,6 +625,10 @@ impl ProviderConfig {
619
625
  observability: self.observability.resolve(env, runtime)?,
620
626
  owned_accounts,
621
627
  precompile_overrides,
628
+ transaction_gas_cap: self
629
+ .transaction_gas_cap
630
+ .map(TryCast::try_cast)
631
+ .transpose()?,
622
632
  })
623
633
  }
624
634
  }
package/src/context.rs CHANGED
@@ -390,8 +390,8 @@ impl Context {
390
390
  }
391
391
 
392
392
  Ok(Self {
393
- provider_factories: HashMap::new(),
394
- solidity_test_runner_factories: HashMap::new(),
393
+ provider_factories: HashMap::default(),
394
+ solidity_test_runner_factories: HashMap::default(),
395
395
  #[cfg(feature = "tracing")]
396
396
  _tracing_write_guard: guard,
397
397
  })
package/src/precompile.rs CHANGED
@@ -1,4 +1,4 @@
1
- use edr_precompile::{PrecompileFn, PrecompileWithAddress};
1
+ use edr_precompile::PrecompileFn;
2
2
  use edr_primitives::Address;
3
3
  use napi::bindgen_prelude::Uint8Array;
4
4
  use napi_derive::napi;
@@ -24,11 +24,11 @@ impl Precompile {
24
24
  }
25
25
  }
26
26
 
27
- impl From<PrecompileWithAddress> for Precompile {
28
- fn from(value: PrecompileWithAddress) -> Self {
27
+ impl From<edr_precompile::Precompile> for Precompile {
28
+ fn from(value: edr_precompile::Precompile) -> Self {
29
29
  Self {
30
- address: value.0,
31
- precompile_fn: value.1,
30
+ address: *value.address(),
31
+ precompile_fn: value.into_precompile(),
32
32
  }
33
33
  }
34
34
  }
package/src/result.rs CHANGED
@@ -1,5 +1,5 @@
1
1
  use edr_chain_spec::EvmHaltReason;
2
- use edr_runtime::trace::AfterMessage;
2
+ use edr_tracing::AfterMessage;
3
3
  use napi::{
4
4
  bindgen_prelude::{BigInt, Either3, Uint8Array},
5
5
  Either,
@@ -112,7 +112,9 @@ impl From<EvmHaltReason> for ExceptionalHalt {
112
112
  EvmHaltReason::StackOverflow => ExceptionalHalt::StackOverflow,
113
113
  EvmHaltReason::OutOfOffset => ExceptionalHalt::OutOfOffset,
114
114
  EvmHaltReason::CreateCollision => ExceptionalHalt::CreateCollision,
115
- EvmHaltReason::PrecompileError => ExceptionalHalt::PrecompileError,
115
+ EvmHaltReason::PrecompileError | EvmHaltReason::PrecompileErrorWithContext(_) => {
116
+ ExceptionalHalt::PrecompileError
117
+ }
116
118
  EvmHaltReason::NonceOverflow => ExceptionalHalt::NonceOverflow,
117
119
  EvmHaltReason::CreateContractSizeLimit => ExceptionalHalt::CreateContractSizeLimit,
118
120
  EvmHaltReason::CreateContractStartingWithEF => {
@@ -198,7 +200,7 @@ impl From<&AfterMessage<EvmHaltReason>> for ExecutionResult {
198
200
  }
199
201
  edr_evm_spec::result::ExecutionResult::Halt { reason, gas_used } => {
200
202
  Either3::C(HaltResult {
201
- reason: ExceptionalHalt::from(*reason),
203
+ reason: ExceptionalHalt::from(reason.clone()),
202
204
  gas_used: BigInt::from(*gas_used),
203
205
  })
204
206
  }
@@ -8,7 +8,7 @@ use edr_solidity_tests::{
8
8
  inspectors::cheatcodes::{CheatsConfigOptions, ExecutionContextConfig},
9
9
  TestFilterConfig,
10
10
  };
11
- use foundry_cheatcodes::{FsPermissions, RpcEndpoint, RpcEndpoints};
11
+ use foundry_cheatcodes::{FsPermissions, RpcEndpointUrl, RpcEndpoints};
12
12
  use napi::{
13
13
  bindgen_prelude::{BigInt, Uint8Array},
14
14
  tokio::runtime,
@@ -36,8 +36,6 @@ pub struct SolidityTestRunnerConfigArgs {
36
36
  pub project_root: String,
37
37
  /// Configures the permissions of cheat codes that access the file system.
38
38
  pub fs_permissions: Option<Vec<PathPermission>>,
39
- /// Whether to support the `testFail` prefix. Defaults to false.
40
- pub test_fail: Option<bool>,
41
39
  /// Address labels for traces. Defaults to none.
42
40
  pub labels: Option<Vec<AddressLabel>>,
43
41
  /// Whether to enable isolation of calls. In isolation mode all top-level
@@ -173,7 +171,6 @@ impl SolidityTestRunnerConfigArgs {
173
171
  let SolidityTestRunnerConfigArgs {
174
172
  project_root,
175
173
  fs_permissions,
176
- test_fail,
177
174
  labels,
178
175
  isolate,
179
176
  ffi,
@@ -246,7 +243,7 @@ impl SolidityTestRunnerConfigArgs {
246
243
  RpcEndpoints::new(
247
244
  endpoints
248
245
  .into_iter()
249
- .map(|(chain, url)| (chain, RpcEndpoint::Url(url))),
246
+ .map(|(chain, url)| (chain, RpcEndpointUrl::new(url))),
250
247
  )
251
248
  })
252
249
  .unwrap_or_default(),
@@ -267,6 +264,7 @@ impl SolidityTestRunnerConfigArgs {
267
264
  .into_iter()
268
265
  .map(|AddressLabel { address, label }| Ok((address.try_cast()?, label)))
269
266
  .collect::<Result<_, napi::Error>>()?,
267
+ seed: fuzz.seed,
270
268
  allow_internal_expect_revert: allow_internal_expect_revert.unwrap_or(false),
271
269
  };
272
270
 
@@ -282,7 +280,6 @@ impl SolidityTestRunnerConfigArgs {
282
280
  let config = edr_napi_core::solidity::config::TestRunnerConfig {
283
281
  project_root: project_root.into(),
284
282
  include_traces: include_traces.unwrap_or_default().into(),
285
- test_fail: test_fail.unwrap_or_default(),
286
283
  isolate,
287
284
  ffi,
288
285
  sender: sender.map(TryCast::try_cast).transpose()?,
@@ -370,7 +367,7 @@ impl TryFrom<FuzzConfigArgs> for FuzzConfig {
370
367
  } = value;
371
368
 
372
369
  let failure_persist_dir = failure_persist_dir.map(PathBuf::from);
373
- let failure_persist_file = failure_persist_file.unwrap_or("failures".to_string());
370
+ let failure_persist_file = failure_persist_file.unwrap_or_else(|| "failures".to_string());
374
371
  let seed = seed
375
372
  .map(|s| {
376
373
  s.parse().map_err(|_err| {
@@ -461,6 +458,10 @@ pub struct InvariantConfigArgs {
461
458
  /// process is disabled if set to 0.
462
459
  /// Defaults to 5000.
463
460
  pub shrink_run_limit: Option<u32>,
461
+ /// The maximum number of rejects via `vm.assume` which can be encountered
462
+ /// during a single invariant run.
463
+ /// Defaults to 65536.
464
+ pub max_assume_rejects: Option<u32>,
464
465
  }
465
466
 
466
467
  impl InvariantConfigArgs {
@@ -514,6 +515,7 @@ impl From<InvariantConfigArgs> for InvariantConfig {
514
515
  include_storage,
515
516
  include_push_bytes,
516
517
  shrink_run_limit,
518
+ max_assume_rejects,
517
519
  } = value;
518
520
 
519
521
  let failure_persist_dir = failure_persist_dir.map(PathBuf::from);
@@ -557,6 +559,10 @@ impl From<InvariantConfigArgs> for InvariantConfig {
557
559
  invariant.shrink_run_limit = shrink_run_limit;
558
560
  }
559
561
 
562
+ if let Some(max_assume_rejects) = max_assume_rejects {
563
+ invariant.max_assume_rejects = max_assume_rejects;
564
+ }
565
+
560
566
  invariant
561
567
  }
562
568
  }
@@ -264,7 +264,7 @@ impl TestResult {
264
264
  }),
265
265
  decoded_logs: test_result.decoded_logs,
266
266
  kind: match test_result.kind {
267
- edr_solidity_tests::result::TestKind::Standard(gas_consumed) => {
267
+ edr_solidity_tests::result::TestKind::Unit { gas: gas_consumed } => {
268
268
  Either3::A(StandardTestKind {
269
269
  consumed_gas: BigInt::from(gas_consumed),
270
270
  })
@@ -283,11 +283,27 @@ impl TestResult {
283
283
  runs,
284
284
  calls,
285
285
  reverts,
286
+ metrics,
287
+ failed_corpus_replays,
286
288
  } => Either3::C(InvariantTestKind {
287
289
  // usize as u64 is always safe
288
290
  runs: BigInt::from(runs as u64),
289
291
  calls: BigInt::from(calls as u64),
290
292
  reverts: BigInt::from(reverts as u64),
293
+ metrics: metrics
294
+ .into_iter()
295
+ .map(|(name, metric)| {
296
+ (
297
+ name,
298
+ InvariantMetrics {
299
+ calls: BigInt::from(metric.calls as u64),
300
+ reverts: BigInt::from(metric.reverts as u64),
301
+ discards: BigInt::from(metric.discards as u64),
302
+ },
303
+ )
304
+ })
305
+ .collect(),
306
+ failed_corpus_replays: BigInt::from(failed_corpus_replays as u64),
291
307
  }),
292
308
  },
293
309
  duration_ns: BigInt::from(test_result.duration.as_nanos()),
@@ -336,7 +352,7 @@ impl From<edr_solidity_tests::result::TestStatus> for TestStatus {
336
352
  }
337
353
  }
338
354
 
339
- /// See [`edr_solidity_tests::result::TestKind::Standard`]
355
+ /// See [`edr_solidity_tests::result::TestKind::Unit`]
340
356
  #[napi(object)]
341
357
  #[derive(Debug, Clone)]
342
358
  pub struct StandardTestKind {
@@ -397,6 +413,27 @@ pub struct InvariantTestKind {
397
413
  /// See [`edr_solidity_tests::result::TestKind::Invariant`]
398
414
  #[napi(readonly)]
399
415
  pub reverts: BigInt,
416
+ /// See [`edr_solidity_tests::result::TestKind::Invariant`]
417
+ #[napi(readonly)]
418
+ pub metrics: std::collections::HashMap<String, InvariantMetrics>,
419
+ /// See [`edr_solidity_tests::result::TestKind::Invariant`]
420
+ #[napi(readonly)]
421
+ pub failed_corpus_replays: BigInt,
422
+ }
423
+
424
+ /// See [`edr_solidity_tests::result::InvariantMetrics`]
425
+ #[napi(object)]
426
+ #[derive(Debug, Clone)]
427
+ pub struct InvariantMetrics {
428
+ // Count of fuzzed selector calls.
429
+ #[napi(readonly)]
430
+ pub calls: BigInt,
431
+ // Count of fuzzed selector reverts.
432
+ #[napi(readonly)]
433
+ pub reverts: BigInt,
434
+ // Count of fuzzed selector discards (through assume cheatcodes).
435
+ #[napi(readonly)]
436
+ pub discards: BigInt,
400
437
  }
401
438
 
402
439
  /// Original sequence size and sequence of calls used as a counter example
@@ -543,10 +580,19 @@ impl CallTrace {
543
580
  /// Instantiates a `CallTrace` with the details from a node and the supplied
544
581
  /// children.
545
582
  fn new(node: &traces::CallTraceNode, children: Vec<Either<CallTrace, LogTrace>>) -> Self {
546
- let contract = node.trace.decoded.label.clone();
583
+ let contract = node
584
+ .trace
585
+ .decoded
586
+ .as_ref()
587
+ .and_then(|decoded| decoded.label.clone());
547
588
  let address = node.trace.address.to_checksum(None);
548
589
 
549
- let inputs = match &node.trace.decoded.call_data {
590
+ let inputs = match &node
591
+ .trace
592
+ .decoded
593
+ .as_ref()
594
+ .and_then(|decoded| decoded.call_data.as_ref())
595
+ {
550
596
  Some(traces::DecodedCallData { signature, args }) => {
551
597
  let name = signature
552
598
  .split('(')
@@ -559,7 +605,12 @@ impl CallTrace {
559
605
  None => Either::B(node.trace.data.as_ref().into()),
560
606
  };
561
607
 
562
- let outputs = match &node.trace.decoded.return_data {
608
+ let outputs = match node
609
+ .trace
610
+ .decoded
611
+ .as_ref()
612
+ .and_then(|decoded| decoded.return_data.as_ref())
613
+ {
563
614
  Some(outputs) => Either::A(outputs.clone()),
564
615
  None => {
565
616
  if node.kind().is_any_create() && node.trace.success {
@@ -676,7 +727,10 @@ impl CallTrace {
676
727
 
677
728
  impl From<&traces::CallLog> for LogTrace {
678
729
  fn from(log: &traces::CallLog) -> Self {
679
- let decoded_log = log.decoded.name.clone().zip(log.decoded.params.as_ref());
730
+ let decoded_log = log
731
+ .decoded
732
+ .as_ref()
733
+ .and_then(|decoded| decoded.name.clone().zip(decoded.params.as_ref()));
680
734
 
681
735
  let parameters = decoded_log.map_or_else(
682
736
  || {
package/src/trace.rs CHANGED
@@ -9,7 +9,7 @@ use std::sync::Arc;
9
9
 
10
10
  use edr_chain_spec::EvmHaltReason;
11
11
  use edr_primitives::bytecode::opcode::OpCode;
12
- use edr_runtime::trace::BeforeMessage;
12
+ use edr_tracing::BeforeMessage;
13
13
  use napi::bindgen_prelude::{BigInt, Either3, Uint8Array};
14
14
  use napi_derive::napi;
15
15
 
@@ -123,7 +123,7 @@ pub struct TracingStep {
123
123
  }
124
124
 
125
125
  impl TracingStep {
126
- pub fn new(step: &edr_runtime::trace::Step) -> Self {
126
+ pub fn new(step: &edr_tracing::Step) -> Self {
127
127
  let stack = step.stack.full().map_or_else(
128
128
  || {
129
129
  step.stack
@@ -162,11 +162,11 @@ pub struct TracingMessageResult {
162
162
  #[napi]
163
163
  #[derive(Clone)]
164
164
  pub struct RawTrace {
165
- inner: Arc<edr_runtime::trace::Trace<EvmHaltReason>>,
165
+ inner: Arc<edr_tracing::Trace<EvmHaltReason>>,
166
166
  }
167
167
 
168
- impl From<Arc<edr_runtime::trace::Trace<EvmHaltReason>>> for RawTrace {
169
- fn from(value: Arc<edr_runtime::trace::Trace<EvmHaltReason>>) -> Self {
168
+ impl From<Arc<edr_tracing::Trace<EvmHaltReason>>> for RawTrace {
169
+ fn from(value: Arc<edr_tracing::Trace<EvmHaltReason>>) -> Self {
170
170
  Self { inner: value }
171
171
  }
172
172
  }
@@ -179,15 +179,13 @@ impl RawTrace {
179
179
  .messages
180
180
  .iter()
181
181
  .map(|message| match message {
182
- edr_runtime::trace::TraceMessage::Before(message) => {
182
+ edr_tracing::TraceMessage::Before(message) => {
183
183
  Either3::A(TracingMessage::from(message))
184
184
  }
185
- edr_runtime::trace::TraceMessage::Step(step) => Either3::B(TracingStep::new(step)),
186
- edr_runtime::trace::TraceMessage::After(message) => {
187
- Either3::C(TracingMessageResult {
188
- execution_result: ExecutionResult::from(message),
189
- })
190
- }
185
+ edr_tracing::TraceMessage::Step(step) => Either3::B(TracingStep::new(step)),
186
+ edr_tracing::TraceMessage::After(message) => Either3::C(TracingMessageResult {
187
+ execution_result: ExecutionResult::from(message),
188
+ }),
191
189
  })
192
190
  .collect()
193
191
  }