Alpha: bootstrap accounts and contracts cleanup
This commit is contained in:
parent
dd933b422b
commit
1e9a6e9941
@ -4,8 +4,11 @@
|
|||||||
[ "edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV", "4000000000000" ],
|
[ "edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV", "4000000000000" ],
|
||||||
[ "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU", "4000000000000" ],
|
[ "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU", "4000000000000" ],
|
||||||
[ "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n", "4000000000000" ],
|
[ "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n", "4000000000000" ],
|
||||||
[ "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", "10000000",
|
[ "tz1PooUKBaoxjBiCR2dxEtbtTUjLX3iaZQoJ", "100" ],
|
||||||
{ "address": "TZ1Yj9xA3jp8xy9maok89VB6HtBUtrK77tFk",
|
[ "edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2", "1" ] ],
|
||||||
|
"bootstrap_contracts": [
|
||||||
|
{ "delegate": "tz1TGu6TN5GSez2ndXXeDX6LgUDvLzPLqgYV",
|
||||||
|
"amount": "10000000",
|
||||||
"script":
|
"script":
|
||||||
{ "code":
|
{ "code":
|
||||||
[ { "prim": "parameter",
|
[ { "prim": "parameter",
|
||||||
@ -35,9 +38,7 @@
|
|||||||
{ "prim": "CONS" },
|
{ "prim": "CONS" },
|
||||||
{ "prim": "DIP", "args": [ [ { "prim": "NOW" } ] ] },
|
{ "prim": "DIP", "args": [ [ { "prim": "NOW" } ] ] },
|
||||||
{ "prim": "PAIR" } ] ] } ],
|
{ "prim": "PAIR" } ] ] } ],
|
||||||
"storage": { "int": "0" } } } ] ],
|
"storage": { "int": "0" } } } ],
|
||||||
"dictator_pubkey":
|
|
||||||
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
|
||||||
"time_between_blocks" : [ "1", "0" ],
|
"time_between_blocks" : [ "1", "0" ],
|
||||||
"blocks_per_roll_snapshot" : 4,
|
"blocks_per_roll_snapshot" : 4,
|
||||||
"blocks_per_cycle" : 8,
|
"blocks_per_cycle" : 8,
|
||||||
|
@ -38,8 +38,11 @@ init_sandboxed_client() {
|
|||||||
[ "edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV", "4000000000000" ],
|
[ "edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV", "4000000000000" ],
|
||||||
[ "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU", "4000000000000" ],
|
[ "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU", "4000000000000" ],
|
||||||
[ "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n", "4000000000000" ],
|
[ "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n", "4000000000000" ],
|
||||||
[ "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav", "10000000",
|
[ "tz1PooUKBaoxjBiCR2dxEtbtTUjLX3iaZQoJ", "100" ],
|
||||||
{ "address": "TZ1Yj9xA3jp8xy9maok89VB6HtBUtrK77tFk",
|
[ "edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2", "1" ] ],
|
||||||
|
"bootstrap_contracts": [
|
||||||
|
{ "delegate": "tz1TGu6TN5GSez2ndXXeDX6LgUDvLzPLqgYV",
|
||||||
|
"amount": "10000000",
|
||||||
"script":
|
"script":
|
||||||
{ "code":
|
{ "code":
|
||||||
[ { "prim": "parameter",
|
[ { "prim": "parameter",
|
||||||
@ -69,9 +72,7 @@ init_sandboxed_client() {
|
|||||||
{ "prim": "CONS" },
|
{ "prim": "CONS" },
|
||||||
{ "prim": "DIP", "args": [ [ { "prim": "NOW" } ] ] },
|
{ "prim": "DIP", "args": [ [ { "prim": "NOW" } ] ] },
|
||||||
{ "prim": "PAIR" } ] ] } ],
|
{ "prim": "PAIR" } ] ] } ],
|
||||||
"storage": { "int": "0" } } } ] ],
|
"storage": { "int": "0" } } } ],
|
||||||
"dictator_pubkey":
|
|
||||||
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2",
|
|
||||||
"time_between_blocks" : [ "1", "0" ],
|
"time_between_blocks" : [ "1", "0" ],
|
||||||
"blocks_per_roll_snapshot" : 4,
|
"blocks_per_roll_snapshot" : 4,
|
||||||
"blocks_per_cycle" : 8,
|
"blocks_per_cycle" : 8,
|
||||||
@ -230,7 +231,6 @@ BOOTSTRAP5_PUBLIC="edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n"
|
|||||||
BOOTSTRAP5_SECRET="unencrypted:edsk4QLrcijEffxV31gGdN2HU7UpyJjA8drFoNcmnB28n89YjPNRFm"
|
BOOTSTRAP5_SECRET="unencrypted:edsk4QLrcijEffxV31gGdN2HU7UpyJjA8drFoNcmnB28n89YjPNRFm"
|
||||||
|
|
||||||
DICTATOR_SECRET="unencrypted:edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6"
|
DICTATOR_SECRET="unencrypted:edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6"
|
||||||
FAUCET_ADDRESS="TZ1Yj9xA3jp8xy9maok89VB6HtBUtrK77tFk"
|
|
||||||
|
|
||||||
add_sandboxed_bootstrap_identities() {
|
add_sandboxed_bootstrap_identities() {
|
||||||
|
|
||||||
@ -252,9 +252,6 @@ activate_alpha() {
|
|||||||
and key dictator \
|
and key dictator \
|
||||||
and parameters "${parameters_file}" \
|
and parameters "${parameters_file}" \
|
||||||
--timestamp $(TZ='AAA+1' date +%FT%TZ)
|
--timestamp $(TZ='AAA+1' date +%FT%TZ)
|
||||||
|
|
||||||
${client} remember contract faucet ${FAUCET_ADDRESS}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
@ -9,28 +9,38 @@
|
|||||||
|
|
||||||
open Misc
|
open Misc
|
||||||
|
|
||||||
let init_account ~typecheck ctxt ({ public_key; amount; script }: Parameters_repr.bootstrap_account) =
|
let init_account ctxt
|
||||||
let public_key_hash = Signature.Public_key.hash public_key in
|
({ public_key_hash ; public_key ; amount }: Parameters_repr.bootstrap_account) =
|
||||||
match script with
|
|
||||||
| None ->
|
|
||||||
let contract = Contract_repr.implicit_contract public_key_hash in
|
let contract = Contract_repr.implicit_contract public_key_hash in
|
||||||
Contract_storage.credit ctxt contract amount >>=? fun ctxt ->
|
Contract_storage.credit ctxt contract amount >>=? fun ctxt ->
|
||||||
|
match public_key with
|
||||||
|
| Some public_key ->
|
||||||
Contract_storage.reveal_manager_key ctxt contract public_key >>=? fun ctxt ->
|
Contract_storage.reveal_manager_key ctxt contract public_key >>=? fun ctxt ->
|
||||||
Delegate_storage.set ctxt contract (Some public_key_hash) >>=? fun ctxt ->
|
Delegate_storage.set ctxt contract (Some public_key_hash) >>=? fun ctxt ->
|
||||||
return ctxt
|
return ctxt
|
||||||
| Some (contract, script) ->
|
| None -> return ctxt
|
||||||
|
|
||||||
|
let init_contract ~typecheck ctxt
|
||||||
|
({ delegate ; amount ; script }: Parameters_repr.bootstrap_contract) =
|
||||||
|
Contract_storage.fresh_contract_from_current_nonce ctxt >>=? fun (ctxt, contract) ->
|
||||||
typecheck ctxt script >>=? fun ctxt ->
|
typecheck ctxt script >>=? fun ctxt ->
|
||||||
Contract_storage.originate ctxt contract
|
Contract_storage.originate ctxt contract
|
||||||
~balance:amount
|
~balance:amount
|
||||||
~manager:Signature.Public_key_hash.zero
|
~manager:Signature.Public_key_hash.zero
|
||||||
~script:(script, None)
|
~script:(script, None)
|
||||||
~delegate:(Some public_key_hash)
|
~delegate:(Some delegate)
|
||||||
~spendable:false
|
~spendable:false
|
||||||
~delegatable:false >>=? fun ctxt ->
|
~delegatable:false >>=? fun ctxt ->
|
||||||
return ctxt
|
return ctxt
|
||||||
|
|
||||||
let init ctxt ~typecheck ?ramp_up_cycles ?no_reward_cycles accounts =
|
let init ctxt ~typecheck ?ramp_up_cycles ?no_reward_cycles accounts contracts =
|
||||||
fold_left_s (init_account ~typecheck) ctxt accounts >>=? fun ctxt ->
|
let nonce =
|
||||||
|
Operation_hash.hash_bytes
|
||||||
|
(* FIXME: change this nonce before lunch *)
|
||||||
|
[ MBytes.of_string "ZERONET_INIT_ORIGINATION_NONCE" ] in
|
||||||
|
let ctxt = Raw_context.init_origination_nonce ctxt nonce in
|
||||||
|
fold_left_s init_account ctxt accounts >>=? fun ctxt ->
|
||||||
|
fold_left_s (init_contract ~typecheck) ctxt contracts >>=? fun ctxt ->
|
||||||
begin
|
begin
|
||||||
match no_reward_cycles with
|
match no_reward_cycles with
|
||||||
| None -> return ctxt
|
| None -> return ctxt
|
||||||
|
@ -13,6 +13,7 @@ val init:
|
|||||||
?ramp_up_cycles:int ->
|
?ramp_up_cycles:int ->
|
||||||
?no_reward_cycles:int ->
|
?no_reward_cycles:int ->
|
||||||
Parameters_repr.bootstrap_account list ->
|
Parameters_repr.bootstrap_account list ->
|
||||||
|
Parameters_repr.bootstrap_contract list ->
|
||||||
Raw_context.t tzresult Lwt.t
|
Raw_context.t tzresult Lwt.t
|
||||||
|
|
||||||
val cycle_end:
|
val cycle_end:
|
||||||
|
@ -19,7 +19,8 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness =
|
|||||||
~typecheck
|
~typecheck
|
||||||
?ramp_up_cycles:param.security_deposit_ramp_up_cycles
|
?ramp_up_cycles:param.security_deposit_ramp_up_cycles
|
||||||
?no_reward_cycles:param.no_reward_cycles
|
?no_reward_cycles:param.no_reward_cycles
|
||||||
param.bootstrap_accounts >>=? fun ctxt ->
|
param.bootstrap_accounts
|
||||||
|
param.bootstrap_contracts >>=? fun ctxt ->
|
||||||
Roll_storage.init_first_cycles ctxt >>=? fun ctxt ->
|
Roll_storage.init_first_cycles ctxt >>=? fun ctxt ->
|
||||||
Vote_storage.init ctxt >>=? fun ctxt ->
|
Vote_storage.init ctxt >>=? fun ctxt ->
|
||||||
Storage.Last_block_priority.init ctxt 0 >>=? fun ctxt ->
|
Storage.Last_block_priority.init ctxt 0 >>=? fun ctxt ->
|
||||||
|
@ -8,13 +8,20 @@
|
|||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
type bootstrap_account = {
|
type bootstrap_account = {
|
||||||
public_key : Signature.Public_key.t ;
|
public_key_hash : Signature.Public_key_hash.t ;
|
||||||
|
public_key : Signature.Public_key.t option ;
|
||||||
amount : Tez_repr.t ;
|
amount : Tez_repr.t ;
|
||||||
script : (Contract_repr.t * Script_repr.t) option ;
|
}
|
||||||
|
|
||||||
|
type bootstrap_contract = {
|
||||||
|
delegate : Signature.Public_key_hash.t ;
|
||||||
|
amount : Tez_repr.t ;
|
||||||
|
script : Script_repr.t ;
|
||||||
}
|
}
|
||||||
|
|
||||||
type t = {
|
type t = {
|
||||||
bootstrap_accounts : bootstrap_account list ;
|
bootstrap_accounts : bootstrap_account list ;
|
||||||
|
bootstrap_contracts : bootstrap_contract list ;
|
||||||
commitments : Commitment_repr.t list ;
|
commitments : Commitment_repr.t list ;
|
||||||
constants : Constants_repr.parametric ;
|
constants : Constants_repr.parametric ;
|
||||||
security_deposit_ramp_up_cycles : int option ;
|
security_deposit_ramp_up_cycles : int option ;
|
||||||
@ -24,29 +31,43 @@ type t = {
|
|||||||
let bootstrap_account_encoding =
|
let bootstrap_account_encoding =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
union
|
union
|
||||||
[ case (Tag 0) ~title:"Non_scripted"
|
[ case (Tag 0) ~title:"Public_key_known"
|
||||||
(tup2
|
(tup2
|
||||||
Signature.Public_key.encoding
|
Signature.Public_key.encoding
|
||||||
Tez_repr.encoding)
|
Tez_repr.encoding)
|
||||||
(function
|
(function
|
||||||
| { public_key ; amount ; script = None } ->
|
| { public_key_hash ; public_key = Some public_key ; amount } ->
|
||||||
|
assert (Signature.Public_key_hash.equal
|
||||||
|
(Signature.Public_key.hash public_key)
|
||||||
|
public_key_hash) ;
|
||||||
Some (public_key, amount)
|
Some (public_key, amount)
|
||||||
| { script = Some _ } -> None)
|
| { public_key = None } -> None)
|
||||||
(fun (public_key, amount) ->
|
(fun (public_key, amount) ->
|
||||||
{ public_key ; amount ; script = None }) ;
|
{ public_key = Some public_key ;
|
||||||
case (Tag 1) ~title:"Scripted"
|
public_key_hash = Signature.Public_key.hash public_key ;
|
||||||
(tup3
|
amount }) ;
|
||||||
Signature.Public_key.encoding
|
case (Tag 1) ~title:"Public_key_unknown"
|
||||||
Tez_repr.encoding
|
(tup2
|
||||||
(obj2
|
Signature.Public_key_hash.encoding
|
||||||
(req "address" Contract_repr.encoding)
|
Tez_repr.encoding)
|
||||||
(req "script" Script_repr.encoding)))
|
|
||||||
(function
|
(function
|
||||||
| { public_key ; amount ; script = Some script } ->
|
| { public_key_hash ; public_key = None ; amount } ->
|
||||||
Some (public_key, amount, script)
|
Some (public_key_hash, amount)
|
||||||
| { script = None } -> None)
|
| { public_key = Some _ } -> None)
|
||||||
(fun (public_key, amount, script) ->
|
(fun (public_key_hash, amount) ->
|
||||||
{ public_key ; amount ; script = Some script }) ]
|
{ public_key = None ;
|
||||||
|
public_key_hash ;
|
||||||
|
amount }) ]
|
||||||
|
|
||||||
|
let bootstrap_contract_encoding =
|
||||||
|
let open Data_encoding in
|
||||||
|
conv
|
||||||
|
(fun { delegate ; amount ; script } -> (delegate, amount, script))
|
||||||
|
(fun (delegate, amount, script) -> { delegate ; amount ; script })
|
||||||
|
(obj3
|
||||||
|
(req "delegate" Signature.Public_key_hash.encoding)
|
||||||
|
(req "amount" Tez_repr.encoding)
|
||||||
|
(req "script" Script_repr.encoding))
|
||||||
|
|
||||||
(* This encoding is used to read configuration files (e.g. sandbox.json)
|
(* 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
|
where some fields can be missing, in that case they are replaced by
|
||||||
@ -249,19 +270,20 @@ let constants_encoding =
|
|||||||
let encoding =
|
let encoding =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
(fun { bootstrap_accounts ; commitments ; constants ;
|
(fun { bootstrap_accounts ; bootstrap_contracts ; commitments ; constants ;
|
||||||
security_deposit_ramp_up_cycles ; no_reward_cycles } ->
|
security_deposit_ramp_up_cycles ; no_reward_cycles } ->
|
||||||
((bootstrap_accounts, commitments,
|
((bootstrap_accounts, bootstrap_contracts, commitments,
|
||||||
security_deposit_ramp_up_cycles, no_reward_cycles),
|
security_deposit_ramp_up_cycles, no_reward_cycles),
|
||||||
constants))
|
constants))
|
||||||
(fun ( (bootstrap_accounts, commitments,
|
(fun ( (bootstrap_accounts, bootstrap_contracts, commitments,
|
||||||
security_deposit_ramp_up_cycles, no_reward_cycles),
|
security_deposit_ramp_up_cycles, no_reward_cycles),
|
||||||
constants) ->
|
constants) ->
|
||||||
{ bootstrap_accounts ; commitments ; constants ;
|
{ bootstrap_accounts ; bootstrap_contracts ; commitments ; constants ;
|
||||||
security_deposit_ramp_up_cycles ; no_reward_cycles })
|
security_deposit_ramp_up_cycles ; no_reward_cycles })
|
||||||
(merge_objs
|
(merge_objs
|
||||||
(obj4
|
(obj5
|
||||||
(req "bootstrap_accounts" (list bootstrap_account_encoding))
|
(req "bootstrap_accounts" (list bootstrap_account_encoding))
|
||||||
|
(dft "bootstrap_contracts" (list bootstrap_contract_encoding) [])
|
||||||
(dft "commitments" (list Commitment_repr.encoding) [])
|
(dft "commitments" (list Commitment_repr.encoding) [])
|
||||||
(opt "security_deposit_ramp_up_cycles" int31)
|
(opt "security_deposit_ramp_up_cycles" int31)
|
||||||
(opt "no_reward_cycles" int31))
|
(opt "no_reward_cycles" int31))
|
||||||
|
@ -8,13 +8,20 @@
|
|||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
type bootstrap_account = {
|
type bootstrap_account = {
|
||||||
public_key : Signature.Public_key.t ;
|
public_key_hash : Signature.Public_key_hash.t ;
|
||||||
|
public_key : Signature.Public_key.t option ;
|
||||||
amount : Tez_repr.t ;
|
amount : Tez_repr.t ;
|
||||||
script : (Contract_repr.t * Script_repr.t) option ;
|
}
|
||||||
|
|
||||||
|
type bootstrap_contract = {
|
||||||
|
delegate : Signature.Public_key_hash.t ;
|
||||||
|
amount : Tez_repr.t ;
|
||||||
|
script : Script_repr.t ;
|
||||||
}
|
}
|
||||||
|
|
||||||
type t = {
|
type t = {
|
||||||
bootstrap_accounts : bootstrap_account list ;
|
bootstrap_accounts : bootstrap_account list ;
|
||||||
|
bootstrap_contracts : bootstrap_contract list ;
|
||||||
commitments : Commitment_repr.t list ;
|
commitments : Commitment_repr.t list ;
|
||||||
constants : Constants_repr.parametric ;
|
constants : Constants_repr.parametric ;
|
||||||
security_deposit_ramp_up_cycles : int option ;
|
security_deposit_ramp_up_cycles : int option ;
|
||||||
|
@ -184,8 +184,8 @@ let initial_context
|
|||||||
no_reward_cycles
|
no_reward_cycles
|
||||||
=
|
=
|
||||||
let bootstrap_accounts =
|
let bootstrap_accounts =
|
||||||
List.map (fun (Account.{ pk = public_key ; _ }, amount) ->
|
List.map (fun (Account.{ pk ; pkh ; _ }, amount) ->
|
||||||
Parameters_repr.{ public_key ; amount; script = None }
|
Parameters_repr.{ public_key_hash = pkh ; public_key = Some pk ; amount }
|
||||||
) initial_accounts
|
) initial_accounts
|
||||||
in
|
in
|
||||||
let json =
|
let json =
|
||||||
@ -193,6 +193,7 @@ let initial_context
|
|||||||
Parameters_repr.encoding
|
Parameters_repr.encoding
|
||||||
Parameters_repr.{
|
Parameters_repr.{
|
||||||
bootstrap_accounts ;
|
bootstrap_accounts ;
|
||||||
|
bootstrap_contracts = [] ;
|
||||||
commitments ;
|
commitments ;
|
||||||
constants ;
|
constants ;
|
||||||
security_deposit_ramp_up_cycles ;
|
security_deposit_ramp_up_cycles ;
|
||||||
|
Loading…
Reference in New Issue
Block a user