Alpha: bootstrap contracts are typechecked

This commit is contained in:
Pierre Chambart 2018-06-23 17:45:48 +02:00
parent 8d45b07514
commit dd933b422b
5 changed files with 13 additions and 4 deletions

View File

@ -1042,6 +1042,7 @@ end
val prepare_first_block:
Context.t ->
typecheck:(context -> Script.t -> context tzresult Lwt.t) ->
level:Int32.t ->
timestamp:Time.t ->
fitness:Fitness.t ->

View File

@ -9,7 +9,7 @@
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
match script with
| 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 ->
return ctxt
| Some (contract, script) ->
typecheck ctxt script >>=? fun ctxt ->
Contract_storage.originate ctxt contract
~balance:amount
~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 ->
return ctxt
let init ctxt ?ramp_up_cycles ?no_reward_cycles accounts =
fold_left_s init_account ctxt accounts >>=? fun ctxt ->
let init ctxt ~typecheck ?ramp_up_cycles ?no_reward_cycles accounts =
fold_left_s (init_account ~typecheck) ctxt accounts >>=? fun ctxt ->
begin
match no_reward_cycles with
| None -> return ctxt

View File

@ -9,6 +9,7 @@
val init:
Raw_context.t ->
typecheck:(Raw_context.t -> Script_repr.t -> Raw_context.t tzresult Lwt.t) ->
?ramp_up_cycles:int ->
?no_reward_cycles:int ->
Parameters_repr.bootstrap_account list ->

View File

@ -8,7 +8,7 @@
(**************************************************************************)
(* 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
~level ~timestamp ~fitness ctxt >>=? fun (param, 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 ->
Contract_storage.init ctxt >>=? fun ctxt ->
Bootstrap_storage.init ctxt
~typecheck
?ramp_up_cycles:param.security_deposit_ramp_up_cycles
?no_reward_cycles:param.no_reward_cycles
param.bootstrap_accounts >>=? fun ctxt ->

View File

@ -266,6 +266,11 @@ let init ctxt block_header =
let level = block_header.Block_header.level in
let fitness = block_header.fitness 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
~typecheck
~level ~timestamp ~fitness ctxt >>=? fun ctxt ->
return (Alpha_context.finalize ctxt)