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

Add no error type #722

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Changes from 1 commit
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
26 changes: 25 additions & 1 deletion fendermint/vm/interpreter/src/fvm/state/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// SPDX-License-Identifier: Apache-2.0, MIT

use anyhow::{anyhow, Context};
use ethers::abi::{AbiDecode, AbiEncode, AbiError};
use ethers::contract::ContractRevert;
use ethers::prelude::Selector;
use ethers::types as et;

use fvm_ipld_blockstore::Blockstore;
Expand Down Expand Up @@ -52,7 +55,7 @@ pub struct GatewayCaller<DB> {
xnet: ContractCaller<
DB,
XnetMessagingFacet<MockProvider>,
xnet_messaging_facet::XnetMessagingFacetErrors,
NoErrors,
>,
}

Expand Down Expand Up @@ -360,3 +363,24 @@ fn membership_to_power_table(

pt
}

#[derive(Clone, ethers::contract::EthAbiType, Debug, PartialEq, Eq, Hash)]
pub struct NoErrors {}

impl ContractRevert for NoErrors {
fn valid_selector(_selector: Selector) -> bool {
unreachable!("valid_selector should not have been called")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably going to crash the node if there is an error. NoRevert does it safer I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, missed it

}
}

impl AbiDecode for NoErrors {
fn decode(_bytes: impl AsRef<[u8]>) -> Result<Self, AbiError> {
unreachable!("decode should not have been called")
}
}

impl AbiEncode for NoErrors {
fn encode(self) -> Vec<u8> {
unreachable!("encode should not have been called")
}
}
Loading