-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix eth RPC call context and fix gas estimate pipeline (#2633)
* Fix eth call contexts, and fix gas estimate pipeline * refactpr to use RPCError enum * Fix estimate gas bug * Fix rpc debug logs * Fix debug log * Remove empty from address error * Only run account balance check if sender address is specified * Fix failing tests * fmt py * remove debugging * More refactor of RPCError messages * Refactor net RPC * Revert to header not found * Fix rust lint * Rust lint
- Loading branch information
Showing
14 changed files
with
479 additions
and
361 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use ain_evm::EVMError; | ||
use jsonrpsee::core::Error; | ||
|
||
pub enum RPCError { | ||
AccountError, | ||
BlockNotFound, | ||
Error(Box<dyn std::error::Error>), | ||
EvmError(EVMError), | ||
FromBlockGreaterThanToBlock, | ||
GasCapTooLow(u64), | ||
InsufficientFunds, | ||
InvalidBlockInput, | ||
InvalidDataInput, | ||
InvalidLogFilter, | ||
InvalidGasPrice, | ||
InvalidTransactionMessage, | ||
InvalidTransactionType, | ||
NonceCacheError, | ||
StateRootNotFound, | ||
TxExecutionFailed, | ||
ValueOverflow, | ||
} | ||
|
||
impl From<RPCError> for Error { | ||
fn from(e: RPCError) -> Self { | ||
match e { | ||
RPCError::AccountError => to_custom_err("error getting account"), | ||
RPCError::BlockNotFound => to_custom_err("header not found"), | ||
RPCError::Error(e) => Error::Custom(format!("{e:?}")), | ||
RPCError::EvmError(e) => Error::Custom(format!("error calling EVM : {e:?}")), | ||
RPCError::FromBlockGreaterThanToBlock => { | ||
to_custom_err("fromBlock is greater than toBlock") | ||
} | ||
RPCError::GasCapTooLow(cap) => { | ||
Error::Custom(format!("gas required exceeds allowance {:#?}", cap)) | ||
} | ||
RPCError::InsufficientFunds => to_custom_err("insufficient funds for transfer"), | ||
RPCError::InvalidBlockInput => { | ||
to_custom_err("both blockHash and fromBlock/toBlock specified") | ||
} | ||
RPCError::InvalidDataInput => { | ||
to_custom_err("data and input fields are mutually exclusive") | ||
} | ||
RPCError::InvalidGasPrice => { | ||
to_custom_err("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified") | ||
} | ||
RPCError::InvalidLogFilter => to_custom_err("invalid log filter"), | ||
RPCError::InvalidTransactionMessage => { | ||
to_custom_err("invalid transaction message parameters") | ||
} | ||
RPCError::InvalidTransactionType => to_custom_err("invalid transaction type specified"), | ||
RPCError::NonceCacheError => to_custom_err("could not cache account nonce"), | ||
RPCError::StateRootNotFound => to_custom_err("state root not found"), | ||
RPCError::TxExecutionFailed => to_custom_err("transaction execution failed"), | ||
RPCError::ValueOverflow => to_custom_err("value overflow"), | ||
} | ||
} | ||
} | ||
|
||
pub fn to_custom_err<T: ToString>(e: T) -> Error { | ||
Error::Custom(e.to_string()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.