#[non_exhaustive]#[repr(u32)]pub enum AnvilNodeError {
TransactionHalt {
inner: Box<Halt>,
transaction_hash: Box<H256>,
},
TransactionValidationFailed {
inner: Box<TransactionValidation>,
transaction_hash: Box<H256>,
},
TimestampBackwardsError {
timestamp_requested: U64,
timestamp_now: U64,
},
GenericError {
message: String,
},
}
Expand description
Domain: AnvilZKsync
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
TransactionHalt
§Summary
Transaction execution halted in anvil-zksync.
§Description
This error occurs when a transaction execution is halted due to an error in the anvil-zksync virtual machine execution. This is a wrapper error that contains a more specific halt error inside it, which provides details about the cause of the halt.
The VM may halt execution 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 halts 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 the halt.
The validation may 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.
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.