Alpha: use protocol parameters instead of sandbox to tune constants
This commit is contained in:
parent
98f30a3e85
commit
3d57055cca
@ -16,5 +16,12 @@
|
|||||||
[ "tz1iDPZLxcGf5CqCNpTuuMdtu3zKpJ6HvvFR", "btz1TaSfoSNhFoqwqbPC9iC19rN24KJtB7skD", "71300478465380003" ],
|
[ "tz1iDPZLxcGf5CqCNpTuuMdtu3zKpJ6HvvFR", "btz1TaSfoSNhFoqwqbPC9iC19rN24KJtB7skD", "71300478465380003" ],
|
||||||
[ "tz1i2kbtVu65dP739qLGRpJNujRM8pdpkH3p", "btz1USqQRuvASPXwseXkGTWeWv4dn3VwMVPEk", "283380756728119992" ],
|
[ "tz1i2kbtVu65dP739qLGRpJNujRM8pdpkH3p", "btz1USqQRuvASPXwseXkGTWeWv4dn3VwMVPEk", "283380756728119992" ],
|
||||||
[ "tz1LKGCg6ESJLDviHkT8Jc7tUwjw4h3d9MaF", "btz1YwCKMbBLRL1qkBjAHGCwjbWDqiTAEFpbw", "1357762577679880028" ]
|
[ "tz1LKGCg6ESJLDviHkT8Jc7tUwjw4h3d9MaF", "btz1YwCKMbBLRL1qkBjAHGCwjbWDqiTAEFpbw", "1357762577679880028" ]
|
||||||
]
|
],
|
||||||
|
"dictator_pubkey":
|
||||||
|
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
||||||
|
"time_between_blocks" : [ 1, 0 ],
|
||||||
|
"blocks_per_roll_snapshot" : 4,
|
||||||
|
"blocks_per_cycle" : 8,
|
||||||
|
"preserved_cycles" : 2,
|
||||||
|
"first_free_baking_slot" : 4
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,4 @@
|
|||||||
{
|
{
|
||||||
"genesis_pubkey":
|
"genesis_pubkey":
|
||||||
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2"
|
||||||
"dictator_pubkey":
|
|
||||||
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
|
||||||
"bootstrap_keys": [
|
|
||||||
"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav",
|
|
||||||
"edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9",
|
|
||||||
"edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV",
|
|
||||||
"edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU",
|
|
||||||
"edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n"
|
|
||||||
],
|
|
||||||
"time_between_blocks" : [ 1, 0 ],
|
|
||||||
"blocks_per_roll_snapshot" : 4,
|
|
||||||
"blocks_per_cycle" : 8,
|
|
||||||
"preserved_cycles" : 2,
|
|
||||||
"first_free_baking_slot" : 4
|
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,13 @@
|
|||||||
[ "tz1iDPZLxcGf5CqCNpTuuMdtu3zKpJ6HvvFR", "btz1TaSfoSNhFoqwqbPC9iC19rN24KJtB7skD", "71300478465380003" ],
|
[ "tz1iDPZLxcGf5CqCNpTuuMdtu3zKpJ6HvvFR", "btz1TaSfoSNhFoqwqbPC9iC19rN24KJtB7skD", "71300478465380003" ],
|
||||||
[ "tz1i2kbtVu65dP739qLGRpJNujRM8pdpkH3p", "btz1USqQRuvASPXwseXkGTWeWv4dn3VwMVPEk", "283380756728119992" ],
|
[ "tz1i2kbtVu65dP739qLGRpJNujRM8pdpkH3p", "btz1USqQRuvASPXwseXkGTWeWv4dn3VwMVPEk", "283380756728119992" ],
|
||||||
[ "tz1LKGCg6ESJLDviHkT8Jc7tUwjw4h3d9MaF", "btz1YwCKMbBLRL1qkBjAHGCwjbWDqiTAEFpbw", "1357762577679880028" ]
|
[ "tz1LKGCg6ESJLDviHkT8Jc7tUwjw4h3d9MaF", "btz1YwCKMbBLRL1qkBjAHGCwjbWDqiTAEFpbw", "1357762577679880028" ]
|
||||||
]
|
],
|
||||||
|
"dictator_pubkey":
|
||||||
|
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
||||||
|
"time_between_blocks" : [ 1, 0 ],
|
||||||
|
"blocks_per_cycle" : 128,
|
||||||
|
"blocks_per_roll_snapshot" : 32,
|
||||||
|
"preserved_cycles" : 1,
|
||||||
|
"first_free_baking_slot" : 4,
|
||||||
|
"proof_of_work_threshold": -1
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,4 @@
|
|||||||
{
|
{
|
||||||
"genesis_pubkey":
|
"genesis_pubkey":
|
||||||
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2"
|
||||||
"dictator_pubkey":
|
|
||||||
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
|
||||||
"bootstrap_keys": [
|
|
||||||
"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav",
|
|
||||||
"edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9",
|
|
||||||
"edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV",
|
|
||||||
"edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU",
|
|
||||||
"edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n"
|
|
||||||
],
|
|
||||||
"time_between_blocks" : [ 1, 0 ],
|
|
||||||
"blocks_per_cycle" : 128,
|
|
||||||
"blocks_per_roll_snapshot" : 32,
|
|
||||||
"preserved_cycles" : 1,
|
|
||||||
"first_free_baking_slot" : 4,
|
|
||||||
"proof_of_work_threshold": -1
|
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,13 @@ init_sandboxed_client() {
|
|||||||
[ "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU", "4000000000000" ],
|
[ "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU", "4000000000000" ],
|
||||||
[ "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n", "4000000000000" ]
|
[ "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n", "4000000000000" ]
|
||||||
],
|
],
|
||||||
"commitments": [
|
"dictator_pubkey":
|
||||||
]
|
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
||||||
|
"time_between_blocks" : [ 1, 0 ],
|
||||||
|
"blocks_per_roll_snapshot" : 4,
|
||||||
|
"blocks_per_cycle" : 8,
|
||||||
|
"preserved_cycles" : 2,
|
||||||
|
"first_free_baking_slot" : 4
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
@ -29,14 +29,7 @@ start_sandboxed_node() {
|
|||||||
cat > "$sandbox_file" <<EOF
|
cat > "$sandbox_file" <<EOF
|
||||||
{
|
{
|
||||||
"genesis_pubkey":
|
"genesis_pubkey":
|
||||||
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2"
|
||||||
"bootstrap_keys": [
|
|
||||||
"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav",
|
|
||||||
"edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9",
|
|
||||||
"edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV",
|
|
||||||
"edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU",
|
|
||||||
"edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
(alias
|
(alias
|
||||||
((name runtest_endorsement)
|
((name runtest_endorsement)
|
||||||
(locks (/tcp-port/18100))
|
(locks (/tcp-port/18100))
|
||||||
(action (chdir ${ROOT} (run ${exe:test_endorsement.exe} ${bin:tezos-node} ${path:sandbox.json} 18100)))))
|
(action (chdir ${ROOT} (run ${exe:test_endorsement.exe} ${bin:tezos-node} 18100)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
((name runtest_michelson_parser)
|
((name runtest_michelson_parser)
|
||||||
@ -47,22 +47,22 @@
|
|||||||
(alias
|
(alias
|
||||||
((name runtest_origination)
|
((name runtest_origination)
|
||||||
(locks (/tcp-port/18200))
|
(locks (/tcp-port/18200))
|
||||||
(action (chdir ${ROOT} (run ${exe:test_origination.exe} ${bin:tezos-node} ${path:sandbox.json} 18200)))))
|
(action (chdir ${ROOT} (run ${exe:test_origination.exe} ${bin:tezos-node} 18200)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
((name runtest_transaction)
|
((name runtest_transaction)
|
||||||
(locks (/tcp-port/18300))
|
(locks (/tcp-port/18300))
|
||||||
(action (chdir ${ROOT} (run ${exe:test_transaction.exe} ${bin:tezos-node} ${path:sandbox.json} 18300)))))
|
(action (chdir ${ROOT} (run ${exe:test_transaction.exe} ${bin:tezos-node} 18300)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
((name runtest_vote)
|
((name runtest_vote)
|
||||||
(locks (/tcp-port/18400))
|
(locks (/tcp-port/18400))
|
||||||
(action (chdir ${ROOT} (run ${exe:test_vote.exe} ${bin:tezos-node} ${path:sandbox-vote.json} 18400)))))
|
(action (chdir ${ROOT} (run ${exe:test_vote.exe} ${bin:tezos-node} 18400)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
((name runtest_rpc)
|
((name runtest_rpc)
|
||||||
(locks (/tcp-port/18500))
|
(locks (/tcp-port/18500))
|
||||||
(action (chdir ${ROOT} (run ${exe:test_rpc.exe} ${bin:tezos-node} ${path:sandbox.json} 18500)))))
|
(action (chdir ${ROOT} (run ${exe:test_rpc.exe} ${bin:tezos-node} 18500)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
((name runtest)
|
((name runtest)
|
||||||
|
@ -34,6 +34,16 @@ let fork_node ?exe ?(timeout = 4) ?(port = 18732) ?sandbox () =
|
|||||||
(Random.int 0xFF_FF_FF) in
|
(Random.int 0xFF_FF_FF) in
|
||||||
let log_file_name, log_file =
|
let log_file_name, log_file =
|
||||||
Filename.open_temp_file "tezos_node_" ".log" in
|
Filename.open_temp_file "tezos_node_" ".log" in
|
||||||
|
let sandbox =
|
||||||
|
match sandbox with
|
||||||
|
| None -> None
|
||||||
|
| Some json ->
|
||||||
|
let file_name, ch =
|
||||||
|
Filename.open_temp_file "tezos_node_" ".log" in
|
||||||
|
Printf.fprintf ch "%s%!"
|
||||||
|
(Data_encoding.Json.to_string json) ;
|
||||||
|
close_out ch ;
|
||||||
|
Some file_name in
|
||||||
let log_fd = Unix.descr_of_out_channel log_file in
|
let log_fd = Unix.descr_of_out_channel log_file in
|
||||||
let null_fd = Unix.(openfile "/dev/null" [O_RDONLY] 0o644) in
|
let null_fd = Unix.(openfile "/dev/null" [O_RDONLY] 0o644) in
|
||||||
let exe =
|
let exe =
|
||||||
@ -48,7 +58,6 @@ let fork_node ?exe ?(timeout = 4) ?(port = 18732) ?sandbox () =
|
|||||||
else
|
else
|
||||||
path
|
path
|
||||||
with _ -> Sys.getcwd () // ".." // "bin_node" // "main.exe" in
|
with _ -> Sys.getcwd () // ".." // "bin_node" // "main.exe" in
|
||||||
Format.eprintf "EXE %s@." exe ;
|
|
||||||
let pid =
|
let pid =
|
||||||
Unix.create_process exe
|
Unix.create_process exe
|
||||||
[| "tezos-node" ;
|
[| "tezos-node" ;
|
||||||
@ -73,7 +82,10 @@ let fork_node ?exe ?(timeout = 4) ?(port = 18732) ?sandbox () =
|
|||||||
| res ->
|
| res ->
|
||||||
handle_error res log_file_name
|
handle_error res log_file_name
|
||||||
end ;
|
end ;
|
||||||
ignore (Sys.command (Printf.sprintf "rm -fr \"%s\"" data_dir))
|
ignore (Sys.command (Printf.sprintf "rm -fr \"%s\"" data_dir)) ;
|
||||||
|
match sandbox with
|
||||||
|
| None -> ()
|
||||||
|
| Some file -> ignore (Sys.command (Printf.sprintf "rm -f \"%s\"" file))
|
||||||
end ;
|
end ;
|
||||||
pid
|
pid
|
||||||
| res ->
|
| res ->
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
val fork_node:
|
val fork_node:
|
||||||
?exe:string -> ?timeout:int -> ?port:int -> ?sandbox:string ->
|
?exe:string -> ?timeout:int -> ?port:int ->
|
||||||
|
?sandbox:Data_encoding.json ->
|
||||||
unit -> int
|
unit -> int
|
||||||
(** [fork_node ()] forks a node in sandbox mode listening to rpc on
|
(** [fork_node ()] forks a node in sandbox mode listening to rpc on
|
||||||
`localhost:port` (where the default port is 18732) and returns the
|
`localhost:port` (where the default port is 18732) and returns the
|
||||||
|
@ -44,6 +44,15 @@ let no_write_context ?(block = `Head 0) config : #Client_context.full = object
|
|||||||
Format.kasprintf (fun _ -> Lwt.return "")
|
Format.kasprintf (fun _ -> Lwt.return "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let sandbox_parameters =
|
||||||
|
let json_result =
|
||||||
|
Data_encoding.Json.from_string {json|
|
||||||
|
{ "genesis_pubkey": "edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2" }
|
||||||
|
|json} in
|
||||||
|
match json_result with
|
||||||
|
| Error err -> raise (Failure err)
|
||||||
|
| Ok json -> json
|
||||||
|
|
||||||
let protocol_parameters =
|
let protocol_parameters =
|
||||||
let json_result =
|
let json_result =
|
||||||
Data_encoding.Json.from_string {json|
|
Data_encoding.Json.from_string {json|
|
||||||
@ -65,7 +74,13 @@ let protocol_parameters =
|
|||||||
[ "tz1iDPZLxcGf5CqCNpTuuMdtu3zKpJ6HvvFR", "btz1TaSfoSNhFoqwqbPC9iC19rN24KJtB7skD", "71300478465380003" ],
|
[ "tz1iDPZLxcGf5CqCNpTuuMdtu3zKpJ6HvvFR", "btz1TaSfoSNhFoqwqbPC9iC19rN24KJtB7skD", "71300478465380003" ],
|
||||||
[ "tz1i2kbtVu65dP739qLGRpJNujRM8pdpkH3p", "btz1USqQRuvASPXwseXkGTWeWv4dn3VwMVPEk", "283380756728119992" ],
|
[ "tz1i2kbtVu65dP739qLGRpJNujRM8pdpkH3p", "btz1USqQRuvASPXwseXkGTWeWv4dn3VwMVPEk", "283380756728119992" ],
|
||||||
[ "tz1LKGCg6ESJLDviHkT8Jc7tUwjw4h3d9MaF", "btz1YwCKMbBLRL1qkBjAHGCwjbWDqiTAEFpbw", "1357762577679880028" ]
|
[ "tz1LKGCg6ESJLDviHkT8Jc7tUwjw4h3d9MaF", "btz1YwCKMbBLRL1qkBjAHGCwjbWDqiTAEFpbw", "1357762577679880028" ]
|
||||||
]
|
],
|
||||||
|
"time_between_blocks" : [ 1, 0 ],
|
||||||
|
"blocks_per_cycle" : 4,
|
||||||
|
"blocks_per_roll_snapshot" : 2,
|
||||||
|
"preserved_cycles" : 1,
|
||||||
|
"first_free_baking_slot" : 4,
|
||||||
|
"proof_of_work_threshold": -1
|
||||||
}
|
}
|
||||||
|json} in
|
|json} in
|
||||||
match json_result with
|
match json_result with
|
||||||
@ -73,11 +88,37 @@ let protocol_parameters =
|
|||||||
| Ok json ->
|
| Ok json ->
|
||||||
Data_encoding.Binary.to_bytes Data_encoding.json json
|
Data_encoding.Binary.to_bytes Data_encoding.json json
|
||||||
|
|
||||||
let activate_alpha () =
|
let vote_protocol_parameters =
|
||||||
|
let json_result =
|
||||||
|
Data_encoding.Json.from_string {json|
|
||||||
|
{ "bootstrap_accounts": [
|
||||||
|
[ "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", "4000000000000" ],
|
||||||
|
[ "edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9", "4000000000000" ],
|
||||||
|
[ "edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV", "4000000000000" ],
|
||||||
|
[ "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU", "4000000000000" ],
|
||||||
|
[ "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n", "4000000000000" ]
|
||||||
|
],
|
||||||
|
"time_between_blocks" : [ 1, 0 ],
|
||||||
|
"blocks_per_cycle" : 4,
|
||||||
|
"blocks_per_roll_snapshot" : 2,
|
||||||
|
"preserved_cycles" : 1,
|
||||||
|
"first_free_baking_slot" : 4,
|
||||||
|
"blocks_per_voting_period": 2,
|
||||||
|
"proof_of_work_threshold": -1
|
||||||
|
}
|
||||||
|
|json} in
|
||||||
|
match json_result with
|
||||||
|
| Error err -> raise (Failure err)
|
||||||
|
| Ok json ->
|
||||||
|
Data_encoding.Binary.to_bytes Data_encoding.json json
|
||||||
|
|
||||||
|
let activate_alpha ?(vote = false) () =
|
||||||
let fitness = Fitness_repr.from_int64 0L in
|
let fitness = Fitness_repr.from_int64 0L in
|
||||||
let dictator_sk = Client_keys.Secret_key_locator.create
|
let dictator_sk = Client_keys.Secret_key_locator.create
|
||||||
~scheme:"unencrypted"
|
~scheme:"unencrypted"
|
||||||
~location:"edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6" in
|
~location:"edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6" in
|
||||||
|
let protocol_parameters =
|
||||||
|
if vote then vote_protocol_parameters else protocol_parameters in
|
||||||
Tezos_client_genesis.Client_proto_main.bake
|
Tezos_client_genesis.Client_proto_main.bake
|
||||||
(no_write_context ~block:(`Head 0) !rpc_config) (`Head 0)
|
(no_write_context ~block:(`Head 0) !rpc_config) (`Head 0)
|
||||||
(Activate { protocol = Proto_alpha.hash ;
|
(Activate { protocol = Proto_alpha.hash ;
|
||||||
@ -86,7 +127,7 @@ let activate_alpha () =
|
|||||||
})
|
})
|
||||||
dictator_sk
|
dictator_sk
|
||||||
|
|
||||||
let init ?exe ?(sandbox = "sandbox.json") ?rpc_port () =
|
let init ?exe ?vote ?rpc_port () =
|
||||||
begin
|
begin
|
||||||
match rpc_port with
|
match rpc_port with
|
||||||
| None -> ()
|
| None -> ()
|
||||||
@ -98,9 +139,9 @@ let init ?exe ?(sandbox = "sandbox.json") ?rpc_port () =
|
|||||||
Node_helpers.fork_node
|
Node_helpers.fork_node
|
||||||
?exe
|
?exe
|
||||||
~port:!rpc_config.port
|
~port:!rpc_config.port
|
||||||
~sandbox
|
~sandbox:sandbox_parameters
|
||||||
() in
|
() in
|
||||||
activate_alpha () >>=? fun hash ->
|
activate_alpha ?vote () >>=? fun hash ->
|
||||||
return (pid, hash)
|
return (pid, hash)
|
||||||
|
|
||||||
let level block =
|
let level block =
|
||||||
|
@ -12,7 +12,7 @@ open Alpha_context
|
|||||||
|
|
||||||
val init :
|
val init :
|
||||||
?exe:string ->
|
?exe:string ->
|
||||||
?sandbox:string ->
|
?vote:bool ->
|
||||||
?rpc_port:int ->
|
?rpc_port:int ->
|
||||||
unit -> (int * Block_hash.t) tzresult Lwt.t
|
unit -> (int * Block_hash.t) tzresult Lwt.t
|
||||||
(** [init ()] sets up the test environment, and return the PID of
|
(** [init ()] sets up the test environment, and return the PID of
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"genesis_pubkey":
|
|
||||||
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
|
||||||
"bootstrap_keys": [
|
|
||||||
"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav",
|
|
||||||
"edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9",
|
|
||||||
"edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV",
|
|
||||||
"edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU",
|
|
||||||
"edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n"
|
|
||||||
],
|
|
||||||
"time_between_blocks" : [ 1, 0 ],
|
|
||||||
"blocks_per_cycle" : 4,
|
|
||||||
"blocks_per_roll_snapshot" : 2,
|
|
||||||
"preserved_cycles" : 1,
|
|
||||||
"first_free_baking_slot" : 4,
|
|
||||||
"blocks_per_voting_period": 2,
|
|
||||||
"proof_of_work_threshold": -1
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"genesis_pubkey":
|
|
||||||
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
|
||||||
"bootstrap_keys": [
|
|
||||||
"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav",
|
|
||||||
"edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9",
|
|
||||||
"edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV",
|
|
||||||
"edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU",
|
|
||||||
"edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n"
|
|
||||||
],
|
|
||||||
"time_between_blocks" : [ 1, 0 ],
|
|
||||||
"blocks_per_cycle" : 4,
|
|
||||||
"blocks_per_roll_snapshot" : 2,
|
|
||||||
"preserved_cycles" : 1,
|
|
||||||
"first_free_baking_slot" : 4,
|
|
||||||
"proof_of_work_threshold": -1
|
|
||||||
}
|
|
@ -245,11 +245,10 @@ let run genesis =
|
|||||||
return ()
|
return ()
|
||||||
|
|
||||||
let exe = try Sys.argv.(1) with _ -> "tezos-node"
|
let exe = try Sys.argv.(1) with _ -> "tezos-node"
|
||||||
let sandbox = try Sys.argv.(2) with _ -> "sandbox.json"
|
let rpc_port = try int_of_string Sys.argv.(2) with _ -> 18100
|
||||||
let rpc_port = try int_of_string Sys.argv.(3) with _ -> 18100
|
|
||||||
|
|
||||||
let main () =
|
let main () =
|
||||||
Helpers.init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, genesis) ->
|
Helpers.init ~exe ~rpc_port () >>=? fun (_node_pid, genesis) ->
|
||||||
run (`Hash (genesis, 0))
|
run (`Hash (genesis, 0))
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,11 +49,10 @@ let run blkid =
|
|||||||
) tests
|
) tests
|
||||||
|
|
||||||
let exe = try Sys.argv.(1) with _ -> "tezos-node"
|
let exe = try Sys.argv.(1) with _ -> "tezos-node"
|
||||||
let sandbox = try Sys.argv.(2) with _ -> "sandbox.json"
|
let rpc_port = try int_of_string Sys.argv.(2) with _ -> 18500
|
||||||
let rpc_port = try int_of_string Sys.argv.(3) with _ -> 18500
|
|
||||||
|
|
||||||
let main () =
|
let main () =
|
||||||
Helpers.init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, genesis) ->
|
Helpers.init ~exe ~rpc_port () >>=? fun (_node_pid, genesis) ->
|
||||||
run (`Hash (genesis, 0))
|
run (`Hash (genesis, 0))
|
||||||
|
|
||||||
let tests = [
|
let tests = [
|
||||||
|
@ -85,11 +85,10 @@ let run_change_to_demo_proto block
|
|||||||
return (`Hash (head, 0))
|
return (`Hash (head, 0))
|
||||||
|
|
||||||
let exe = try Sys.argv.(1) with _ -> "tezos-node"
|
let exe = try Sys.argv.(1) with _ -> "tezos-node"
|
||||||
let sandbox = try Sys.argv.(2) with _ -> "sandbox-vote.json"
|
let rpc_port = try int_of_string Sys.argv.(2) with _ -> 18400
|
||||||
let rpc_port = try int_of_string Sys.argv.(3) with _ -> 18400
|
|
||||||
|
|
||||||
let change_to_demo_proto () =
|
let change_to_demo_proto () =
|
||||||
init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, hash) ->
|
init ~exe ~vote:true ~rpc_port () >>=? fun (_node_pid, hash) ->
|
||||||
run_change_to_demo_proto (`Hash (hash, 0)) Account.bootstrap_accounts >>=? fun _blkh ->
|
run_change_to_demo_proto (`Hash (hash, 0)) Account.bootstrap_accounts >>=? fun _blkh ->
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
@ -101,186 +101,6 @@ let default = {
|
|||||||
|
|
||||||
module CompareListInt = Compare.List (Compare.Int)
|
module CompareListInt = Compare.List (Compare.Int)
|
||||||
|
|
||||||
(* This encoding is used to read configuration files (e.g. sandbox.json)
|
|
||||||
where some fields can be missing, in that case they are replaced by
|
|
||||||
the default. *)
|
|
||||||
let sandbox_encoding =
|
|
||||||
let open Data_encoding in
|
|
||||||
conv
|
|
||||||
(fun c ->
|
|
||||||
let module Compare_time_between_blocks = Compare.List (Period_repr) in
|
|
||||||
let module Compare_keys = Compare.List (Ed25519.Public_key) in
|
|
||||||
let opt (=) def v = if def = v then None else Some v in
|
|
||||||
let preserved_cycles =
|
|
||||||
opt Compare.Int.(=)
|
|
||||||
default.preserved_cycles c.preserved_cycles
|
|
||||||
and blocks_per_cycle =
|
|
||||||
opt Compare.Int32.(=)
|
|
||||||
default.blocks_per_cycle c.blocks_per_cycle
|
|
||||||
and blocks_per_commitment =
|
|
||||||
opt Compare.Int32.(=)
|
|
||||||
default.blocks_per_commitment c.blocks_per_commitment
|
|
||||||
and blocks_per_roll_snapshot =
|
|
||||||
opt Compare.Int32.(=)
|
|
||||||
default.blocks_per_roll_snapshot c.blocks_per_roll_snapshot
|
|
||||||
and blocks_per_voting_period =
|
|
||||||
opt Compare.Int32.(=)
|
|
||||||
default.blocks_per_voting_period c.blocks_per_voting_period
|
|
||||||
and time_between_blocks =
|
|
||||||
opt Compare_time_between_blocks.(=)
|
|
||||||
default.time_between_blocks c.time_between_blocks
|
|
||||||
and first_free_baking_slot =
|
|
||||||
opt Compare.Int.(=)
|
|
||||||
default.first_free_baking_slot c.first_free_baking_slot
|
|
||||||
and endorsers_per_block =
|
|
||||||
opt Compare.Int.(=)
|
|
||||||
default.endorsers_per_block c.endorsers_per_block
|
|
||||||
and max_gas =
|
|
||||||
opt Compare.Int.(=)
|
|
||||||
default.max_gas c.max_gas
|
|
||||||
and proof_of_work_threshold =
|
|
||||||
opt Compare.Int64.(=)
|
|
||||||
default.proof_of_work_threshold c.proof_of_work_threshold
|
|
||||||
and dictator_pubkey =
|
|
||||||
opt Ed25519.Public_key.(=)
|
|
||||||
default.dictator_pubkey c.dictator_pubkey
|
|
||||||
and max_operation_data_length =
|
|
||||||
opt Compare.Int.(=)
|
|
||||||
default.max_operation_data_length c.max_operation_data_length
|
|
||||||
and tokens_per_roll =
|
|
||||||
opt Tez_repr.(=)
|
|
||||||
default.tokens_per_roll c.tokens_per_roll
|
|
||||||
and michelson_maximum_type_size =
|
|
||||||
opt Compare.Int.(=)
|
|
||||||
default.michelson_maximum_type_size c.michelson_maximum_type_size
|
|
||||||
and seed_nonce_revelation_tip =
|
|
||||||
opt Tez_repr.(=)
|
|
||||||
default.seed_nonce_revelation_tip c.seed_nonce_revelation_tip
|
|
||||||
and origination_burn =
|
|
||||||
opt Tez_repr.(=)
|
|
||||||
default.origination_burn c.origination_burn
|
|
||||||
and block_security_deposit =
|
|
||||||
opt Tez_repr.(=)
|
|
||||||
default.block_security_deposit c.block_security_deposit
|
|
||||||
and endorsement_security_deposit =
|
|
||||||
opt Tez_repr.(=)
|
|
||||||
default.endorsement_security_deposit c.endorsement_security_deposit
|
|
||||||
and block_reward =
|
|
||||||
opt Tez_repr.(=)
|
|
||||||
default.block_reward c.block_reward
|
|
||||||
and endorsement_reward =
|
|
||||||
opt Tez_repr.(=)
|
|
||||||
default.endorsement_reward c.endorsement_reward
|
|
||||||
in
|
|
||||||
((( preserved_cycles,
|
|
||||||
blocks_per_cycle,
|
|
||||||
blocks_per_commitment,
|
|
||||||
blocks_per_roll_snapshot,
|
|
||||||
blocks_per_voting_period,
|
|
||||||
time_between_blocks,
|
|
||||||
first_free_baking_slot,
|
|
||||||
endorsers_per_block,
|
|
||||||
max_gas,
|
|
||||||
proof_of_work_threshold),
|
|
||||||
( dictator_pubkey,
|
|
||||||
max_operation_data_length,
|
|
||||||
tokens_per_roll,
|
|
||||||
michelson_maximum_type_size,
|
|
||||||
seed_nonce_revelation_tip,
|
|
||||||
origination_burn,
|
|
||||||
block_security_deposit,
|
|
||||||
endorsement_security_deposit,
|
|
||||||
block_reward,
|
|
||||||
endorsement_reward)), ()) )
|
|
||||||
(fun ((( preserved_cycles,
|
|
||||||
blocks_per_cycle,
|
|
||||||
blocks_per_commitment,
|
|
||||||
blocks_per_roll_snapshot,
|
|
||||||
blocks_per_voting_period,
|
|
||||||
time_between_blocks,
|
|
||||||
first_free_baking_slot,
|
|
||||||
endorsers_per_block,
|
|
||||||
max_gas,
|
|
||||||
proof_of_work_threshold),
|
|
||||||
( dictator_pubkey,
|
|
||||||
max_operation_data_length,
|
|
||||||
tokens_per_roll,
|
|
||||||
michelson_maximum_type_size,
|
|
||||||
seed_nonce_revelation_tip,
|
|
||||||
origination_burn,
|
|
||||||
block_security_deposit,
|
|
||||||
endorsement_security_deposit,
|
|
||||||
block_reward,
|
|
||||||
endorsement_reward)), ()) ->
|
|
||||||
let unopt def = function None -> def | Some v -> v in
|
|
||||||
{ preserved_cycles =
|
|
||||||
unopt default.preserved_cycles preserved_cycles ;
|
|
||||||
blocks_per_cycle =
|
|
||||||
unopt default.blocks_per_cycle blocks_per_cycle ;
|
|
||||||
blocks_per_commitment =
|
|
||||||
unopt default.blocks_per_commitment blocks_per_commitment ;
|
|
||||||
blocks_per_roll_snapshot =
|
|
||||||
unopt default.blocks_per_roll_snapshot blocks_per_roll_snapshot ;
|
|
||||||
blocks_per_voting_period =
|
|
||||||
unopt default.blocks_per_voting_period blocks_per_voting_period ;
|
|
||||||
time_between_blocks =
|
|
||||||
unopt default.time_between_blocks @@
|
|
||||||
time_between_blocks ;
|
|
||||||
first_free_baking_slot =
|
|
||||||
unopt default.first_free_baking_slot first_free_baking_slot ;
|
|
||||||
endorsers_per_block =
|
|
||||||
unopt default.endorsers_per_block endorsers_per_block ;
|
|
||||||
max_gas =
|
|
||||||
unopt default.max_gas max_gas ;
|
|
||||||
proof_of_work_threshold =
|
|
||||||
unopt default.proof_of_work_threshold proof_of_work_threshold ;
|
|
||||||
dictator_pubkey =
|
|
||||||
unopt default.dictator_pubkey dictator_pubkey ;
|
|
||||||
max_operation_data_length =
|
|
||||||
unopt default.max_operation_data_length max_operation_data_length ;
|
|
||||||
tokens_per_roll =
|
|
||||||
unopt default.tokens_per_roll tokens_per_roll ;
|
|
||||||
michelson_maximum_type_size =
|
|
||||||
unopt default.michelson_maximum_type_size michelson_maximum_type_size ;
|
|
||||||
seed_nonce_revelation_tip =
|
|
||||||
unopt default.seed_nonce_revelation_tip seed_nonce_revelation_tip ;
|
|
||||||
origination_burn =
|
|
||||||
unopt default.origination_burn origination_burn ;
|
|
||||||
block_security_deposit =
|
|
||||||
unopt default.block_security_deposit block_security_deposit ;
|
|
||||||
endorsement_security_deposit =
|
|
||||||
unopt default.endorsement_security_deposit endorsement_security_deposit ;
|
|
||||||
block_reward =
|
|
||||||
unopt default.block_reward block_reward ;
|
|
||||||
endorsement_reward =
|
|
||||||
unopt default.endorsement_reward endorsement_reward ;
|
|
||||||
} )
|
|
||||||
(merge_objs
|
|
||||||
(merge_objs
|
|
||||||
(obj10
|
|
||||||
(opt "preserved_cycles" uint8)
|
|
||||||
(opt "blocks_per_cycle" int32)
|
|
||||||
(opt "blocks_per_commitment" int32)
|
|
||||||
(opt "blocks_per_roll_snapshot" int32)
|
|
||||||
(opt "blocks_per_voting_period" int32)
|
|
||||||
(opt "time_between_blocks" (list Period_repr.encoding))
|
|
||||||
(opt "first_free_baking_slot" uint16)
|
|
||||||
(opt "endorsers_per_block" uint16)
|
|
||||||
(opt "instructions_per_transaction" int31)
|
|
||||||
(opt "proof_of_work_threshold" int64))
|
|
||||||
(obj10
|
|
||||||
(opt "dictator_pubkey" Ed25519.Public_key.encoding)
|
|
||||||
(opt "max_operation_data_length" int31)
|
|
||||||
(opt "tokens_per_roll" Tez_repr.encoding)
|
|
||||||
(opt "michelson_maximum_type_size" uint16)
|
|
||||||
(opt "seed_nonce_revelation_tip" Tez_repr.encoding)
|
|
||||||
(opt "origination_burn" Tez_repr.encoding)
|
|
||||||
(opt "block_security_deposit" Tez_repr.encoding)
|
|
||||||
(opt "endorsement_security_deposit" Tez_repr.encoding)
|
|
||||||
(opt "block_reward" Tez_repr.encoding)
|
|
||||||
(opt "endorsement_reward" Tez_repr.encoding)))
|
|
||||||
unit)
|
|
||||||
|
|
||||||
let parametric_encoding =
|
let parametric_encoding =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
@ -383,15 +203,3 @@ let encoding =
|
|||||||
(merge_objs fixed_encoding parametric_encoding)
|
(merge_objs fixed_encoding parametric_encoding)
|
||||||
|
|
||||||
type error += Constant_read of exn
|
type error += Constant_read of exn
|
||||||
|
|
||||||
let read_sandbox = function
|
|
||||||
| None ->
|
|
||||||
return default
|
|
||||||
| Some json ->
|
|
||||||
match Data_encoding.Json.(destruct sandbox_encoding json) with
|
|
||||||
| exception exn -> fail (Constant_read exn)
|
|
||||||
| c ->
|
|
||||||
if Compare.Int32.(c.blocks_per_roll_snapshot > c.blocks_per_cycle) then
|
|
||||||
failwith "Invalid sandbox: 'blocks_per_roll_snapshot > blocks_per_cycle'"
|
|
||||||
else
|
|
||||||
return c
|
|
||||||
|
@ -14,10 +14,10 @@ type bootstrap_account = {
|
|||||||
|
|
||||||
type t = {
|
type t = {
|
||||||
bootstrap_accounts : bootstrap_account list ;
|
bootstrap_accounts : bootstrap_account list ;
|
||||||
commitments : (Unclaimed_public_key_hash.t * Commitment_repr.t) list
|
commitments : (Unclaimed_public_key_hash.t * Commitment_repr.t) list ;
|
||||||
|
constants : Constants_repr.parametric ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let bootstrap_account_encoding =
|
let bootstrap_account_encoding =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
@ -25,16 +25,198 @@ let bootstrap_account_encoding =
|
|||||||
(fun (public_key, amount) -> { public_key ; amount })
|
(fun (public_key, amount) -> { public_key ; amount })
|
||||||
(tup2 Ed25519.Public_key.encoding Tez_repr.encoding)
|
(tup2 Ed25519.Public_key.encoding Tez_repr.encoding)
|
||||||
|
|
||||||
|
(* This encoding is used to read configuration files (e.g. sandbox.json)
|
||||||
|
where some fields can be missing, in that case they are replaced by
|
||||||
|
the default. *)
|
||||||
|
let constants_encoding =
|
||||||
|
let open Data_encoding in
|
||||||
|
conv
|
||||||
|
(fun (c : Constants_repr.parametric) ->
|
||||||
|
let module Compare_time_between_blocks = Compare.List (Period_repr) in
|
||||||
|
let module Compare_keys = Compare.List (Ed25519.Public_key) in
|
||||||
|
let opt (=) def v = if def = v then None else Some v in
|
||||||
|
let default = Constants_repr.default in
|
||||||
|
let preserved_cycles =
|
||||||
|
opt Compare.Int.(=)
|
||||||
|
default.preserved_cycles c.preserved_cycles
|
||||||
|
and blocks_per_cycle =
|
||||||
|
opt Compare.Int32.(=)
|
||||||
|
default.blocks_per_cycle c.blocks_per_cycle
|
||||||
|
and blocks_per_commitment =
|
||||||
|
opt Compare.Int32.(=)
|
||||||
|
default.blocks_per_commitment c.blocks_per_commitment
|
||||||
|
and blocks_per_roll_snapshot =
|
||||||
|
opt Compare.Int32.(=)
|
||||||
|
default.blocks_per_roll_snapshot c.blocks_per_roll_snapshot
|
||||||
|
and blocks_per_voting_period =
|
||||||
|
opt Compare.Int32.(=)
|
||||||
|
default.blocks_per_voting_period c.blocks_per_voting_period
|
||||||
|
and time_between_blocks =
|
||||||
|
opt Compare_time_between_blocks.(=)
|
||||||
|
default.time_between_blocks c.time_between_blocks
|
||||||
|
and first_free_baking_slot =
|
||||||
|
opt Compare.Int.(=)
|
||||||
|
default.first_free_baking_slot c.first_free_baking_slot
|
||||||
|
and endorsers_per_block =
|
||||||
|
opt Compare.Int.(=)
|
||||||
|
default.endorsers_per_block c.endorsers_per_block
|
||||||
|
and max_gas =
|
||||||
|
opt Compare.Int.(=)
|
||||||
|
default.max_gas c.max_gas
|
||||||
|
and proof_of_work_threshold =
|
||||||
|
opt Compare.Int64.(=)
|
||||||
|
default.proof_of_work_threshold c.proof_of_work_threshold
|
||||||
|
and dictator_pubkey =
|
||||||
|
opt Ed25519.Public_key.(=)
|
||||||
|
default.dictator_pubkey c.dictator_pubkey
|
||||||
|
and max_operation_data_length =
|
||||||
|
opt Compare.Int.(=)
|
||||||
|
default.max_operation_data_length c.max_operation_data_length
|
||||||
|
and tokens_per_roll =
|
||||||
|
opt Tez_repr.(=)
|
||||||
|
default.tokens_per_roll c.tokens_per_roll
|
||||||
|
and michelson_maximum_type_size =
|
||||||
|
opt Compare.Int.(=)
|
||||||
|
default.michelson_maximum_type_size c.michelson_maximum_type_size
|
||||||
|
and seed_nonce_revelation_tip =
|
||||||
|
opt Tez_repr.(=)
|
||||||
|
default.seed_nonce_revelation_tip c.seed_nonce_revelation_tip
|
||||||
|
and origination_burn =
|
||||||
|
opt Tez_repr.(=)
|
||||||
|
default.origination_burn c.origination_burn
|
||||||
|
and block_security_deposit =
|
||||||
|
opt Tez_repr.(=)
|
||||||
|
default.block_security_deposit c.block_security_deposit
|
||||||
|
and endorsement_security_deposit =
|
||||||
|
opt Tez_repr.(=)
|
||||||
|
default.endorsement_security_deposit c.endorsement_security_deposit
|
||||||
|
and block_reward =
|
||||||
|
opt Tez_repr.(=)
|
||||||
|
default.block_reward c.block_reward
|
||||||
|
and endorsement_reward =
|
||||||
|
opt Tez_repr.(=)
|
||||||
|
default.endorsement_reward c.endorsement_reward
|
||||||
|
in
|
||||||
|
(( preserved_cycles,
|
||||||
|
blocks_per_cycle,
|
||||||
|
blocks_per_commitment,
|
||||||
|
blocks_per_roll_snapshot,
|
||||||
|
blocks_per_voting_period,
|
||||||
|
time_between_blocks,
|
||||||
|
first_free_baking_slot,
|
||||||
|
endorsers_per_block,
|
||||||
|
max_gas,
|
||||||
|
proof_of_work_threshold),
|
||||||
|
( dictator_pubkey,
|
||||||
|
max_operation_data_length,
|
||||||
|
tokens_per_roll,
|
||||||
|
michelson_maximum_type_size,
|
||||||
|
seed_nonce_revelation_tip,
|
||||||
|
origination_burn,
|
||||||
|
block_security_deposit,
|
||||||
|
endorsement_security_deposit,
|
||||||
|
block_reward,
|
||||||
|
endorsement_reward)))
|
||||||
|
(fun (( preserved_cycles,
|
||||||
|
blocks_per_cycle,
|
||||||
|
blocks_per_commitment,
|
||||||
|
blocks_per_roll_snapshot,
|
||||||
|
blocks_per_voting_period,
|
||||||
|
time_between_blocks,
|
||||||
|
first_free_baking_slot,
|
||||||
|
endorsers_per_block,
|
||||||
|
max_gas,
|
||||||
|
proof_of_work_threshold),
|
||||||
|
( dictator_pubkey,
|
||||||
|
max_operation_data_length,
|
||||||
|
tokens_per_roll,
|
||||||
|
michelson_maximum_type_size,
|
||||||
|
seed_nonce_revelation_tip,
|
||||||
|
origination_burn,
|
||||||
|
block_security_deposit,
|
||||||
|
endorsement_security_deposit,
|
||||||
|
block_reward,
|
||||||
|
endorsement_reward)) ->
|
||||||
|
let unopt def = function None -> def | Some v -> v in
|
||||||
|
let default = Constants_repr.default in
|
||||||
|
{ Constants_repr.preserved_cycles =
|
||||||
|
unopt default.preserved_cycles preserved_cycles ;
|
||||||
|
blocks_per_cycle =
|
||||||
|
unopt default.blocks_per_cycle blocks_per_cycle ;
|
||||||
|
blocks_per_commitment =
|
||||||
|
unopt default.blocks_per_commitment blocks_per_commitment ;
|
||||||
|
blocks_per_roll_snapshot =
|
||||||
|
unopt default.blocks_per_roll_snapshot blocks_per_roll_snapshot ;
|
||||||
|
blocks_per_voting_period =
|
||||||
|
unopt default.blocks_per_voting_period blocks_per_voting_period ;
|
||||||
|
time_between_blocks =
|
||||||
|
unopt default.time_between_blocks @@
|
||||||
|
time_between_blocks ;
|
||||||
|
first_free_baking_slot =
|
||||||
|
unopt default.first_free_baking_slot first_free_baking_slot ;
|
||||||
|
endorsers_per_block =
|
||||||
|
unopt default.endorsers_per_block endorsers_per_block ;
|
||||||
|
max_gas =
|
||||||
|
unopt default.max_gas max_gas ;
|
||||||
|
proof_of_work_threshold =
|
||||||
|
unopt default.proof_of_work_threshold proof_of_work_threshold ;
|
||||||
|
dictator_pubkey =
|
||||||
|
unopt default.dictator_pubkey dictator_pubkey ;
|
||||||
|
max_operation_data_length =
|
||||||
|
unopt default.max_operation_data_length max_operation_data_length ;
|
||||||
|
tokens_per_roll =
|
||||||
|
unopt default.tokens_per_roll tokens_per_roll ;
|
||||||
|
michelson_maximum_type_size =
|
||||||
|
unopt default.michelson_maximum_type_size michelson_maximum_type_size ;
|
||||||
|
seed_nonce_revelation_tip =
|
||||||
|
unopt default.seed_nonce_revelation_tip seed_nonce_revelation_tip ;
|
||||||
|
origination_burn =
|
||||||
|
unopt default.origination_burn origination_burn ;
|
||||||
|
block_security_deposit =
|
||||||
|
unopt default.block_security_deposit block_security_deposit ;
|
||||||
|
endorsement_security_deposit =
|
||||||
|
unopt default.endorsement_security_deposit endorsement_security_deposit ;
|
||||||
|
block_reward =
|
||||||
|
unopt default.block_reward block_reward ;
|
||||||
|
endorsement_reward =
|
||||||
|
unopt default.endorsement_reward endorsement_reward ;
|
||||||
|
} )
|
||||||
|
(merge_objs
|
||||||
|
(obj10
|
||||||
|
(opt "preserved_cycles" uint8)
|
||||||
|
(opt "blocks_per_cycle" int32)
|
||||||
|
(opt "blocks_per_commitment" int32)
|
||||||
|
(opt "blocks_per_roll_snapshot" int32)
|
||||||
|
(opt "blocks_per_voting_period" int32)
|
||||||
|
(opt "time_between_blocks" (list Period_repr.encoding))
|
||||||
|
(opt "first_free_baking_slot" uint16)
|
||||||
|
(opt "endorsers_per_block" uint16)
|
||||||
|
(opt "instructions_per_transaction" int31)
|
||||||
|
(opt "proof_of_work_threshold" int64))
|
||||||
|
(obj10
|
||||||
|
(opt "dictator_pubkey" Ed25519.Public_key.encoding)
|
||||||
|
(opt "max_operation_data_length" int31)
|
||||||
|
(opt "tokens_per_roll" Tez_repr.encoding)
|
||||||
|
(opt "michelson_maximum_type_size" uint16)
|
||||||
|
(opt "seed_nonce_revelation_tip" Tez_repr.encoding)
|
||||||
|
(opt "origination_burn" Tez_repr.encoding)
|
||||||
|
(opt "block_security_deposit" Tez_repr.encoding)
|
||||||
|
(opt "endorsement_security_deposit" Tez_repr.encoding)
|
||||||
|
(opt "block_reward" Tez_repr.encoding)
|
||||||
|
(opt "endorsement_reward" Tez_repr.encoding)))
|
||||||
|
|
||||||
let encoding =
|
let encoding =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
(fun { bootstrap_accounts ; commitments } ->
|
(fun { bootstrap_accounts ; commitments ; constants } ->
|
||||||
(bootstrap_accounts, commitments))
|
((bootstrap_accounts, commitments), constants ))
|
||||||
(fun ( bootstrap_accounts, commitments ) ->
|
(fun ( (bootstrap_accounts, commitments), constants ) ->
|
||||||
{ bootstrap_accounts ; commitments })
|
{ bootstrap_accounts ; commitments ; constants })
|
||||||
(obj2
|
(merge_objs
|
||||||
(req "bootstrap_accounts" (list bootstrap_account_encoding))
|
(obj2
|
||||||
(req "commitments"
|
(req "bootstrap_accounts" (list bootstrap_account_encoding))
|
||||||
(list (merge_tups
|
(dft "commitments"
|
||||||
(tup1 Unclaimed_public_key_hash.encoding)
|
(list (merge_tups
|
||||||
Commitment_repr.encoding))))
|
(tup1 Unclaimed_public_key_hash.encoding)
|
||||||
|
Commitment_repr.encoding)) []))
|
||||||
|
constants_encoding)
|
||||||
|
@ -14,7 +14,9 @@ type bootstrap_account = {
|
|||||||
|
|
||||||
type t = {
|
type t = {
|
||||||
bootstrap_accounts : bootstrap_account list ;
|
bootstrap_accounts : bootstrap_account list ;
|
||||||
commitments : (Unclaimed_public_key_hash.t * Commitment_repr.t) list
|
commitments : (Unclaimed_public_key_hash.t * Commitment_repr.t) list ;
|
||||||
|
constants : Constants_repr.parametric ;
|
||||||
}
|
}
|
||||||
|
|
||||||
val encoding: t Data_encoding.t
|
val encoding: t Data_encoding.t
|
||||||
|
val constants_encoding: Constants_repr.parametric Data_encoding.t
|
||||||
|
@ -136,9 +136,6 @@ let version_value = "alpha"
|
|||||||
let version = "v1"
|
let version = "v1"
|
||||||
let first_level_key = [ version ; "first_level" ]
|
let first_level_key = [ version ; "first_level" ]
|
||||||
let constants_key = [ version ; "constants" ]
|
let constants_key = [ version ; "constants" ]
|
||||||
|
|
||||||
(* temporary hardcoded key to be removed... *)
|
|
||||||
let sandbox_param_key = [ "sandbox_parameter" ]
|
|
||||||
let protocol_param_key = [ "protocol_parameters" ]
|
let protocol_param_key = [ "protocol_parameters" ]
|
||||||
|
|
||||||
let get_first_level ctxt =
|
let get_first_level ctxt =
|
||||||
@ -157,31 +154,43 @@ let set_first_level ctxt level =
|
|||||||
Context.set ctxt first_level_key bytes >>= fun ctxt ->
|
Context.set ctxt first_level_key bytes >>= fun ctxt ->
|
||||||
return ctxt
|
return ctxt
|
||||||
|
|
||||||
type error += Failed_to_parse_sandbox_parameter of MBytes.t
|
type error += Failed_to_parse_parameter of MBytes.t
|
||||||
|
type error += Failed_to_decode_parameter of Data_encoding.json * string
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
register_error_kind
|
register_error_kind
|
||||||
`Temporary
|
`Temporary
|
||||||
~id:"context.failed_to_parse_sandbox_parameter"
|
~id:"context.failed_to_parse_parameter"
|
||||||
~title: "Failed to parse sandbox parameter"
|
~title: "Failed to parse parameter"
|
||||||
~description:
|
~description:
|
||||||
"The sandbox parameter is not a valid JSON string."
|
"The protocol parameters are not valid JSON."
|
||||||
~pp:begin fun ppf bytes ->
|
~pp:begin fun ppf bytes ->
|
||||||
Format.fprintf ppf
|
Format.fprintf ppf
|
||||||
"@[<v 2>Cannot parse the sandbox parameter:@ %s@]"
|
"@[<v 2>Cannot parse the protocol parameter:@ %s@]"
|
||||||
(MBytes.to_string bytes)
|
(MBytes.to_string bytes)
|
||||||
end
|
end
|
||||||
Data_encoding.(obj1 (req "contents" bytes))
|
Data_encoding.(obj1 (req "contents" bytes))
|
||||||
(function Failed_to_parse_sandbox_parameter data -> Some data | _ -> None)
|
(function Failed_to_parse_parameter data -> Some data | _ -> None)
|
||||||
(fun data -> Failed_to_parse_sandbox_parameter data)
|
(fun data -> Failed_to_parse_parameter data) ;
|
||||||
|
register_error_kind
|
||||||
let get_sandbox_param c =
|
`Temporary
|
||||||
Context.get c sandbox_param_key >>= function
|
~id:"context.failed_to_decode_parameter"
|
||||||
| None -> return None
|
~title: "Failed to decode parameter"
|
||||||
| Some bytes ->
|
~description:
|
||||||
match Data_encoding.Binary.of_bytes Data_encoding.json bytes with
|
"Unexpected JSON object."
|
||||||
| None -> fail (Failed_to_parse_sandbox_parameter bytes)
|
~pp:begin fun ppf (json, msg) ->
|
||||||
| Some json -> return (Some json)
|
Format.fprintf ppf
|
||||||
|
"@[<v 2>Cannot decode the protocol parameter:@ %s@ %a@]"
|
||||||
|
msg
|
||||||
|
Data_encoding.Json.pp json
|
||||||
|
end
|
||||||
|
Data_encoding.(obj2
|
||||||
|
(req "contents" json)
|
||||||
|
(req "error" string))
|
||||||
|
(function
|
||||||
|
| Failed_to_decode_parameter (json, msg) -> Some (json, msg)
|
||||||
|
| _ -> None)
|
||||||
|
(fun (json, msg) -> Failed_to_decode_parameter (json, msg))
|
||||||
|
|
||||||
let get_proto_param ctxt =
|
let get_proto_param ctxt =
|
||||||
Context.get ctxt protocol_param_key >>= function
|
Context.get ctxt protocol_param_key >>= function
|
||||||
@ -189,7 +198,7 @@ let get_proto_param ctxt =
|
|||||||
failwith "Missing protocol parameters."
|
failwith "Missing protocol parameters."
|
||||||
| Some bytes ->
|
| Some bytes ->
|
||||||
match Data_encoding.Binary.of_bytes Data_encoding.json bytes with
|
match Data_encoding.Binary.of_bytes Data_encoding.json bytes with
|
||||||
| None -> failwith "Invalid json"
|
| None -> fail (Failed_to_parse_parameter bytes)
|
||||||
| Some json -> begin
|
| Some json -> begin
|
||||||
Context.del ctxt protocol_param_key >>= fun ctxt ->
|
Context.del ctxt protocol_param_key >>= fun ctxt ->
|
||||||
match Data_encoding.Json.destruct Parameters_repr.encoding json with
|
match Data_encoding.Json.destruct Parameters_repr.encoding json with
|
||||||
@ -204,7 +213,7 @@ let get_proto_param ctxt =
|
|||||||
let set_constants ctxt constants =
|
let set_constants ctxt constants =
|
||||||
let bytes =
|
let bytes =
|
||||||
Data_encoding.Binary.to_bytes
|
Data_encoding.Binary.to_bytes
|
||||||
Constants_repr.parametric_encoding constants in
|
Parameters_repr.constants_encoding constants in
|
||||||
Context.set ctxt constants_key bytes
|
Context.set ctxt constants_key bytes
|
||||||
|
|
||||||
let get_constants ctxt =
|
let get_constants ctxt =
|
||||||
@ -213,7 +222,7 @@ let get_constants ctxt =
|
|||||||
failwith "Internal error: cannot read constants in context."
|
failwith "Internal error: cannot read constants in context."
|
||||||
| Some bytes ->
|
| Some bytes ->
|
||||||
match
|
match
|
||||||
Data_encoding.Binary.of_bytes Constants_repr.parametric_encoding bytes
|
Data_encoding.Binary.of_bytes Parameters_repr.constants_encoding bytes
|
||||||
with
|
with
|
||||||
| None ->
|
| None ->
|
||||||
failwith "Internal error: cannot parse constants in context."
|
failwith "Internal error: cannot parse constants in context."
|
||||||
@ -267,12 +276,10 @@ let prepare_first_block ~level ~timestamp ~fitness ctxt =
|
|||||||
check_first_block ctxt >>=? fun () ->
|
check_first_block ctxt >>=? fun () ->
|
||||||
Lwt.return (Raw_level_repr.of_int32 level) >>=? fun first_level ->
|
Lwt.return (Raw_level_repr.of_int32 level) >>=? fun first_level ->
|
||||||
get_proto_param ctxt >>=? fun (param, ctxt) ->
|
get_proto_param ctxt >>=? fun (param, ctxt) ->
|
||||||
get_sandbox_param ctxt >>=? fun sandbox_param ->
|
|
||||||
Constants_repr.read_sandbox sandbox_param >>=? fun constants ->
|
|
||||||
Context.set ctxt version_key
|
Context.set ctxt version_key
|
||||||
(MBytes.of_string version_value) >>= fun ctxt ->
|
(MBytes.of_string version_value) >>= fun ctxt ->
|
||||||
set_first_level ctxt first_level >>=? fun ctxt ->
|
set_first_level ctxt first_level >>=? fun ctxt ->
|
||||||
set_constants ctxt constants >>= fun ctxt ->
|
set_constants ctxt param.constants >>= fun ctxt ->
|
||||||
prepare ctxt ~level ~timestamp ~fitness >>=? fun ctxt ->
|
prepare ctxt ~level ~timestamp ~fitness >>=? fun ctxt ->
|
||||||
return (param, ctxt)
|
return (param, ctxt)
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ type storage_error =
|
|||||||
| Corrupted_data of string list
|
| Corrupted_data of string list
|
||||||
|
|
||||||
type error += Storage_error of storage_error
|
type error += Storage_error of storage_error
|
||||||
type error += Failed_to_parse_sandbox_parameter of MBytes.t
|
type error += Failed_to_parse_parameter of MBytes.t
|
||||||
|
type error += Failed_to_decode_parameter of Data_encoding.json * string
|
||||||
|
|
||||||
val storage_error: storage_error -> 'a tzresult Lwt.t
|
val storage_error: storage_error -> 'a tzresult Lwt.t
|
||||||
|
|
||||||
|
@ -14,12 +14,7 @@ let sandbox_parameters =
|
|||||||
match Data_encoding.Json.from_string {json|
|
match Data_encoding.Json.from_string {json|
|
||||||
{
|
{
|
||||||
"genesis_pubkey":
|
"genesis_pubkey":
|
||||||
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2"
|
||||||
"slot_durations" : [ 1, 0 ],
|
|
||||||
"cycle_length" : 4,
|
|
||||||
"block_per_roll_snapshot" : 2,
|
|
||||||
"time_before_reward" : 1,
|
|
||||||
"first_free_baking_slot" : 4
|
|
||||||
}
|
}
|
||||||
|json} with
|
|json} with
|
||||||
| Error err -> raise (Failure err)
|
| Error err -> raise (Failure err)
|
||||||
@ -47,7 +42,11 @@ let protocol_parameters =
|
|||||||
[ "tz1iDPZLxcGf5CqCNpTuuMdtu3zKpJ6HvvFR", "btz1TaSfoSNhFoqwqbPC9iC19rN24KJtB7skD", "71300478465380003" ],
|
[ "tz1iDPZLxcGf5CqCNpTuuMdtu3zKpJ6HvvFR", "btz1TaSfoSNhFoqwqbPC9iC19rN24KJtB7skD", "71300478465380003" ],
|
||||||
[ "tz1i2kbtVu65dP739qLGRpJNujRM8pdpkH3p", "btz1USqQRuvASPXwseXkGTWeWv4dn3VwMVPEk", "283380756728119992" ],
|
[ "tz1i2kbtVu65dP739qLGRpJNujRM8pdpkH3p", "btz1USqQRuvASPXwseXkGTWeWv4dn3VwMVPEk", "283380756728119992" ],
|
||||||
[ "tz1LKGCg6ESJLDviHkT8Jc7tUwjw4h3d9MaF", "btz1YwCKMbBLRL1qkBjAHGCwjbWDqiTAEFpbw", "1357762577679880028" ]
|
[ "tz1LKGCg6ESJLDviHkT8Jc7tUwjw4h3d9MaF", "btz1YwCKMbBLRL1qkBjAHGCwjbWDqiTAEFpbw", "1357762577679880028" ]
|
||||||
]
|
],
|
||||||
|
"time_between_blocks" : [ 1, 0 ],
|
||||||
|
"blocks_per_cycle" : 4,
|
||||||
|
"blocks_per_roll_snapshot" : 2,
|
||||||
|
"first_free_baking_slot" : 4
|
||||||
}
|
}
|
||||||
|json} in
|
|json} in
|
||||||
match json_result with
|
match json_result with
|
||||||
|
Loading…
Reference in New Issue
Block a user