Alpha: bootstrap contracts are typechecked
This commit is contained in:
parent
8d45b07514
commit
dd933b422b
@ -1042,6 +1042,7 @@ end
|
|||||||
|
|
||||||
val prepare_first_block:
|
val prepare_first_block:
|
||||||
Context.t ->
|
Context.t ->
|
||||||
|
typecheck:(context -> Script.t -> context tzresult Lwt.t) ->
|
||||||
level:Int32.t ->
|
level:Int32.t ->
|
||||||
timestamp:Time.t ->
|
timestamp:Time.t ->
|
||||||
fitness:Fitness.t ->
|
fitness:Fitness.t ->
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
open Misc
|
open Misc
|
||||||
|
|
||||||
let init_account ctxt ({ public_key; amount; script }: Parameters_repr.bootstrap_account) =
|
let init_account ~typecheck ctxt ({ public_key; amount; script }: Parameters_repr.bootstrap_account) =
|
||||||
let public_key_hash = Signature.Public_key.hash public_key in
|
let public_key_hash = Signature.Public_key.hash public_key in
|
||||||
match script with
|
match script with
|
||||||
| None ->
|
| None ->
|
||||||
@ -19,6 +19,7 @@ let init_account ctxt ({ public_key; amount; script }: Parameters_repr.bootstrap
|
|||||||
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) ->
|
| Some (contract, script) ->
|
||||||
|
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
|
||||||
@ -28,8 +29,8 @@ let init_account ctxt ({ public_key; amount; script }: Parameters_repr.bootstrap
|
|||||||
~delegatable:false >>=? fun ctxt ->
|
~delegatable:false >>=? fun ctxt ->
|
||||||
return ctxt
|
return ctxt
|
||||||
|
|
||||||
let init ctxt ?ramp_up_cycles ?no_reward_cycles accounts =
|
let init ctxt ~typecheck ?ramp_up_cycles ?no_reward_cycles accounts =
|
||||||
fold_left_s init_account ctxt accounts >>=? fun ctxt ->
|
fold_left_s (init_account ~typecheck) ctxt accounts >>=? fun ctxt ->
|
||||||
begin
|
begin
|
||||||
match no_reward_cycles with
|
match no_reward_cycles with
|
||||||
| None -> return ctxt
|
| None -> return ctxt
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
val init:
|
val init:
|
||||||
Raw_context.t ->
|
Raw_context.t ->
|
||||||
|
typecheck:(Raw_context.t -> Script_repr.t -> Raw_context.t tzresult Lwt.t) ->
|
||||||
?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 ->
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
(* This is the genesis protocol: initialise the state *)
|
(* This is the genesis protocol: initialise the state *)
|
||||||
let prepare_first_block ctxt ~level ~timestamp ~fitness =
|
let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness =
|
||||||
Raw_context.prepare_first_block
|
Raw_context.prepare_first_block
|
||||||
~level ~timestamp ~fitness ctxt >>=? fun (param, ctxt) ->
|
~level ~timestamp ~fitness ctxt >>=? fun (param, ctxt) ->
|
||||||
Commitment_storage.init ctxt param.commitments >>=? fun ctxt ->
|
Commitment_storage.init ctxt param.commitments >>=? fun ctxt ->
|
||||||
@ -16,6 +16,7 @@ let prepare_first_block ctxt ~level ~timestamp ~fitness =
|
|||||||
Seed_storage.init ctxt >>=? fun ctxt ->
|
Seed_storage.init ctxt >>=? fun ctxt ->
|
||||||
Contract_storage.init ctxt >>=? fun ctxt ->
|
Contract_storage.init ctxt >>=? fun ctxt ->
|
||||||
Bootstrap_storage.init ctxt
|
Bootstrap_storage.init ctxt
|
||||||
|
~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 >>=? fun ctxt ->
|
||||||
|
@ -266,6 +266,11 @@ let init ctxt block_header =
|
|||||||
let level = block_header.Block_header.level in
|
let level = block_header.Block_header.level in
|
||||||
let fitness = block_header.fitness in
|
let fitness = block_header.fitness in
|
||||||
let timestamp = block_header.timestamp in
|
let timestamp = block_header.timestamp in
|
||||||
|
let typecheck (ctxt:Alpha_context.context) (script:Alpha_context.Script.t) =
|
||||||
|
Script_ir_translator.parse_script ctxt script >>=? fun (_ex_script, ctxt) ->
|
||||||
|
return ctxt
|
||||||
|
in
|
||||||
Alpha_context.prepare_first_block
|
Alpha_context.prepare_first_block
|
||||||
|
~typecheck
|
||||||
~level ~timestamp ~fitness ctxt >>=? fun ctxt ->
|
~level ~timestamp ~fitness ctxt >>=? fun ctxt ->
|
||||||
return (Alpha_context.finalize ctxt)
|
return (Alpha_context.finalize ctxt)
|
||||||
|
Loading…
Reference in New Issue
Block a user