Alpha: remove some alphanet specifics
This commit is contained in:
parent
c125f822f5
commit
16758a5c74
@ -247,7 +247,6 @@ module Bootstrap : sig
|
||||
}
|
||||
val accounts: context -> account list
|
||||
val account_encoding: account Data_encoding.t
|
||||
val refill: context -> context tzresult Lwt.t
|
||||
end
|
||||
|
||||
module Constants : sig
|
||||
@ -692,7 +691,6 @@ end
|
||||
module Roll : sig
|
||||
|
||||
val value: context -> Tez.t
|
||||
val next: context -> Int32.t tzresult Lwt.t
|
||||
|
||||
val freeze_rolls_for_cycle: context -> Cycle.t -> context tzresult Lwt.t
|
||||
val clear_cycle: context -> Cycle.t -> context tzresult Lwt.t
|
||||
|
@ -102,20 +102,6 @@ module Context = struct
|
||||
~output: Level.encoding
|
||||
RPC_path.(custom_root / "context" / "next_level")
|
||||
|
||||
let roll_value =
|
||||
RPC_service.post_service
|
||||
~query: RPC_query.empty
|
||||
~input: empty
|
||||
~output: (obj1 (req "roll_value" Tez.encoding))
|
||||
RPC_path.(custom_root / "context" / "roll_value")
|
||||
|
||||
let next_roll =
|
||||
RPC_service.post_service
|
||||
~query: RPC_query.empty
|
||||
~input: empty
|
||||
~output: (obj1 (req "next_roll" int32))
|
||||
RPC_path.(custom_root / "context" / "next_roll")
|
||||
|
||||
let voting_period_kind =
|
||||
RPC_service.post_service
|
||||
~description: "Voting period kind for the current block"
|
||||
@ -140,12 +126,6 @@ module Context = struct
|
||||
register0 S.next_level begin fun ctxt () () ->
|
||||
return (Level.current ctxt)
|
||||
end ;
|
||||
register0 S.roll_value begin fun ctxt () () ->
|
||||
return (Roll.value ctxt)
|
||||
end;
|
||||
register0 S.next_roll begin fun ctxt () () ->
|
||||
Roll.next ctxt
|
||||
end ;
|
||||
register0 S.voting_period_kind begin fun ctxt () () ->
|
||||
Vote.get_current_period_kind ctxt
|
||||
end
|
||||
@ -156,12 +136,6 @@ module Context = struct
|
||||
let next_level ctxt block =
|
||||
RPC_context.make_call0 S.next_level ctxt block () ()
|
||||
|
||||
let roll_value ctxt block =
|
||||
RPC_context.make_call0 S.roll_value ctxt block () ()
|
||||
|
||||
let next_roll ctxt block =
|
||||
RPC_context.make_call0 S.next_roll ctxt block () ()
|
||||
|
||||
let voting_period_kind ctxt block =
|
||||
RPC_context.make_call0 S.voting_period_kind ctxt block () ()
|
||||
|
||||
|
@ -30,12 +30,6 @@ module Context : sig
|
||||
(** [next_level cctxt blk] returns the (protocol view of the) level
|
||||
of the successor of [blk]. *)
|
||||
|
||||
val next_roll:
|
||||
'a #RPC_context.simple -> 'a -> int32 shell_tzresult Lwt.t
|
||||
|
||||
val roll_value:
|
||||
'a #RPC_context.simple -> 'a -> Tez.t shell_tzresult Lwt.t
|
||||
|
||||
val voting_period_kind:
|
||||
'a #RPC_context.simple -> 'a -> Voting_period.kind shell_tzresult Lwt.t
|
||||
(** [voting_period_kind cctxt blk] returns the voting period kind
|
||||
|
@ -299,7 +299,6 @@ let may_start_new_cycle ctxt =
|
||||
| Some last_cycle ->
|
||||
let new_cycle = Cycle.succ last_cycle in
|
||||
let succ_new_cycle = Cycle.succ new_cycle in
|
||||
Bootstrap.refill ctxt >>=? fun ctxt ->
|
||||
Seed.clear_cycle ctxt last_cycle >>=? fun ctxt ->
|
||||
Seed.compute_for_cycle ctxt succ_new_cycle >>=? fun ctxt ->
|
||||
Roll.clear_cycle ctxt last_cycle >>=? fun ctxt ->
|
||||
|
@ -42,29 +42,3 @@ let account_encoding =
|
||||
(obj2
|
||||
(req "publicKeyHash" Ed25519.Public_key_hash.encoding)
|
||||
(req "publicKey" Ed25519.Public_key.encoding))
|
||||
|
||||
let refill ctxt =
|
||||
(* Unefficient HACK for the alphanet only... *)
|
||||
Contract_storage.list ctxt >>= fun contracts ->
|
||||
List.fold_left
|
||||
(fun total contract ->
|
||||
Contract_storage.get_balance ctxt contract >>=? fun balance ->
|
||||
total >>=? fun total -> Lwt.return Tez_repr.(total +? balance))
|
||||
(return Tez_repr.zero) contracts >>=? fun total ->
|
||||
(* The bootstrap accounts should have at least 1/2 of the total amount
|
||||
of tokens. *)
|
||||
let accounts = accounts ctxt in
|
||||
let min_balance =
|
||||
Tez_repr.(total /? 2L >>? fun r -> r /? (Int64.of_int (List.length accounts))) in
|
||||
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.(min_balance >>? fun r -> r -? balance) with
|
||||
| Error _ -> return ctxt
|
||||
| Ok tez -> Contract_storage.credit ctxt contract tez)
|
||||
ctxt
|
||||
accounts >>=? fun c ->
|
||||
Roll_storage.may_recompute_rolls c >>=? fun c ->
|
||||
return c
|
||||
|
@ -17,5 +17,3 @@ val account_encoding: account Data_encoding.t
|
||||
val accounts: Raw_context.t -> account list
|
||||
|
||||
val init: Raw_context.t -> Raw_context.t tzresult Lwt.t
|
||||
|
||||
val refill: Raw_context.t -> Raw_context.t tzresult Lwt.t
|
||||
|
@ -215,30 +215,5 @@ end
|
||||
|
||||
let value = Raw_context.roll_value
|
||||
|
||||
(* HACK for the alphanet: let's increase the roll value when
|
||||
the total amount of roll is greater than 100,000. *)
|
||||
let may_recompute_rolls c =
|
||||
Storage.Roll.Next.get c >>=? fun next ->
|
||||
let double = Roll_repr.too_many_roll next in
|
||||
if Compare.Int.(double <= 0) then
|
||||
return c
|
||||
else
|
||||
Raw_context.double_roll_value c double >>=? fun c ->
|
||||
Storage.Roll.clear c >>= fun c ->
|
||||
Storage.Roll.Limbo.remove c >>= fun c ->
|
||||
Storage.Roll.Next.init_set c Roll_repr.first >>= fun c ->
|
||||
Storage.Contract.fold c ~init:(ok c) ~f:begin fun k c ->
|
||||
Lwt.return c >>=? fun c ->
|
||||
Storage.Roll.Contract_roll_list.remove c k >>= fun c ->
|
||||
Storage.Roll.Contract_change.init_set c k Tez_repr.zero >>= fun c ->
|
||||
Storage.Contract.Balance.get c k >>=? fun balance ->
|
||||
Contract.add_amount c k balance >>=? fun c ->
|
||||
return c
|
||||
end
|
||||
|
||||
let next c =
|
||||
Storage.Roll.Next.get c >>=? fun next ->
|
||||
return (Roll_repr.to_int32 next)
|
||||
|
||||
let init c =
|
||||
Storage.Roll.Next.init c Roll_repr.first
|
||||
|
@ -63,7 +63,3 @@ val get_contract_delegate:
|
||||
Raw_context.t -> Contract_repr.t -> Ed25519.Public_key_hash.t option tzresult Lwt.t
|
||||
|
||||
val value: Raw_context.t -> Tez_repr.t
|
||||
|
||||
(** HACK for the alphanet. *)
|
||||
val may_recompute_rolls: Raw_context.t -> Raw_context.t tzresult Lwt.t
|
||||
val next: Raw_context.t -> Int32.t tzresult Lwt.t
|
||||
|
Loading…
Reference in New Issue
Block a user