#[non_exhaustive]#[repr(u32)]pub enum AnvilNodeError {
TransactionHalt {
inner: Box<Halt>,
transaction_hash: Box<H256>,
},
TransactionValidationFailed {
inner: Box<TransactionValidation>,
transaction_hash: Box<H256>,
},
TransactionGasEstimationFailed {
inner: Box<GasEstimation>,
transaction_data: Vec<u8>,
},
TimestampBackwardsError {
timestamp_requested: U64,
timestamp_now: U64,
},
SerializationError {
transaction_type: String,
from: Box<H256>,
to: Box<H256>,
reason: String,
},
GenericError {
message: String,
},
}
Expand description
Domain: AnvilZKsync
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
TransactionHalt
§Summary
Transaction execution reverted and gas was burned.
§Description
This error occurs when a transaction execution is reverted due to an error in the anvil-zksync virtual machine execution and all gas is burned. This is a wrapper error that contains a more specific error inside it.
The VM may fail for various reasons including:
- Account validation failures (signature issues, nonce mismatches)
- Paymaster-related errors (when testing account abstraction features)
- Gas limit exceedance
- Storage access limitations
- Contract execution failures
When using anvil-zksync for testing, these failures are valuable signals that help you identify issues with your contracts or transactions before deploying to the real ZKSync network.
TransactionValidationFailed
§Summary
Transaction validation failed in anvil-zksync.
§Description
This error occurs when a transaction validation is failed and it is not executed. This is a wrapper error that contains a more specific validation error inside it, which provides details about the cause of failure.
The validation may fail for various reasons including:
- Gas limit exceedance
- Invalid gas limit value
- maxFeePerGas exceeding maxPriorityFeePerGas, and so on.
When using anvil-zksync for testing, these errors are valuable signals that help you identify issues with your contracts or transactions before deploying to the real ZKSync network.
TransactionGasEstimationFailed
§Summary
Transaction gas estimation failed in anvil-zksync.
§Description
This error occurs when a gas estimation for transaction failed. This is a wrapper error that contains a more specific gas estimation error inside it, which provides details about the cause of failure.
TimestampBackwardsError
§Summary
Requested block timestamp is earlier than the current timestamp.
§Description
This error occurs when attempting to set a future block timestamp to a value that is earlier than the timestamp of the most recently mined block.
In anvil-zksync, block timestamps must always increase monotonically. This simulates the behavior of real blockchain networks where time only moves forward. Each new block must have a timestamp greater than its predecessor.
Anvil-zksync provides methods to manipulate time for testing purposes (like evm_increaseTime
and evm_setNextBlockTimestamp
), but these can only move time forward, never backward.
Block timestamps in anvil-zksync are used by:
- Smart contracts that rely on
block.timestamp
for time-dependent logic - System contracts that need to track event timing
- Time-locked functionality in DeFi applications and governance protocols
When testing contracts that have time-dependent logic, it’s important to ensure that any manipulated timestamps move forward in time, not backward.
SerializationError
§Summary
Failed to serialize transaction request into a valid transaction.
§Description
This error occurs when anvil-zksync is unable to convert a transaction request into a properly formatted transaction object. This typically happens during transaction creation or gas estimation when the request contains invalid or incompatible parameters.