-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fault proving: Populate ContractsRawCode when processing Create Transaction in global merkle root crate #2652
Fault proving: Populate ContractsRawCode when processing Create Transaction in global merkle root crate #2652
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing this. Overall looks good but there are two tiny blockers I can see:
- A dangling todo that should reference an issue.
- An
as
conversion in production code.
If these are addressed I'd happily approve this PR.
7f0ff15
to
ebe1f20
Compare
let contract_id = tx | ||
.metadata() | ||
.as_ref() | ||
.map(|metadata| metadata.body.contract_id) | ||
.ok_or(anyhow::anyhow!( | ||
"Create transaction does not have a contract ID in its metadata" | ||
))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't rely on existence of the contract_id
in metadata. I would suggest to use contract_id
from ContractCreated
output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 0f91ceb, but I'm curious to know why the metadata is unreliable.
2457f06
to
bbf6361
Compare
ebe1f20
to
4177a75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit :)
d103ddb
to
ee3edba
Compare
} | ||
|
||
// TODO: https://github.com/FuelLabs/fuel-core/issues/2654 | ||
// This code is copied from the executor. We should refactor it to be shared. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. It's not super obvious to me who should own this function. Maybe add it to where TransactionBuilder
is maintained. Or add the functionality to the TransactionBuilder
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a separate PR (#2654) where I add it to fuel-core-types
behind the test-helpers
feature. Happy to discuss if this is the right place there.
|
||
// TODO: https://github.com/FuelLabs/fuel-core/issues/2654 | ||
// This code is copied from the executor. We should refactor it to be shared. | ||
fn create_contract(bytecode: &[u8], rng: &mut impl rand::RngCore) -> Create { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename this create_contract_tx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: e6aadd5
// CreateBody is not publicly exported, so we need to use a generic type | ||
// and ensure that all trait bounds are satisfied |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, removed in be996d8
d0572ee
to
e6aadd5
Compare
Co-authored-by: Mårten Blankfors <marten@blankfors.se>
Co-authored-by: Mårten Blankfors <marten@blankfors.se>
Co-authored-by: Mårten Blankfors <marten@blankfors.se>
e6aadd5
to
6bc31c6
Compare
## Version 0.41.6 ### Added - [2668](#2668): Expose gas price service test helpers - [2621](#2598): Global merkle root storage updates process upgrade transactions. - [2650](#2650): Populate `ProcessedTransactions` table in global merkle root storage. - [2667](#2667): Populate `Blobs` table in global merkle root storage. - [2652](#2652): Global Merkle Root storage crate: Add Raw contract bytecode to global merkle root storage when processing Create transactions. ### Fixed - [2673](#2673): Change read behavior on the InMemoryTransaction to use offset and allow not equal buf size (fix CCP and LDC broken from FuelLabs/fuel-vm#847)
fn process_create_transaction(&mut self, tx: &Create) -> anyhow::Result<()> { | ||
let bytecode_witness_index = tx.bytecode_witness_index(); | ||
let witnesses = tx.witnesses(); | ||
let bytecode = witnesses[usize::from(*bytecode_witness_index)].as_vec(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If bytecode_witness_index
is malicious, it will panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that clippy missed this 🤔 thanks for spotting!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created hotfix PR #2677
Linked Issues/PRs
Closes #2587
Description
Checklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]