Skip to content

Conversation

@IlyasRidhuan
Copy link
Contributor

@IlyasRidhuan IlyasRidhuan commented Jan 14, 2026

Protocol contract mutations turned out to be much more complex. Might've been easier to implement a hardcoded set.

We need to ensure we re-validate the enqueued calls whenever we mutate the protocol contracts since we could have invalidated some addresses.

Note: The TS simulation required a change to match the cpp simulator

@IlyasRidhuan IlyasRidhuan force-pushed the ir/01-09-feat_avm_mutate_globals branch from ed25916 to 23929ad Compare January 14, 2026 14:44
@IlyasRidhuan IlyasRidhuan force-pushed the ir/01-13-feat_avm_protocol_contract_mutations branch 2 times, most recently from 23aabe7 to 1054464 Compare January 14, 2026 14:57
@IlyasRidhuan IlyasRidhuan force-pushed the ir/01-09-feat_avm_mutate_globals branch from 23929ad to ed98aa8 Compare January 15, 2026 11:20
@IlyasRidhuan IlyasRidhuan force-pushed the ir/01-13-feat_avm_protocol_contract_mutations branch from 1054464 to 3bc2633 Compare January 15, 2026 11:20
@IlyasRidhuan IlyasRidhuan force-pushed the ir/01-09-feat_avm_mutate_globals branch from ed98aa8 to 5864a4d Compare January 15, 2026 13:02
@IlyasRidhuan IlyasRidhuan force-pushed the ir/01-13-feat_avm_protocol_contract_mutations branch from 3bc2633 to 2584a41 Compare January 15, 2026 13:02
protected contractsDB: PublicContractsDB,
protected globalVariables: GlobalVariables,
config?: Partial<PublicSimulatorConfig>,
protected protocolContracts: ProtocolContracts = ProtocolContractsList,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

needed to change the interface because we would otherwise force to read from the list

// MIN_FEE must be >= 1 to prevent underflow in compute_effective_gas_fees, since
// global_variables.gas_fees is hardcoded to {1, 1}. This can change once we enable
// smart mutations of global variables that maintain the invariant max_fees_per_gas >= gas_fees.
// MIN_FEE must be >= 1 to prevent underflow in compute_effective_gas_fees.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comment was missed when we mutated hte global variables in an earlier pr


namespace {

void update_enqueued_calls_for_protocol_contract(Tx& tx,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a bit of a code-smell, but we need to update the addresses used in the enqueued calls whenever we modify the protocol contracts and we would have potentially invalidated addresses that are referenced by enqueued calls

// For protocol contracts, also add instances keyed by canonical address (1-11).
// This is needed because protocol contracts are looked up by canonical address,
// but the derived address in protocol_contracts.derived_addresses maps to the actual instance.
for (size_t i = 0; i < tx_data.protocol_contracts.derived_addresses.size(); ++i) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is so that when we look up the protocol contracts we can retrieve the instance

break;
}

// Clear any protocol contract derived addresses that reference addresses no longer in the contract set.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is pretty lazy, but i was running into some issues with calling stale contract addresses. I'll investigate a cleaner way to ensure we dont need a clean up step after mutations.

@IlyasRidhuan IlyasRidhuan marked this pull request as ready for review January 15, 2026 13:17
@IlyasRidhuan IlyasRidhuan changed the base branch from ir/01-09-feat_avm_mutate_globals to graphite-base/19586 January 15, 2026 14:23
@IlyasRidhuan IlyasRidhuan force-pushed the ir/01-13-feat_avm_protocol_contract_mutations branch from 2584a41 to 8b90735 Compare January 15, 2026 14:53
@IlyasRidhuan IlyasRidhuan changed the base branch from graphite-base/19586 to ir/01-09-feat_avm_mutate_globals January 15, 2026 14:53
Base automatically changed from ir/01-09-feat_avm_mutate_globals to merge-train/avm January 15, 2026 16:32
@IlyasRidhuan IlyasRidhuan force-pushed the ir/01-13-feat_avm_protocol_contract_mutations branch 2 times, most recently from 4c7af27 to 2c157cb Compare January 15, 2026 18:33
@AztecBot
Copy link
Collaborator

AztecBot commented Jan 15, 2026

Flakey Tests

🤖 says: This CI run detected 2 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/94e663dd0c028c31�94e663dd0c028c318;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_epochs/epochs_invalidate_block.parallel.test.ts "committee member invalidates a block if proposer does not come through" (95s) (code: 1) group:e2e-p2p-epoch-flakes (\033IlyasRidhuan\033: feat(avm): protocol contractg mutations)
\033FLAKED\033 (8;;http://ci.aztec-labs.com/a9f49d9ddcee15c9�a9f49d9ddcee15c98;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_epochs/epochs_high_tps_block_building.test.ts (281s) (code: 1) group:e2e-p2p-epoch-flakes (\033IlyasRidhuan\033: feat(avm): protocol contractg mutations)

@IlyasRidhuan IlyasRidhuan force-pushed the ir/01-13-feat_avm_protocol_contract_mutations branch from 2c157cb to 16c9a69 Compare January 16, 2026 14:33
@IlyasRidhuan IlyasRidhuan merged commit e80488d into merge-train/avm Jan 16, 2026
9 checks passed
@IlyasRidhuan IlyasRidhuan deleted the ir/01-13-feat_avm_protocol_contract_mutations branch January 16, 2026 15:08
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.

4 participants