From 07486a3027cbac1d15c0c8ea4c00e71ad4f91e90 Mon Sep 17 00:00:00 2001 From: Vincent Botbol Date: Tue, 17 Jul 2018 14:04:33 +0200 Subject: [PATCH] Alpha/Origination: ensure that delegate's originated accounts are registered --- src/proto_alpha/lib_protocol/src/delegate_storage.ml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/proto_alpha/lib_protocol/src/delegate_storage.ml b/src/proto_alpha/lib_protocol/src/delegate_storage.ml index 4fbbdd262..231746c71 100644 --- a/src/proto_alpha/lib_protocol/src/delegate_storage.ml +++ b/src/proto_alpha/lib_protocol/src/delegate_storage.ml @@ -253,6 +253,14 @@ let registered c delegate = c (Contract_repr.implicit_contract delegate) let init ctxt contract delegate = + known ctxt delegate >>=? fun known_delegate -> + fail_unless + known_delegate + (Roll_storage.Unregistered_delegate delegate) >>=? fun () -> + registered ctxt delegate >>= fun is_registered -> + fail_unless + is_registered + (Roll_storage.Unregistered_delegate delegate) >>=? fun () -> Storage.Contract.Delegate.init ctxt contract delegate >>=? fun ctxt -> Storage.Contract.Balance.get ctxt contract >>=? fun balance -> link ctxt contract delegate balance