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

Error propagation from NearExt::call #3455

Open
ilblackdragon opened this issue Oct 5, 2020 · 4 comments
Open

Error propagation from NearExt::call #3455

ilblackdragon opened this issue Oct 5, 2020 · 4 comments
Assignees
Labels
A-EVM Area: Native EVM implementation and support C-bug Category: This is a bug T-Aurora Team: issues relevant to the Aurora team

Comments

@ilblackdragon
Copy link
Member

ilblackdragon commented Oct 5, 2020

There is a TODO error right now that gets ignored, as some errors are not due to runtime and can be non deterministic. Also return value is vector which is limiting.

Instead should propagate error via state and catch in on high level.

@ailisp
Copy link
Member

ailisp commented Nov 2, 2020

Didn't have time to start, moving to current epoch

@ailisp
Copy link
Member

ailisp commented Nov 17, 2020

@ilblackdragon
Did an investigation today, however find it impossible to propagate error due to how openethereum is designed.
First the TODO is this one (omit uninteresting details):

impl<'a> vm::Ext for NearExt<'a> {
    fn create(
...
    ) -> Result<ContractCreateResult, TrapKind> {
        // TODO: better error propagation.
        interpreter::deploy_code(
        ...
        )
        .map_err(|_| TrapKind::Call(ActionParams::default()))
    }
}

And interpreter::deploy_code has a reasonable good structure of error types:

  • could fail coz of duplicate contract
  • could fail due to insufficient balance to transfer
  • fail due to one of evm error, convert to near error by convert_vm_error

each above case => Err(VMLogicError::EvmError(...))

And

  • success Ok(ContractCreateResult::Created(...))
  • fail due to call contructor fail => Ok(ContractCreateResult::Reverted(gas_need_to_refund)

However, when interpreter::deploy_code return to Ext::create on NearExt, this has to be converted to Result<ContractCreateResult, TrapKind>, because openethereum-73b1d27a6fe08245/2662d19/ethcore/evm/src/interpreter/mod.rs, exec_instruction calls

let create_result = ext.create(
...
);

and (without change openethereum), this must be Result<ContractCreateResult, TrapKind> type and its structure is:

/// Result of externalities create function.
pub enum ContractCreateResult {
	/// Returned when creation was successfull.
	/// Contains an address of newly created contract and gas left.
	Created(Address, U256),
	/// Returned when contract creation failed.
	/// VM doesn't have to know the reason.
	Failed,
	/// Reverted with REVERT.
	Reverted(U256, ReturnData),
}
pub enum TrapKind {
	Call(ActionParams),
	Create(ActionParams, Address),
}

So there is no way to propogate well structured error in interpreter::deploy_code to Ext::create on NearExt and higher level.

@ailisp
Copy link
Member

ailisp commented Nov 18, 2020

@nearmax, @evgenykuzyakov @ilblackdragon or @artob
Can you confirm my analysis is valid, and if so, is this worth to do in a bounty, to modify openethereum to make this error propagation becomes possible? Thanks

@alexauroradev alexauroradev added the C-bug Category: This is a bug label Dec 4, 2020
@alexauroradev alexauroradev changed the title [EVM] Error propagation from NearExt::call Error propagation from NearExt::call Dec 4, 2020
@artob artob assigned artob and unassigned ailisp Jan 14, 2021
@bowenwang1996 bowenwang1996 added the T-Aurora Team: issues relevant to the Aurora team label Jun 29, 2021
@stale
Copy link

stale bot commented Sep 27, 2021

This issue has been automatically marked as stale because it has not had recent activity in the last 2 months.
It will be closed in 7 days if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the S-stale label Sep 27, 2021
@akhi3030 akhi3030 removed the S-stale label Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-EVM Area: Native EVM implementation and support C-bug Category: This is a bug T-Aurora Team: issues relevant to the Aurora team
Projects
None yet
Development

No branches or pull requests

6 participants