@nomicfoundation/edr 0.12.0-next.4 → 0.12.0-next.6

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.
@@ -8,7 +8,7 @@ use edr_napi_core::solidity::{
8
8
  use edr_solidity::artifacts::ArtifactId;
9
9
  use edr_solidity_tests::{
10
10
  contracts::ContractsByArtifact, decode::RevertDecoder, evm_context::L1EvmBuilder,
11
- multi_runner::TestContract, revm::context::TxEnv, MultiContractRunner,
11
+ multi_runner::TestContract, MultiContractRunner,
12
12
  };
13
13
  use napi::tokio;
14
14
  use napi_derive::napi;
@@ -33,14 +33,14 @@ impl SyncTestRunnerFactory for L1TestRunnerFactory {
33
33
  let runner = tokio::task::block_in_place(|| {
34
34
  runtime
35
35
  .block_on(MultiContractRunner::<
36
- edr_eth::l1::BlockEnv,
36
+ edr_chain_l1::BlockEnv,
37
37
  (),
38
38
  L1EvmBuilder,
39
- edr_eth::l1::HaltReason,
40
- edr_eth::l1::SpecId,
39
+ edr_chain_l1::HaltReason,
40
+ edr_chain_l1::Hardfork,
41
41
  _,
42
- edr_eth::l1::InvalidTransaction,
43
- TxEnv,
42
+ edr_chain_l1::InvalidTransaction,
43
+ edr_chain_l1::TxEnv,
44
44
  >::new(
45
45
  config.try_into()?,
46
46
  contracts,
@@ -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
- edr_eth::l1::BlockEnv,
37
+ edr_op::BlockEnv,
38
38
  _,
39
39
  OpEvmBuilder,
40
- edr_op::OpHaltReason,
41
- edr_op::OpSpecId,
40
+ edr_op::HaltReason,
41
+ edr_op::Hardfork,
42
42
  _,
43
43
  edr_op::transaction::InvalidTransaction,
44
- edr_op::transaction::OpTxEnv<edr_eth::l1::TxEnv>,
44
+ edr_op::transaction::OpTxEnv<edr_chain_l1::TxEnv>,
45
45
  >::new(
46
46
  config.try_into()?,
47
47
  contracts,
@@ -1,6 +1,6 @@
1
1
  use std::sync::{Mutex, OnceLock};
2
2
 
3
- use edr_eth::spec::HaltReasonTrait;
3
+ use edr_evm_spec::HaltReasonTrait;
4
4
  use edr_napi_core::solidity::config::TracingConfigWithBuffers;
5
5
  use edr_solidity::{
6
6
  artifacts::BuildInfoConfigWithBuffers,
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<edr_eth::l1::HaltReason>> for ExitCode {
54
- fn from(code: edr_solidity::exit_code::ExitCode<edr_eth::l1::HaltReason>) -> Self {
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(edr_eth::l1::HaltReason::OutOfGas(_)) => Self::OUT_OF_GAS,
61
- ExitCode::Halt(edr_eth::l1::HaltReason::OpcodeNotFound | edr_eth::l1::HaltReason::InvalidFEOpcode
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
- | edr_eth::l1::HaltReason::NotActivated) => Self::INVALID_OPCODE,
64
- ExitCode::Halt(edr_eth::l1::HaltReason::StackUnderflow) => Self::STACK_UNDERFLOW,
65
- ExitCode::Halt(edr_eth::l1::HaltReason::CreateContractSizeLimit) => Self::CODESIZE_EXCEEDS_MAXIMUM,
66
- ExitCode::Halt(edr_eth::l1::HaltReason::CreateCollision) => Self::CREATE_COLLISION,
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
  }
@@ -57,10 +57,17 @@ impl ReturnData {
57
57
  return Ok(String::new());
58
58
  }
59
59
 
60
+ if !self.is_error_return_data() {
61
+ return Err(napi::Error::new(
62
+ napi::Status::InvalidArg,
63
+ "VM Exception while processing transaction: Expected return data to be a Error(string)",
64
+ ));
65
+ }
66
+
60
67
  let result = Error::abi_decode(&self.value[..]).map_err(|_err| {
61
68
  napi::Error::new(
62
69
  napi::Status::InvalidArg,
63
- "Expected return data to be a Error(string) and contain a valid string",
70
+ "VM Exception while processing transaction: Expected return data to contain a valid string",
64
71
  )
65
72
  })?;
66
73
 
@@ -69,10 +76,17 @@ impl ReturnData {
69
76
 
70
77
  #[napi(catch_unwind)]
71
78
  pub fn decode_panic(&self) -> napi::Result<BigInt> {
79
+ if !self.is_panic_return_data() {
80
+ return Err(napi::Error::new(
81
+ napi::Status::InvalidArg,
82
+ "VM Exception while processing transaction: Expected return data to be a Panic(uint256)",
83
+ ));
84
+ }
85
+
72
86
  let result = Panic::abi_decode(&self.value[..]).map_err(|_err| {
73
87
  napi::Error::new(
74
88
  napi::Status::InvalidArg,
75
- "Expected return data to be a Error(string) and contain a valid string",
89
+ "VM Exception while processing transaction: Expected return data to contain a valid uint256",
76
90
  )
77
91
  })?;
78
92
 
package/src/trace.rs CHANGED
@@ -7,8 +7,9 @@
7
7
 
8
8
  use std::sync::Arc;
9
9
 
10
- use edr_eth::{bytecode::opcode::OpCode, l1};
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<l1::HaltReason>>,
165
+ inner: Arc<edr_evm::trace::Trace<EvmHaltReason>>,
165
166
  }
166
167
 
167
- impl From<Arc<edr_evm::trace::Trace<l1::HaltReason>>> for RawTrace {
168
- fn from(value: Arc<edr_evm::trace::Trace<l1::HaltReason>>) -> Self {
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
  }