Skip to content
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

Wide merkle query #16093

Merged
merged 42 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d96eb19
wide merkle query
fabrizio-m Sep 19, 2024
cc3d2bf
missing comment
fabrizio-m Sep 19, 2024
c29b3f1
proper depth on range
fabrizio-m Sep 19, 2024
f446563
domain separation
fabrizio-m Sep 19, 2024
38fb17b
handle answer
fabrizio-m Sep 19, 2024
f5937a0
versioning
fabrizio-m Sep 20, 2024
4f84b95
back to previous query
fabrizio-m Sep 20, 2024
ed16dab
remove to_latest
fabrizio-m Sep 23, 2024
77ab99b
unify in single query
fabrizio-m Sep 23, 2024
d633026
check leaves are power of 2
fabrizio-m Sep 23, 2024
c54ff14
removed unused functions
fabrizio-m Sep 24, 2024
250c655
extra checks for length
fabrizio-m Sep 24, 2024
1229ef8
handle exception
fabrizio-m Sep 24, 2024
d4b9dba
misc
fabrizio-m Sep 24, 2024
812a188
move to array
fabrizio-m Sep 24, 2024
d7eece3
update rpc
fabrizio-m Sep 25, 2024
6250c36
proper rpc response update
fabrizio-m Sep 25, 2024
3f47ce7
variable with query
fabrizio-m Sep 25, 2024
bf3d52f
fix
fabrizio-m Sep 30, 2024
362db02
Merge branch 'compatible' into fabrizio-m/wide-merkle-queries
fabrizio-m Sep 30, 2024
0e77722
fix domain separation
fabrizio-m Oct 3, 2024
4777937
Merge branch 'compatible' into fabrizio-m/wide-merkle-queries
fabrizio-m Oct 3, 2024
c5e5a97
add comment about query depth
fabrizio-m Oct 3, 2024
7fd1dd6
remove print
fabrizio-m Oct 4, 2024
d5f29c0
Merge branch 'compatible' into fabrizio-m/wide-merkle-queries
fabrizio-m Oct 4, 2024
c973512
Merge remote-tracking branch 'origin/compatible' into fabrizio-m/wide…
deepthiskumar Oct 15, 2024
e9cb154
reject if depth of received subtree is is greater than the requested …
deepthiskumar Nov 9, 2024
c1c12c9
move subtree depth constants to compile-config
deepthiskumar Nov 11, 2024
d26d015
update sync ledger unit tests with variable subtree depths
deepthiskumar Nov 12, 2024
db10629
move subtree depth constants to genesis constants, Runtime_config.dae…
deepthiskumar Nov 12, 2024
a27d3cc
Merge remote-tracking branch 'origin/compatible' into fabrizio-m/wide…
deepthiskumar Nov 13, 2024
c14616d
move sync ledger constants back to compile time
deepthiskumar Nov 19, 2024
a32c8ab
Merge remote-tracking branch 'origin/compatible' into fabrizio-m/wide…
deepthiskumar Nov 19, 2024
8848b69
fix typo in comment
deepthiskumar Nov 19, 2024
4a15962
update syncable ledger tests
deepthiskumar Nov 19, 2024
95f4052
Merge remote-tracking branch 'origin/compatible' into fabrizio-m/wide…
deepthiskumar Nov 20, 2024
8f500b8
return sync ledger answer or error, not option
deepthiskumar Nov 21, 2024
12fb304
tests for requested subtree depth > max subtree depth
deepthiskumar Nov 21, 2024
305fba1
return error if downgrading; other review comments
deepthiskumar Nov 21, 2024
45c6517
remove max depth check by receiver; add tests for edge cases
deepthiskumar Nov 22, 2024
7732404
Add Merkle_address.extend, use it for array init in ledger sync
mrmr1993 Nov 20, 2024
36801fc
Merge remote-tracking branch 'origin/compatible' into fabrizio-m/wide…
deepthiskumar Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions src/lib/mina_ledger/sync_ledger.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,30 @@ module Answer = struct
module Stable = struct
[@@@no_toplevel_latest_type]

