@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.
- package/index.d.ts +27 -11
- package/package.json +8 -8
- package/src/account.rs +1 -1
- package/src/chains/generic.rs +21 -17
- package/src/chains/l1.rs +81 -76
- package/src/chains/op.rs +37 -31
- package/src/config.rs +111 -6
- package/src/context.rs +37 -56
- package/src/log.rs +2 -2
- package/src/mock/time.rs +55 -63
- package/src/mock.rs +2 -1
- package/src/provider/response.rs +4 -4
- package/src/result.rs +24 -69
- package/src/solidity_tests/l1.rs +6 -6
- package/src/solidity_tests/op.rs +4 -4
- package/src/solidity_tests/runner.rs +1 -1
- package/src/trace/exit.rs +9 -8
- package/src/trace/return_data.rs +16 -2
- package/src/trace.rs +5 -4
package/src/solidity_tests/l1.rs
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
36
|
+
edr_chain_l1::BlockEnv,
|
|
37
37
|
(),
|
|
38
38
|
L1EvmBuilder,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
edr_chain_l1::HaltReason,
|
|
40
|
+
edr_chain_l1::Hardfork,
|
|
41
41
|
_,
|
|
42
|
-
|
|
43
|
-
TxEnv,
|
|
42
|
+
edr_chain_l1::InvalidTransaction,
|
|
43
|
+
edr_chain_l1::TxEnv,
|
|
44
44
|
>::new(
|
|
45
45
|
config.try_into()?,
|
|
46
46
|
contracts,
|
package/src/solidity_tests/op.rs
CHANGED
|
@@ -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
|
-
|
|
37
|
+
edr_op::BlockEnv,
|
|
38
38
|
_,
|
|
39
39
|
OpEvmBuilder,
|
|
40
|
-
edr_op::
|
|
41
|
-
edr_op::
|
|
40
|
+
edr_op::HaltReason,
|
|
41
|
+
edr_op::Hardfork,
|
|
42
42
|
_,
|
|
43
43
|
edr_op::transaction::InvalidTransaction,
|
|
44
|
-
edr_op::transaction::OpTxEnv<
|
|
44
|
+
edr_op::transaction::OpTxEnv<edr_chain_l1::TxEnv>,
|
|
45
45
|
>::new(
|
|
46
46
|
config.try_into()?,
|
|
47
47
|
contracts,
|
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<
|
|
54
|
-
fn from(code: edr_solidity::exit_code::ExitCode<
|
|
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(
|
|
61
|
-
ExitCode::Halt(
|
|
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
|
-
|
|
|
64
|
-
ExitCode::Halt(
|
|
65
|
-
ExitCode::Halt(
|
|
66
|
-
ExitCode::Halt(
|
|
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
|
}
|
package/src/trace/return_data.rs
CHANGED
|
@@ -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
|
|
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
|
|
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::
|
|
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<
|
|
165
|
+
inner: Arc<edr_evm::trace::Trace<EvmHaltReason>>,
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
impl From<Arc<edr_evm::trace::Trace<
|
|
168
|
-
fn from(value: Arc<edr_evm::trace::Trace<
|
|
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
|
}
|