-
Notifications
You must be signed in to change notification settings - Fork 584
MIP Ref Impl: Increase zkApp account update limit #17386
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1309,16 +1309,33 @@ module Update_group = Make_update_group (struct | |
| failwith "zkapp_segment_of_controls: Unsupported combination" | ||
| end) | ||
|
|
||
| let zkapp_cost ~proof_segments ~signed_single_segments ~signed_pair_segments | ||
| ~(genesis_constants : Genesis_constants.t) () = | ||
| (*10.26*np + 10.08*n2 + 9.14*n1 < 69.45*) | ||
| let proof_cost = genesis_constants.zkapp_proof_update_cost in | ||
| let signed_pair_cost = genesis_constants.zkapp_signed_pair_update_cost in | ||
| let signed_single_cost = genesis_constants.zkapp_signed_single_update_cost in | ||
| Float.( | ||
| (proof_cost * of_int proof_segments) | ||
| + (signed_pair_cost * of_int signed_pair_segments) | ||
| + (signed_single_cost * of_int signed_single_segments)) | ||
| (** [zkapp_cost ~proof_segments ~signed_single_segments ~signed_pair_segments] | ||
| returns the cost of a zkapp command having such constitution. | ||
|
|
||
| The cost of a zkapp command is defined as the number of segments it have in | ||
| the base layer. | ||
|
|
||
| This is because SNARK Coordinator schedules single base proof/merge to each | ||
| SNARK worker. These proofs form a B-ary tree, where B is Pickles' branching | ||
| factor, i.e. the number of proofs Pickles could be merged at once. Under | ||
| current configuration, B is 2. | ||
|
|
||
| The latency before us getting a final proof would be the latency from root | ||
| to any leaf node. Given we have sufficient workers available, possible proof | ||
| trees would be more or less a balanced binary tree, so with n segments, the | ||
| latency would of Theta(log_B n), assuming all kind proofs requires roughly | ||
| same time to proof. | ||
|
|
||
| to ensure the latency of receving final proof to be smaller than some cap, | ||
| we could equally just restrict number of leave segments. For example, If we | ||
| want the tree to have at most [L] layers, we just ensure the cost for any | ||
| zkapp_command to be at most [B^L]. | ||
|
|
||
| WARN: this is only relevant after we merged SNARK worker rework PRs, please | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this warning can be removed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, rebasing onto compatible and removing it. |
||
| remove this warning if we've already done so. | ||
| *) | ||
| let zkapp_cost ~proof_segments ~signed_single_segments ~signed_pair_segments = | ||
| proof_segments + signed_single_segments + signed_pair_segments | ||
|
|
||
| (* Zkapp_command transactions are filtered using this predicate | ||
| - when adding to the transaction pool | ||
|
|
@@ -1361,14 +1378,17 @@ let valid_size (type aux) ~(genesis_constants : Genesis_constants.t) | |
| | Signed_pair -> | ||
| (proof_segments, signed_singles, signed_pairs + 1) ) | ||
| in | ||
| let cost_limit = genesis_constants.zkapp_transaction_cost_limit in | ||
| let max_event_elements = genesis_constants.max_event_elements in | ||
| let max_action_elements = genesis_constants.max_action_elements in | ||
| let Genesis_constants. | ||
| { max_event_elements | ||
| ; max_action_elements | ||
| ; max_zkapp_segment_per_transaction | ||
| ; _ | ||
| } = | ||
| genesis_constants | ||
| in | ||
| let zkapp_cost_within_limit = | ||
| Float.( | ||
| zkapp_cost ~proof_segments ~signed_single_segments ~signed_pair_segments | ||
| ~genesis_constants () | ||
| < cost_limit) | ||
| zkapp_cost ~proof_segments ~signed_single_segments ~signed_pair_segments | ||
| <= max_zkapp_segment_per_transaction | ||
| in | ||
| let valid_event_elements = num_event_elements <= max_event_elements in | ||
| let valid_action_elements = num_action_elements <= max_action_elements in | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -464,10 +464,7 @@ module Json_layout = struct | |
| type t = | ||
| { txpool_max_size : int option [@default None] | ||
| ; peer_list_url : string option [@default None] | ||
| ; zkapp_proof_update_cost : float option [@default None] | ||
| ; zkapp_signed_single_update_cost : float option [@default None] | ||
| ; zkapp_signed_pair_update_cost : float option [@default None] | ||
| ; zkapp_transaction_cost_limit : float option [@default None] | ||
| ; max_zkapp_segment_per_transaction : int option [@default None] | ||
| ; max_event_elements : int option [@default None] | ||
| ; max_action_elements : int option [@default None] | ||
| ; zkapp_cmd_limit_hardcap : int option [@default None] | ||
|
|
@@ -1271,10 +1268,7 @@ module Daemon = struct | |
| type t = Json_layout.Daemon.t = | ||
| { txpool_max_size : int option | ||
| ; peer_list_url : string option | ||
| ; zkapp_proof_update_cost : float option [@default None] | ||
| ; zkapp_signed_single_update_cost : float option [@default None] | ||
| ; zkapp_signed_pair_update_cost : float option [@default None] | ||
| ; zkapp_transaction_cost_limit : float option [@default None] | ||
| ; max_zkapp_segment_per_transaction : int option [@default None] | ||
| ; max_event_elements : int option [@default None] | ||
| ; max_action_elements : int option [@default None] | ||
| ; zkapp_cmd_limit_hardcap : int option [@default None] | ||
|
|
@@ -1303,18 +1297,9 @@ module Daemon = struct | |
| { txpool_max_size = | ||
| opt_fallthrough ~default:t1.txpool_max_size t2.txpool_max_size | ||
| ; peer_list_url = opt_fallthrough ~default:t1.peer_list_url t2.peer_list_url | ||
| ; zkapp_proof_update_cost = | ||
| opt_fallthrough ~default:t1.zkapp_proof_update_cost | ||
| t2.zkapp_proof_update_cost | ||
| ; zkapp_signed_single_update_cost = | ||
| opt_fallthrough ~default:t1.zkapp_signed_single_update_cost | ||
| t2.zkapp_signed_single_update_cost | ||
| ; zkapp_signed_pair_update_cost = | ||
| opt_fallthrough ~default:t1.zkapp_signed_pair_update_cost | ||
| t2.zkapp_signed_pair_update_cost | ||
| ; zkapp_transaction_cost_limit = | ||
| opt_fallthrough ~default:t1.zkapp_transaction_cost_limit | ||
| t2.zkapp_transaction_cost_limit | ||
| ; max_zkapp_segment_per_transaction = | ||
| opt_fallthrough ~default:t1.max_zkapp_segment_per_transaction | ||
| t2.max_zkapp_segment_per_transaction | ||
| ; max_event_elements = | ||
| opt_fallthrough ~default:t1.max_event_elements t2.max_event_elements | ||
| ; max_action_elements = | ||
|
|
@@ -1343,10 +1328,7 @@ module Daemon = struct | |
| let gen = | ||
| let open Quickcheck.Generator.Let_syntax in | ||
| let%bind txpool_max_size = Int.gen_incl 0 1000 in | ||
| let%bind zkapp_proof_update_cost = Float.gen_incl 0.0 100.0 in | ||
| let%bind zkapp_signed_single_update_cost = Float.gen_incl 0.0 100.0 in | ||
| let%bind zkapp_signed_pair_update_cost = Float.gen_incl 0.0 100.0 in | ||
| let%bind zkapp_transaction_cost_limit = Float.gen_incl 0.0 100.0 in | ||
| let%bind max_zkapp_segment_per_transaction = Int.gen_incl 0 50 in | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsure about these generators
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am as well. The old generator could generate a config with Where is it used? |
||
| let%bind max_event_elements = Int.gen_incl 0 100 in | ||
| let%bind zkapp_cmd_limit_hardcap = Int.gen_incl 0 1000 in | ||
| let%bind minimum_user_command_fee = | ||
|
|
@@ -1355,10 +1337,7 @@ module Daemon = struct | |
| let%map max_action_elements = Int.gen_incl 0 1000 in | ||
| { txpool_max_size = Some txpool_max_size | ||
| ; peer_list_url = None | ||
| ; zkapp_proof_update_cost = Some zkapp_proof_update_cost | ||
| ; zkapp_signed_single_update_cost = Some zkapp_signed_single_update_cost | ||
| ; zkapp_signed_pair_update_cost = Some zkapp_signed_pair_update_cost | ||
| ; zkapp_transaction_cost_limit = Some zkapp_transaction_cost_limit | ||
| ; max_zkapp_segment_per_transaction = Some max_zkapp_segment_per_transaction | ||
| ; max_event_elements = Some max_event_elements | ||
| ; max_action_elements = Some max_action_elements | ||
| ; zkapp_cmd_limit_hardcap = Some zkapp_cmd_limit_hardcap | ||
|
|
||
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.
1 param to rule them all :)