diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index 690f212c7..8f2a6aa39 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -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 -> diff --git a/src/proto_alpha/lib_protocol/src/bootstrap_storage.ml b/src/proto_alpha/lib_protocol/src/bootstrap_storage.ml index ba637d896..8af4b6242 100644 --- a/src/proto_alpha/lib_protocol/src/bootstrap_storage.ml +++ b/src/proto_alpha/lib_protocol/src/bootstrap_storage.ml @@ -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 diff --git a/src/proto_alpha/lib_protocol/src/bootstrap_storage.mli b/src/proto_alpha/lib_protocol/src/bootstrap_storage.mli index 353bfc0d5..b399ea69c 100644 --- a/src/proto_alpha/lib_protocol/src/bootstrap_storage.mli +++ b/src/proto_alpha/lib_protocol/src/bootstrap_storage.mli @@ -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 -> diff --git a/src/proto_alpha/lib_protocol/src/init_storage.ml b/src/proto_alpha/lib_protocol/src/init_storage.ml index 08a043df3..22d119ad2 100644 --- a/src/proto_alpha/lib_protocol/src/init_storage.ml +++ b/src/proto_alpha/lib_protocol/src/init_storage.ml @@ -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 -> diff --git a/src/proto_alpha/lib_protocol/src/main.ml b/src/proto_alpha/lib_protocol/src/main.ml index d34a2ee80..3ebff5e49 100644 --- a/src/proto_alpha/lib_protocol/src/main.ml +++ b/src/proto_alpha/lib_protocol/src/main.ml @@ -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)