module V3 = struct
type t =
( Ledger_hash.Stable.V1.t
, Account.Stable.V2.t )
Syncable_ledger.Answer.Stable.V2.t
[@@deriving sexp, to_yojson]

let to_latest = Fn.id
end

module V2 = struct
type t =
( Ledger_hash.Stable.V1.t
, Account.Stable.V2.t )
Syncable_ledger.Answer.Stable.V1.t
[@@deriving sexp, to_yojson]

let to_latest = Fn.id
let to_latest x = Syncable_ledger.Answer.Stable.V1.to_latest Fn.id x

(* Not a standard versioning function *)

(** Attempts to downgrade v3 -> v2 *)
let from_v3 : V3.t -> t =
fun x -> Syncable_ledger.Answer.Stable.V1.from_v2 x
end
end]

Expand All @@ -79,12 +95,31 @@ module Query = struct
module Stable = struct
[@@@no_toplevel_latest_type]

module V2 = struct
type t =
Ledger.Location.Addr.Stable.V1.t Syncable_ledger.Query.Stable.V2.t
[@@deriving sexp, to_yojson, hash, compare]

let to_latest = Fn.id
end

module V1 = struct
type t =
Ledger.Location.Addr.Stable.V1.t Syncable_ledger.Query.Stable.V1.t
[@@deriving sexp, to_yojson, hash, compare]

let to_latest = Fn.id
let to_latest : t -> V2.t = Syncable_ledger.Query.Stable.V1.to_latest

(* Not a standard versioning function *)

(** Attempts to downgrade v3 -> v2 *)
deepthiskumar marked this conversation as resolved.
Show resolved Hide resolved
let from_v2 : V2.t -> t = function
| What_child_hashes (a, _) ->
What_child_hashes a
| What_contents a ->
What_contents a
| Num_accounts ->
Num_accounts
end
end]

Expand Down
49 changes: 46 additions & 3 deletions src/lib/mina_networking/rpcs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,13 @@ module Answer_sync_ledger_query = struct
include Master
end)

module V3 = struct
module V4 = struct
module T = struct
type query = Ledger_hash.Stable.V1.t * Sync_ledger.Query.Stable.V1.t
type query = Ledger_hash.Stable.V1.t * Sync_ledger.Query.Stable.V2.t
[@@deriving sexp]

type response =
(( Sync_ledger.Answer.Stable.V2.t
(( Sync_ledger.Answer.Stable.V3.t
, Bounded_types.Wrapped_error.Stable.V1.t )
Result.t
[@version_asserted] )
Expand All @@ -399,6 +399,49 @@ module Answer_sync_ledger_query = struct
include Register (T')
end

module V3 = struct
module T = struct
type query = Ledger_hash.Stable.V1.t * Sync_ledger.Query.Stable.V1.t
[@@deriving sexp]

type response =
(( Sync_ledger.Answer.Stable.V2.t
, Bounded_types.Wrapped_error.Stable.V1.t )
Result.t
[@version_asserted] )
[@@deriving sexp]

let query_of_caller_model : Master.T.query -> query =
fun (h, q) -> (h, Sync_ledger.Query.Stable.V1.from_v2 q)

let callee_model_of_query : query -> Master.T.query =
fun (h, q) -> (h, Sync_ledger.Query.Stable.V1.to_latest q)

let response_of_callee_model : Master.T.response -> response = function
| Ok a ->
Ok (Sync_ledger.Answer.Stable.V2.from_v3 a)
| Error e ->
Error e

let caller_model_of_response : response -> Master.T.response = function
| Ok a ->
Ok (Sync_ledger.Answer.Stable.V2.to_latest a)
| Error e ->
Error e
end

module T' =
Perf_histograms.Rpc.Plain.Decorate_bin_io
(struct
include M
include Master
end)
(T)

include T'
include Register (T')
end

let receipt_trust_action_message (_, query) =
( "Answer_sync_ledger_query: $query"
, [ ("query", Sync_ledger.Query.to_yojson query) ] )
Expand Down
Loading