@nomicfoundation/edr 0.6.4 → 0.6.5

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
@@ -376,7 +376,9 @@ export const enum ExitCode {
376
376
  /** Create init code size exceeds limit (runtime). */
377
377
  CODESIZE_EXCEEDS_MAXIMUM = 6,
378
378
  /** Create collision. */
379
- CREATE_COLLISION = 7
379
+ CREATE_COLLISION = 7,
380
+ /** Unknown halt reason. */
381
+ UNKNOWN_HALT_REASON = 8
380
382
  }
381
383
  export interface EvmStep {
382
384
  pc: number
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomicfoundation/edr",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "devDependencies": {
5
5
  "@napi-rs/cli": "^2.18.4",
6
6
  "@types/chai": "^4.2.0",
@@ -52,13 +52,13 @@
52
52
  "repository": "NomicFoundation/edr.git",
53
53
  "types": "index.d.ts",
54
54
  "dependencies": {
55
- "@nomicfoundation/edr-darwin-arm64": "0.6.4",
56
- "@nomicfoundation/edr-darwin-x64": "0.6.4",
57
- "@nomicfoundation/edr-linux-arm64-gnu": "0.6.4",
58
- "@nomicfoundation/edr-linux-arm64-musl": "0.6.4",
59
- "@nomicfoundation/edr-linux-x64-gnu": "0.6.4",
60
- "@nomicfoundation/edr-linux-x64-musl": "0.6.4",
61
- "@nomicfoundation/edr-win32-x64-msvc": "0.6.4"
55
+ "@nomicfoundation/edr-darwin-arm64": "0.6.5",
56
+ "@nomicfoundation/edr-darwin-x64": "0.6.5",
57
+ "@nomicfoundation/edr-linux-arm64-gnu": "0.6.5",
58
+ "@nomicfoundation/edr-linux-arm64-musl": "0.6.5",
59
+ "@nomicfoundation/edr-linux-x64-gnu": "0.6.5",
60
+ "@nomicfoundation/edr-linux-x64-musl": "0.6.5",
61
+ "@nomicfoundation/edr-win32-x64-msvc": "0.6.5"
62
62
  },
63
63
  "scripts": {
64
64
  "artifacts": "napi artifacts",
package/src/context.rs CHANGED
@@ -1,5 +1,6 @@
1
- use std::{io, ops::Deref, sync::Arc};
1
+ use std::{ops::Deref, sync::Arc};
2
2
 
3
+ #[cfg(feature = "tracing")]
3
4
  use napi::Status;
4
5
  use napi_derive::napi;
5
6
  use tracing_subscriber::{prelude::*, EnvFilter, Registry};
@@ -23,8 +24,7 @@ impl EdrContext {
23
24
  #[doc = "Creates a new [`EdrContext`] instance. Should only be called once!"]
24
25
  #[napi(constructor)]
25
26
  pub fn new() -> napi::Result<Self> {
26
- let context =
27
- Context::new().map_err(|e| napi::Error::new(Status::GenericFailure, e.to_string()))?;
27
+ let context = Context::new()?;
28
28
 
29
29
  Ok(Self {
30
30
  inner: Arc::new(context),
@@ -34,14 +34,13 @@ impl EdrContext {
34
34
 
35
35
  #[derive(Debug)]
36
36
  pub struct Context {
37
- _subscriber_guard: tracing::subscriber::DefaultGuard,
38
37
  #[cfg(feature = "tracing")]
39
38
  _tracing_write_guard: tracing_flame::FlushGuard<std::io::BufWriter<std::fs::File>>,
40
39
  }
41
40
 
42
41
  impl Context {
43
42
  /// Creates a new [`Context`] instance. Should only be called once!
44
- pub fn new() -> io::Result<Self> {
43
+ pub fn new() -> napi::Result<Self> {
45
44
  let fmt_layer = tracing_subscriber::fmt::layer()
46
45
  .with_file(true)
47
46
  .with_line_number(true)
@@ -54,8 +53,13 @@ impl Context {
54
53
 
55
54
  #[cfg(feature = "tracing")]
56
55
  let (flame_layer, guard) = {
57
- let (flame_layer, guard) =
58
- tracing_flame::FlameLayer::with_file("tracing.folded").unwrap();
56
+ let (flame_layer, guard) = tracing_flame::FlameLayer::with_file("tracing.folded")
57
+ .map_err(|err| {
58
+ napi::Error::new(
59
+ Status::GenericFailure,
60
+ format!("Failed to create tracing.folded file with error: {err:?}"),
61
+ )
62
+ })?;
59
63
 
60
64
  let flame_layer = flame_layer.with_empty_samples(false);
61
65
  (flame_layer, guard)
@@ -64,10 +68,14 @@ impl Context {
64
68
  #[cfg(feature = "tracing")]
65
69
  let subscriber = subscriber.with(flame_layer);
66
70
 
67
- let subscriber_guard = tracing::subscriber::set_default(subscriber);
71
+ if let Err(error) = tracing::subscriber::set_global_default(subscriber) {
72
+ println!(
73
+ "Failed to set global tracing subscriber with error: {error}\n\
74
+ Please only initialize EdrContext once per process to avoid this error."
75
+ );
76
+ }
68
77
 
69
78
  Ok(Self {
70
- _subscriber_guard: subscriber_guard,
71
79
  #[cfg(feature = "tracing")]
72
80
  _tracing_write_guard: guard,
73
81
  })
package/src/trace/exit.rs CHANGED
@@ -30,6 +30,8 @@ pub enum ExitCode {
30
30
  CODESIZE_EXCEEDS_MAXIMUM,
31
31
  /// Create collision.
32
32
  CREATE_COLLISION,
33
+ /// Unknown halt reason.
34
+ UNKNOWN_HALT_REASON,
33
35
  }
34
36
 
35
37
  impl fmt::Display for ExitCode {
@@ -43,6 +45,7 @@ impl fmt::Display for ExitCode {
43
45
  ExitCode::STACK_UNDERFLOW => write!(f, "Stack underflow"),
44
46
  ExitCode::CODESIZE_EXCEEDS_MAXIMUM => write!(f, "Codesize exceeds maximum"),
45
47
  ExitCode::CREATE_COLLISION => write!(f, "Create collision"),
48
+ ExitCode::UNKNOWN_HALT_REASON => write!(f, "Unknown halt reason"),
46
49
  }
47
50
  }
48
51
  }
@@ -62,7 +65,7 @@ impl From<edr_solidity::message_trace::ExitCode> for ExitCode {
62
65
  ExitCode::Halt(HaltReason::StackUnderflow) => Self::STACK_UNDERFLOW,
63
66
  ExitCode::Halt(HaltReason::CreateContractSizeLimit) => Self::CODESIZE_EXCEEDS_MAXIMUM,
64
67
  ExitCode::Halt(HaltReason::CreateCollision) => Self::CREATE_COLLISION,
65
- halt @ ExitCode::Halt(_) => panic!("Unmatched EDR exceptional halt: {halt:?}"),
68
+ ExitCode::Halt(_) => Self::UNKNOWN_HALT_REASON,
66
69
  }
67
70
  }
68
71
  }