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 RLP implementation of receipt is incorrect #1259

Closed
yangby-cryptape opened this issue Jul 2, 2023 · 1 comment
Closed

The RLP implementation of receipt is incorrect #1259

yangby-cryptape opened this issue Jul 2, 2023 · 1 comment
Assignees
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 RLP implementation of receipt is incorrect.

Details

Here is the RLP implementation of receipt in Axon:

impl Encodable for Receipt {
fn rlp_append(&self, s: &mut RlpStream) {
s.begin_list(13)
.append(&self.tx_hash)
.append(&self.block_number)
.append(&self.block_hash)
.append(&self.tx_index)
.append(&self.state_root)
.append(&self.used_gas)
.append(&self.logs_bloom)
.append_list(&self.logs)
.append(&self.log_index)
.append(&self.code_address)
.append(&self.sender)
.append(&bincode::serialize(&self.ret).unwrap())
.append(&self.removed);
}
}

Yes, in legacy Ethereu JSON-RPC Specification (a.k.a. Ethereum Execution API Specification now), a receipt will have more that 10 fields.

But when do RLP of a receipt, only 4 fields should be used, that was written in section 4.3.1 of Ethereum Yellow Paper since the day when Ethereum launched.

... ... the status code of the transaction, $R_{z}$, the cumulative gas used in the block containing the transaction receipt as of immediately after the transaction has happened, $R_{u}$, the set of logs created through execution of the transaction, $R_{l}$, and the Bloom filter composed from information in those logs, $R_{b}$:

... ...

The function $L_{R}$ prepares a transaction receipt for being transformed into an RLP-serialised byte array:

$$L_{R}(R) = (R_{z},R_{u},R_{b},R_{l})$$

Also, you could NOT restore a JSON-RPC receipt from a RLP-serialised receipt.

Expected Behavior

None.

OS

Not Associated

Axon version

No response

Kernel

Not Associated

Relevant log output

No response

Anything else?

No response

@KaoImin
Copy link
Contributor

KaoImin commented Aug 18, 2023

Fix in #1270

@KaoImin KaoImin closed this as completed Aug 18, 2023
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

No branches or pull requests

2 participants