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

The implemention of receipts root in block is incorrect #1258

Closed
yangby-cryptape opened this issue Jul 2, 2023 · 0 comments · Fixed by #1270
Closed

The implemention of receipts root in block is incorrect #1258

yangby-cryptape opened this issue Jul 2, 2023 · 0 comments · Fixed by #1270
Labels
t:bug Something isn't working

Comments

@yangby-cryptape
Copy link
Collaborator

yangby-cryptape commented Jul 2, 2023

Contact Details

No response

Current Behavior

Summary

If "Axon is compatible with Ethereum" as that written in the README.md, the implementation of receipts root in block is incorrect.

Details

  • The Block::receipts_root is set from ExecResp.receipt_root.

    receipts_root: exec_resp.receipt_root,

  • The ExecResp.receipt_root is merkle root of a list of hashes.

    ExecResp {
    state_root: new_state_root,
    receipt_root: TrieMerkle::from_iter(hashes.iter().enumerate())
    .root_hash()
    .unwrap_or_default(),
    gas_used: gas,
    tx_resp: res,
    }

  • Each hash in hashes is AxonExecutor::evm_exec(...).ret.

    let mut r = system_contract_dispatch(adapter, tx)
    .unwrap_or_else(|| Self::evm_exec(adapter, &config, &precompiles, tx));
    r.logs = adapter.get_logs();
    gas += r.gas_used;
    fee = fee.checked_add(r.fee_cost).unwrap_or(U256::max_value());
    hashes.push(Hasher::digest(&r.ret));

  • TxResp.ret is set from res.

    TxResp {
    exit_reason: exit,
    ret: res,

  • The res is transact_call(...).1

    let (exit, res) = match tx.transaction.unsigned.action() {
    TransactionAction::Call(addr) => executor.transact_call(
    tx.sender,
    *addr,
    *tx.transaction.unsigned.value(),
    tx.transaction.unsigned.data().to_vec(),
    gas_limit.as_u64(),
    access_list,
    ),
    TransactionAction::Create => executor.transact_create(
    tx.sender,
    *tx.transaction.unsigned.value(),
    tx.transaction.unsigned.data().to_vec(),
    gas_limit.as_u64(),
    access_list,
    ),
    };

  • So, the res is just Vec<u8> which represents the return data of the called contract, it is NOT the receipt of transaction.

Expected Behavior

None.

OS

Not Associated

Axon version

No response

Kernel

Not Associated

Relevant log output

No response

Anything else?

p.s. I don't like your issue template, at least it's not suitable for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant