diff --git a/src/proto/bootstrap/apply.ml b/src/proto/bootstrap/apply.ml index a91c574de..7db9a1c1f 100644 --- a/src/proto/bootstrap/apply.ml +++ b/src/proto/bootstrap/apply.ml @@ -190,6 +190,7 @@ let may_start_new_cycle ctxt = >>=? fun reward_date -> Reward.set_reward_time_for_cycle ctxt last_cycle reward_date >>=? fun ctxt -> + Bootstrap.refill ctxt >>=? fun ctxt -> return ctxt let apply_main ctxt accept_failing_script block operations = diff --git a/src/proto/bootstrap/bootstrap_storage.ml b/src/proto/bootstrap/bootstrap_storage.ml index 9555ae33d..c6d6f205d 100644 --- a/src/proto/bootstrap/bootstrap_storage.ml +++ b/src/proto/bootstrap/bootstrap_storage.ml @@ -98,3 +98,14 @@ let account_encoding = (req "publicKey" Ed25519.public_key_encoding) (req "secretKey" Ed25519.secret_key_encoding)) +let refill ctxt = + fold_left_s + (fun ctxt account -> + let contract = + Contract_repr.default_contract account.public_key_hash in + Contract_storage.get_balance ctxt contract >>=? fun balance -> + match Tez_repr.(wealth -? balance) with + | Error _ -> return ctxt + | Ok tez -> Contract_storage.credit ctxt contract tez) + ctxt + accounts diff --git a/src/proto/bootstrap/bootstrap_storage.mli b/src/proto/bootstrap/bootstrap_storage.mli index f578bb61e..e8235b26a 100644 --- a/src/proto/bootstrap/bootstrap_storage.mli +++ b/src/proto/bootstrap/bootstrap_storage.mli @@ -18,3 +18,5 @@ val account_encoding: account Data_encoding.t val accounts: account list val init: Storage.t -> Storage.t tzresult Lwt.t + +val refill: Storage.t -> Storage.t tzresult Lwt.t diff --git a/src/proto/bootstrap/tezos_context.mli b/src/proto/bootstrap/tezos_context.mli index 2ba9f0e81..1f29a1e05 100644 --- a/src/proto/bootstrap/tezos_context.mli +++ b/src/proto/bootstrap/tezos_context.mli @@ -163,6 +163,7 @@ module Bootstrap : sig } val accounts: account list val account_encoding: account Data_encoding.t + val refill: context -> context tzresult Lwt.t end module Constants : sig