Skip to content

Commit af94dfa

Browse files
committed
chain: Address review comments
In particular, restore some important error analysis in EthereumAdapter that got lost in the rebase
1 parent 190788b commit af94dfa

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

chain/ethereum/src/ethereum_adapter.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use anyhow::Context;
21
use futures::future;
32
use futures::prelude::*;
43
use graph::blockchain::BlockHash;
@@ -510,6 +509,9 @@ impl EthereumAdapter {
510509
const PARITY_BAD_JUMP_PREFIX: &str = "Bad jump";
511510
const PARITY_STACK_LIMIT_PREFIX: &str = "Out of stack";
512511

512+
// See f0af4ab0-6b7c-4b68-9141-5b79346a5f61.
513+
const PARITY_OUT_OF_GAS: &str = "Out of gas";
514+
513515
const PARITY_VM_EXECUTION_ERROR: i64 = -32015;
514516
const PARITY_REVERT_PREFIX: &str = "Reverted 0x";
515517

@@ -549,7 +551,7 @@ impl EthereumAdapter {
549551
Err(web3::Error::Rpc(rpc_error))
550552
if GETH_EXECUTION_ERRORS
551553
.iter()
552-
.any(|e| rpc_error.message.contains(e)) =>
554+
.any(|e| rpc_error.message.to_lowercase().contains(e)) =>
553555
{
554556
Err(EthereumContractCallError::Revert(rpc_error.message))
555557
}
@@ -564,7 +566,8 @@ impl EthereumAdapter {
564566
|| data.starts_with(PARITY_BAD_JUMP_PREFIX)
565567
|| data.starts_with(PARITY_STACK_LIMIT_PREFIX)
566568
|| data == PARITY_BAD_INSTRUCTION_FE
567-
|| data == PARITY_BAD_INSTRUCTION_FD =>
569+
|| data == PARITY_BAD_INSTRUCTION_FD
570+
|| data == PARITY_OUT_OF_GAS =>
568571
{
569572
let reason = if data == PARITY_BAD_INSTRUCTION_FE {
570573
PARITY_BAD_INSTRUCTION_FE.to_owned()
@@ -829,11 +832,7 @@ impl EthereumAdapter {
829832
.timeout_secs(*JSON_RPC_TIMEOUT)
830833
.run(move || {
831834
let web3 = web3.cheap_clone();
832-
async move {
833-
{
834-
web3.eth().chain_id().await
835-
}
836-
}
835+
async move { web3.eth().chain_id().await }
837836
})
838837
.await?,
839838
)
@@ -860,7 +859,7 @@ impl EthereumAdapterTrait for EthereumAdapter {
860859
.timeout_secs(20)
861860
.run(move || {
862861
let web3 = web3.cheap_clone();
863-
async move { web3.net().version().await.with_context(|| "boom") }
862+
async move { web3.net().version().await.map_err(Into::into) }
864863
})
865864
.boxed();
866865

chain/ethereum/src/trigger.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,9 @@ pub struct EthereumTransactionData {
363363

364364
impl From<&'_ Transaction> for EthereumTransactionData {
365365
fn from(tx: &Transaction) -> EthereumTransactionData {
366-
// Old versions of web3 (before commit 11277e07) always had a value
367-
// for `from`; newer versions make this an option, but it's not
368-
// clear what the value should be if this is ever `None`
369-
let from = tx.from.expect("tx.from must have a value");
366+
// unwrap: this is always `Some` for txns that have been mined
367+
// (see https://github.com/tomusdrw/rust-web3/pull/407)
368+
let from = tx.from.unwrap();
370369
EthereumTransactionData {
371370
hash: tx.hash,
372371
index: tx.transaction_index.unwrap().as_u64().into(),

0 commit comments

Comments
 (0)