-
Notifications
You must be signed in to change notification settings - Fork 283
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
feat: introduce avm circuit public inputs #9759
Conversation
@@ -111,7 +101,6 @@ impl PrivateCallDataValidator { | |||
self.validate_call(); | |||
self.validate_private_call_requests(); | |||
self.validate_public_call_requests(); | |||
self.validate_teardown_call_request(); |
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.
Moved into validate_public_call_requests
.
} else { | ||
1 | ||
}; | ||
validate_incrementing_counters_within_range( |
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.
Don't need to check it as teardown_call_request does not have a counter anymore.
@@ -85,10 +85,6 @@ impl PrivateKernelCircuitOutputValidator { | |||
private_call.historical_header, | |||
"mismatch historical_header", | |||
); | |||
assert( | |||
is_empty(self.output.constants.global_variables), |
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.
Removed this check as a new struct TxConstantData
is now used in private land, which includes all fields in CombinedConstantData
except for global_variables
.
@@ -34,6 +31,5 @@ pub fn meter_gas_used(data: CombinedAccumulatedData, gas_settings: GasSettings) | |||
metered_da_bytes += data.unencrypted_log_preimages_length as u32; | |||
metered_l2_gas += data.unencrypted_log_preimages_length as u32 * L2_GAS_PER_LOG_BYTE; | |||
|
|||
let teardown_gas = gas_settings.teardown_gas_limits; | |||
Gas::new(metered_da_bytes * DA_GAS_PER_BYTE, metered_l2_gas) + Gas::tx_overhead() + teardown_gas |
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.
Don't include teardown_gas
for private-only tx.
Before this, the users would have to set it to empty in GasSettings
to avoid paying extra fees, which was quite annoying.
Changes to public function bytecode sizes
🧾 Summary (100% most significant diffs)
Full diff report 👇
|
Changes to circuit sizes
🧾 Summary (100% most significant diffs)
Full diff report 👇
|
@@ -66,7 +67,7 @@ pub struct PrivateContext { | |||
nullifiers: BoundedVec<Nullifier, MAX_NULLIFIERS_PER_CALL>, | |||
|
|||
private_call_requests: BoundedVec<PrivateCallRequest, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL>, | |||
public_call_requests: BoundedVec<PublicCallRequest, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL>, | |||
public_call_requests: BoundedVec<Counted<PublicCallRequest>, MAX_ENQUEUED_CALLS_PER_CALL>, |
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.
Remove counter
from PublicCallRequest
and use Counted
to add counter
to any struct.
Will do the same for other side effects in another PR.
meter_gas_used(data) + Gas::tx_overhead() | ||
} | ||
|
||
pub fn meter_gas_used_revertible(data: PublicAccumulatedData, teardown_gas: Gas) -> Gas { | ||
meter_gas_used(data) + Gas::new(teardown_gas.da_gas, teardown_gas.l2_gas) |
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.
Don't add the teardown_gas
to revertible gas_used
in private_tail_to_public.
It is used to compute the transaction fee, and should be added when actually computing the transaction fee. (I think) it was added here to make the code for computing fee slightly simpler - adding gas used from both non-revertible and revertible. But there were code in some places that subtracted the teardown gas to get the actual gas used, which seemed more confusing.
With this change, the gas_used
from either private kernel tail or tail_to_public indicates the actual gas used. When computing transaction fee, it will be non_revertible_gas + revertible_gas + teardown_gas
.
self.hints.public_data_writes, | ||
self.output.end.public_data_update_requests, | ||
); | ||
let original_array = self.hints.public_data_writes; |
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.
Copied the code from assert_deduped_array
, and tweaked it so that it operates on the deduped array that contains different types to the items in the original array.
Can't be bothered to change assert_deduped_array
since we will remove the public kernel soon.
let all_public_data_update_requests = | ||
self.calculate_all_public_data_update_requests(transaction_fee); | ||
self.calculate_all_public_data_update_requests(self.transaction_fee); |
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.
transaction_fee
is either computed in private_base_rollup
or in the AVM and passed in from public_base_rollup
.
|
||
if read_hint.leaf_slot == 0 { | ||
if existing_update_index != MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_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.
Use the existing_update_index
to decide whether to update the pending set or the tree.
This makes the code in the orchestrator simpler. It doesn't have to check whether the write exists in the pending set to generate the hint. It can always generate the hint. And let the circuit decide whether to use the hint or not.
@@ -393,20 +393,6 @@ export class BBNativeRollupProver implements ServerCircuitProver { | |||
return emptyPrivateKernelProof; | |||
} | |||
|
|||
public async getEmptyTubeProof( |
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.
Removed this because it is exactly the same as getEmptyPrivateKernelProof
.
/** | ||
* Output data of the tx. | ||
*/ | ||
txEffect: TxEffect; |
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.
data: KernelCircuitPublicInputs
is removed from ProcessedTx
because it is no longer the type exported by all txs. Private-only txs still output KernelCircuitPublicInputs
. But txs containing public calls are now associated with AvmCircuitPublicIpnuts
.
We replace it with TxEffect
, which achieves what KernelCircuitPublicInputs
can do and more:
- The
finalPublicDataUpdateRequests
field can be removed becausetxEffect.publicDataWrites
contains all public data writes, including thefeePaymentPublicDataWrite
injected by the base rollup. - All 3 log preimages arrays can be removed because they are already in
TxEffect
.
* Is the struct empty? | ||
* @returns whether all members are empty. | ||
*/ | ||
isEmpty(): boolean { |
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.
Removing this as it was only used in avm.test.ts
, and I didn't want to add isEmpty
to AvmCircuitPublicInputs
and all its child types.
In real world we might never need to check if the inputs to the AVM is empty or not.
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.
Awesome work! Huge changeset....
No description provided.