-
Notifications
You must be signed in to change notification settings - Fork 28
Add flashtestation builder tx #282
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
Conversation
46380ae
to
41c42bf
Compare
79aff67
to
0b9b3a3
Compare
41c42bf
to
01573b2
Compare
0b9b3a3
to
581ebac
Compare
01573b2
to
32146ac
Compare
581ebac
to
8768d27
Compare
32146ac
to
2499332
Compare
} | ||
} | ||
}; | ||
match result { |
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.
it looks like this conversion from the evm result to TxSimulateResult
is repeated in simulate_verify_block_proof_tx
, can you separate it into another function?
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.
this will be cleaned up in favour of #285
} | ||
} | ||
|
||
fn check_verify_block_proof_log(&self, logs: &[Log]) -> bool { |
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.
do the iter().any()
thing and elide this function since it'll just be a short line then
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.
this is removed in a later PR
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 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.
But that PR isn't going into main. If we merge this PR then that one later (and I can't predict how much later) then main ends up in a dirty state
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 don't think this is a blocking change to merging this PR and #285 is intended to be a fast follow that is going to be run on mainnet. This is preliminary flashtestations code to ensure the whole flow works on experimental
11f6b6a
to
5787983
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.
Pull Request Overview
Adds flashtestations builder transaction logic (registration and block proof verification) and exposes additional payload context accessors needed for computing block content hashes.
- Introduces FlashtestationsBuilderTx with funding, registration, and block proof verification flows.
- Adds a new LogMismatch revert reason and a helper constructor BuilderTransactionError::other.
- Makes previously internal OpPayloadBuilderCtx accessors public (parent_hash, timestamp, etc.) to support new logic.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
File | Description |
---|---|
flashtestations/service.rs | Replaces inline stub with instantiation of new FlashtestationsBuilderTx and passes args. |
flashtestations/mod.rs | Adds builder_tx module and new LogMismatch revert error variant. |
flashtestations/builder_tx.rs | New implementation of funding, registration, and block proof verification logic. |
builders/standard/builder_tx.rs | Updates import path for FlashtestationsBuilderTx. |
builders/flashblocks/builder_tx.rs | Updates import path and switches to new error helper. |
builders/context.rs | Widens visibility of multiple context accessors; adds parent_hash and timestamp helpers. |
builders/builder_tx.rs | Adds BuilderTransactionError::other convenience constructor. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
pub struct FlashtestationsBuilderTxArgs { | ||
pub attestation: Vec<u8>, | ||
pub extra_registration_data: Bytes, | ||
pub tee_service_signer: Signer, | ||
pub funding_key: Signer, | ||
pub funding_amount: U256, | ||
pub registry_address: Address, | ||
pub builder_policy_address: Address, | ||
pub builder_proof_version: u8, | ||
pub enable_block_proofs: bool, | ||
pub registered: bool, | ||
} |
Copilot
AI
Oct 16, 2025
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.
The registered flag provided in FlashtestationsBuilderTxArgs is never applied; new() always initializes registered with an empty OnceLock, causing the initial known registration status to be ignored and potentially triggering unnecessary registration attempts. Set the OnceLock when args.registered is true, e.g. let mut lock = OnceLock::new(); if args.registered { let _ = lock.set(true); } and assign lock to the struct, or store the initial state separately.
Copilot uses AI. Check for mistakes.
impl FlashtestationsBuilderTx { | ||
pub fn new(args: FlashtestationsBuilderTxArgs) -> Self { | ||
Self { | ||
attestation: args.attestation, | ||
extra_registration_data: args.extra_registration_data, | ||
tee_service_signer: args.tee_service_signer, | ||
funding_key: args.funding_key, | ||
funding_amount: args.funding_amount, | ||
registry_address: args.registry_address, | ||
builder_policy_address: args.builder_policy_address, | ||
builder_proof_version: args.builder_proof_version, | ||
registered: OnceLock::new(), | ||
enable_block_proofs: args.enable_block_proofs, | ||
} | ||
} |
Copilot
AI
Oct 16, 2025
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.
The registered flag provided in FlashtestationsBuilderTxArgs is never applied; new() always initializes registered with an empty OnceLock, causing the initial known registration status to be ignored and potentially triggering unnecessary registration attempts. Set the OnceLock when args.registered is true, e.g. let mut lock = OnceLock::new(); if args.registered { let _ = lock.set(true); } and assign lock to the struct, or store the initial state separately.
Copilot uses AI. Check for mistakes.
signed_tx: register_tx, | ||
is_top_of_block: false, | ||
}), | ||
false, |
Copilot
AI
Oct 16, 2025
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.
After a successful simulated registration and construction of the real registration transaction, the returned boolean is false, preventing the caller from marking the TEE service as registered; this leads to an extra redundant registration attempt until a revert confirms TEEServiceAlreadyRegistered. Change the second tuple value to true to reflect successful registration.
false, | |
true, |
Copilot uses AI. Check for mistakes.
match self.register_tee_service_tx(ctx, &mut evm) { | ||
Ok((_, registered)) => { | ||
if registered { | ||
let _ = self.registered.set(registered); | ||
} | ||
Ok(()) | ||
} | ||
Err(e) => Err(BuilderTransactionError::other(e)), | ||
} |
Copilot
AI
Oct 16, 2025
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.
Successful new registrations (which currently return false from register_tee_service_tx) never set the OnceLock, so the builder repeats registration until a revert marks it as already registered; combined with the incorrect false return this wastes gas. After adjusting register_tee_service_tx to return true on success, set the flag unconditionally when registration succeeds or explicitly handle both success and already-registered cases.
Copilot uses AI. Check for mistakes.
evm.modify_cfg(|cfg| { | ||
cfg.disable_balance_check = true; | ||
}); | ||
match self.register_tee_service_tx(ctx, &mut evm) { |
Copilot
AI
Oct 16, 2025
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.
Wrapping an existing BuilderTransactionError with BuilderTransactionError::other(e) erases its original variant, hindering downstream handling or pattern matching; return Err(e) directly to preserve semantic detail.
Copilot uses AI. Check for mistakes.
} | ||
Ok(()) | ||
} | ||
Err(e) => Err(BuilderTransactionError::other(e)), |
Copilot
AI
Oct 16, 2025
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.
Wrapping an existing BuilderTransactionError with BuilderTransactionError::other(e) erases its original variant, hindering downstream handling or pattern matching; return Err(e) directly to preserve semantic detail.
Err(e) => Err(BuilderTransactionError::other(e)), | |
Err(e) => Err(e), |
Copilot uses AI. Check for mistakes.
let block_content_hash = Self::compute_block_content_hash( | ||
transactions.clone(), | ||
ctx.parent_hash(), |
Copilot
AI
Oct 16, 2025
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.
Cloning the entire transactions vector just to pass it into compute_block_content_hash is unnecessary and can incur allocation and copy costs; change compute_block_content_hash to accept a slice (&[OpTransactionSigned]) and pass transactions by reference to avoid cloning.
Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
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.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
let block_content_hash = Self::compute_block_content_hash( | ||
transactions.clone(), | ||
ctx.parent_hash(), | ||
ctx.block_number(), | ||
ctx.timestamp(), | ||
); |
Copilot
AI
Oct 16, 2025
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.
transactions.clone() is redundant because verify_block_proof_tx already owns the Vec. Remove the clone and pass transactions directly, or change compute_block_content_hash to accept &[OpTransactionSigned] to avoid unnecessary allocations.
Copilot uses AI. Check for mistakes.
builder_txs.extend(self.verify_block_proof_tx( | ||
info.executed_transactions.clone(), | ||
ctx, | ||
&mut evm, | ||
)?); |
Copilot
AI
Oct 16, 2025
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.
Cloning info.executed_transactions here causes a full vector copy even when block proofs are enabled every block. If immutability is sufficient, pass a slice (&info.executed_transactions) and adjust verify_block_proof_tx to take &[OpTransactionSigned] to avoid repeated cloning.
Copilot uses AI. Check for mistakes.
π Summary
Add flashtestations builder tx and registration logic into built block
π‘ Motivation and Context
β I have completed the following steps:
make lint
make test