Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

[fix] skip value is zero in end_tx #1600

Conversation

lightsing
Copy link
Contributor

No description provided.

@lightsing lightsing marked this pull request as ready for review September 13, 2023 08:05
@github-actions github-actions bot added the crate-bus-mapping Issues related to the bus-mapping workspace member label Sep 13, 2023
Copy link
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

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

LGTM.
Let me try to explain if I understand the fix. The PR refactored the coinbase transfer to transfer_to_irreversible, which implemented the correct behavior of transferring to the coinbase.
Especially, when the transfer value is zero and the coinbase account doesn't exist, the coinbase account won't be created.

@@ -277,10 +277,8 @@ fn gen_end_tx_steps(state: &mut CircuitInputStateRef) -> Result<ExecStep, Error>
if !found {
return Err(Error::AccountNotFound(state.block.coinbase));
}
let coinbase_account = coinbase_account.clone();
let coinbase_balance_prev = coinbase_account.balance;
let coinbase_exist = !coinbase_account.is_empty();
let coinbase_transfer_value = effective_tip * (state.tx.gas() - exec_step.gas_left);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we know when will the coinbase_transfer_value be zero? Is it when the signature or nonce was bad or tx.gas_limit was set to zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lispc said according to spec, the gas price can be zero, then value is zero. though it won't happen in real world

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a wrong assumption that the coinbase_transfer_value will never be zero so in the previous pr I didn't include this

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lispc said according to spec, the gas price can be zero, then value is zero.

Makes sense. Thanks for elaborating on it.

Copy link
Member

@ed255 ed255 left a comment

Choose a reason for hiding this comment

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

LGTM! This should fix the error found in #1581

Please @lightsing remember to add some description in the PR in future occasions, it helps us understand the context of the PR for reviewing.

@ChihChengLiang ChihChengLiang added this pull request to the merge queue Sep 13, 2023
Merged via the queue into privacy-scaling-explorations:main with commit f36df6e Sep 13, 2023
18 of 22 checks passed
@lispc
Copy link
Collaborator

lispc commented Sep 14, 2023

oh i think we should also change codes in evm_circuits? the assignment codes must be changed?

failed #1581

@ed255
Copy link
Member

ed255 commented Sep 15, 2023

oh i think we should also change codes in evm_circuits? the assignment codes must be changed?

failed #1581

Ah you're right! EndTxGadget::assign_exec_step needs to be updated to pick up the rw ops values following the same flow as the bus-mapping.

@lightsing lightsing deleted the upstream/fix/skip-zero branch September 22, 2023 05:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate-bus-mapping Issues related to the bus-mapping workspace member
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants