Skip to content

Conversation

avalonche
Copy link
Collaborator

πŸ“ Summary

Add flashtestations builder tx and registration logic into built block

πŸ’‘ Motivation and Context


βœ… I have completed the following steps:

  • Run make lint
  • Run make test
  • Added tests (if applicable)

@avalonche avalonche changed the base branch from main to updated-registration October 1, 2025 22:39
@avalonche avalonche force-pushed the add-flashtestation-builder-tx branch from 46380ae to 41c42bf Compare October 1, 2025 22:41
@avalonche avalonche force-pushed the updated-registration branch from 79aff67 to 0b9b3a3 Compare October 2, 2025 05:44
@avalonche avalonche force-pushed the add-flashtestation-builder-tx branch from 41c42bf to 01573b2 Compare October 2, 2025 05:45
@avalonche avalonche force-pushed the updated-registration branch from 0b9b3a3 to 581ebac Compare October 2, 2025 17:47
@avalonche avalonche force-pushed the add-flashtestation-builder-tx branch from 01573b2 to 32146ac Compare October 2, 2025 17:48
@avalonche avalonche force-pushed the updated-registration branch from 581ebac to 8768d27 Compare October 3, 2025 17:47
Base automatically changed from updated-registration to main October 3, 2025 17:47
@avalonche avalonche force-pushed the add-flashtestation-builder-tx branch from 32146ac to 2499332 Compare October 3, 2025 17:54
}
}
};
match result {
Copy link
Contributor

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?

Copy link
Collaborator Author

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 {
Copy link
Contributor

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

Copy link
Collaborator Author

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

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

Copy link
Collaborator Author

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

@Copilot Copilot AI review requested due to automatic review settings October 16, 2025 18:00
@avalonche avalonche force-pushed the add-flashtestation-builder-tx branch from 11f6b6a to 5787983 Compare October 16, 2025 18:00
@avalonche avalonche enabled auto-merge (squash) October 16, 2025 18:01
Copy link
Contributor

@Copilot Copilot AI left a 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.

Comment on lines +37 to +48
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,
}
Copy link

Copilot AI Oct 16, 2025

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.

Comment on lines +83 to +97
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,
}
}
Copy link

Copilot AI Oct 16, 2025

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,
Copy link

Copilot AI Oct 16, 2025

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.

Suggested change
false,
true,

Copilot uses AI. Check for mistakes.

Comment on lines +545 to +553
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)),
}
Copy link

Copilot AI Oct 16, 2025

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) {
Copy link

Copilot AI Oct 16, 2025

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)),
Copy link

Copilot AI Oct 16, 2025

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.

Suggested change
Err(e) => Err(BuilderTransactionError::other(e)),
Err(e) => Err(e),

Copilot uses AI. Check for mistakes.

Comment on lines +477 to +479
let block_content_hash = Self::compute_block_content_hash(
transactions.clone(),
ctx.parent_hash(),
Copy link

Copilot AI Oct 16, 2025

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.

@Copilot Copilot AI review requested due to automatic review settings October 16, 2025 18:04
Copy link
Contributor

@Copilot Copilot AI left a 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.

Comment on lines +477 to +482
let block_content_hash = Self::compute_block_content_hash(
transactions.clone(),
ctx.parent_hash(),
ctx.block_number(),
ctx.timestamp(),
);
Copy link

Copilot AI Oct 16, 2025

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.

Comment on lines +595 to +599
builder_txs.extend(self.verify_block_proof_tx(
info.executed_transactions.clone(),
ctx,
&mut evm,
)?);
Copy link

Copilot AI Oct 16, 2025

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.

@avalonche avalonche merged commit 5cd19de into main Oct 16, 2025
4 checks passed
@avalonche avalonche deleted the add-flashtestation-builder-tx branch October 16, 2025 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants