Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update revm and map new errors to rpc #4696

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/revm/revm-inspectors/src/tracing/builder/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ impl ParityTraceBuilder {

// Calculate the stack items at this step
let push_stack = {
let step_op = step.op.u8();
let step_op = step.op.get();
let show_stack: usize;
if (opcode::PUSH0..=opcode::PUSH32).contains(&step_op) {
show_stack = 1;
Expand Down Expand Up @@ -482,7 +482,7 @@ impl ParityTraceBuilder {
let cost = self
.spec_id
.and_then(|spec_id| {
spec_opcode_gas(spec_id).get(step.op.u8() as usize).map(|op| op.get_gas())
spec_opcode_gas(spec_id).get(step.op.get() as usize).map(|op| op.get_gas())
})
.unwrap_or_default();

Expand Down
4 changes: 2 additions & 2 deletions crates/revm/revm-inspectors/src/tracing/js/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ impl OpObj {
let to_string = FunctionObjectBuilder::new(
context,
NativeFunction::from_copy_closure(move |_this, _args, _ctx| {
let op = OpCode::try_from_u8(value)
let op = OpCode::new(value)
.or_else(|| {
// if the opcode is invalid, we'll use the invalid opcode to represent it
// because this is invoked before the opcode is
// executed, the evm will eventually return a `Halt`
// with invalid/unknown opcode as result
let invalid_opcode = 0xfe;
OpCode::try_from_u8(invalid_opcode)
OpCode::new(invalid_opcode)
})
.expect("is valid opcode;");
let s = op.to_string();
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/revm-inspectors/src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,13 @@ impl TracingInspector {
let stack =
self.config.record_stack_snapshots.then(|| interp.stack.clone()).unwrap_or_default();

let op = OpCode::try_from_u8(interp.current_opcode())
let op = OpCode::new(interp.current_opcode())
.or_else(|| {
// if the opcode is invalid, we'll use the invalid opcode to represent it because
// this is invoked before the opcode is executed, the evm will eventually return a
// `Halt` with invalid/unknown opcode as result
let invalid_opcode = 0xfe;
OpCode::try_from_u8(invalid_opcode)
OpCode::new(invalid_opcode)
})
.expect("is valid opcode;");

Expand Down
4 changes: 2 additions & 2 deletions crates/revm/revm-inspectors/src/tracing/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,15 +637,15 @@ impl CallTraceStep {
/// Returns true if the step is a STOP opcode
#[inline]
pub(crate) fn is_stop(&self) -> bool {
matches!(self.op.u8(), opcode::STOP)
matches!(self.op.get(), opcode::STOP)
}

/// Returns true if the step is a call operation, any of
/// CALL, CALLCODE, DELEGATECALL, STATICCALL, CREATE, CREATE2
#[inline]
pub(crate) fn is_calllike_op(&self) -> bool {
matches!(
self.op.u8(),
self.op.get(),
opcode::CALL |
opcode::DELEGATECALL |
opcode::STATICCALL |
Expand Down
22 changes: 22 additions & 0 deletions crates/rpc/rpc/src/eth/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,18 @@ pub enum RpcInvalidTransactionError {
/// Block `blob_gas_price` is greater than tx-specified `max_fee_per_blob_gas` after Cancun.
#[error("max fee per blob gas less than block blob gas fee")]
BlobFeeCapTooLow,
/// Blob transaction has a versioned hash with an invalid blob
#[error("blob hash version mismatch")]
BlobHashVersionMismatch,
/// Blob transaction has no versioned hashes
#[error("blob transaction missing blob hashes")]
BlobTransactionMissingBlobHashes,
/// Blob transaction has too many blobs
#[error("blob transaction exceeds max blobs per block")]
TooManyBlobs,
/// Blob transaction is a create transaction
#[error("blob transaction is a create transaction")]
BlobTransactionIsCreate,
}

impl RpcInvalidTransactionError {
Expand Down Expand Up @@ -394,6 +406,16 @@ impl From<revm::primitives::InvalidTransaction> for RpcInvalidTransactionError {
InvalidTransaction::BlobGasPriceGreaterThanMax => {
RpcInvalidTransactionError::BlobFeeCapTooLow
}
InvalidTransaction::EmptyBlobs => {
RpcInvalidTransactionError::BlobTransactionMissingBlobHashes
}
InvalidTransaction::BlobVersionNotSupported => {
RpcInvalidTransactionError::BlobHashVersionMismatch
}
InvalidTransaction::TooManyBlobs => RpcInvalidTransactionError::TooManyBlobs,
InvalidTransaction::BlobCreateTransaction => {
RpcInvalidTransactionError::BlobTransactionIsCreate
}
}
}
}
Expand Down
Loading