RPC: remove subfield accessors

This is painful to maintain and `jq` works well.
This commit is contained in:
Grégoire Henry 2018-05-29 13:14:04 +02:00 committed by Benjamin Canou
parent e4ffbd2854
commit 632144b689
14 changed files with 145 additions and 506 deletions

View File

@ -10,8 +10,8 @@
open Client_config
let get_commands_for_version ctxt block protocol =
Shell_services.Blocks.Metadata.next_protocol_hash ctxt ~block () >>= function
| Ok version -> begin
Shell_services.Blocks.protocols ctxt ~block () >>= function
| Ok { next_protocol = version } -> begin
match protocol with
| None ->
return (Some version, Client_commands.commands_for_version version)

View File

@ -19,9 +19,9 @@ protocol_version="PsgZ1PB2h82sTKznNbmZxtbsU432eKDv1W6cf1cJFhCFmGYSiJs"
$admin_client inject protocol "$test_dir/demo"
$admin_client list protocols
$client activate protocol $protocol_version with fitness 1 and key dictator and parameters $parameters_file
answ=$($client -p ProtoALphaALph rpc get /chains/main/blocks/head/metadata/next_protocol_hash 2>/dev/null)
answ=$($client -p ProtoALphaALph rpc get /chains/main/blocks/head/metadata 2>/dev/null)
if ! grep "$protocol_version" <<< $answ ; then
if ! grep "\"next_protocol\": \"$protocol_version\"" <<< $answ ; then
exit 1
fi

View File

@ -40,8 +40,8 @@ assert_propagation_level() {
level=$1
printf "\n\nAsserting all nodes have reached level %s\n" "$level"
for client in "${client_instances[@]}"; do
( $client rpc get /chains/main/blocks/head/header/shell/level \
| assert_in_output "$level" ) \
( $client rpc get /chains/main/blocks/head/header/shell \
| assert_in_output "\"level\": $level" ) \
|| exit 2
done
}
@ -51,7 +51,7 @@ assert_protocol() {
proto=$1
printf "\n\nAsserting protocol propagation\n"
for client in "${client_instances[@]}"; do
( $client rpc get /chains/main/blocks/head/metadata/next_protocol_hash | assert_in_output "$proto" ) \
( $client rpc get /chains/main/blocks/head/metadata | assert_in_output "\"next_protocol\": \"$proto\"" ) \
|| exit 2
done
}

View File

@ -27,8 +27,8 @@ let wait_for_operation_inclusion
let fetch_predecessors block =
let rec loop acc block =
Block_services.Empty.Header.Shell.predecessor
ctxt ~chain ~block:(`Hash (block, 0)) () >>=? fun predecessor ->
Block_services.Empty.Header.shell_header
ctxt ~chain ~block:(`Hash (block, 0)) () >>=? fun { predecessor } ->
if Block_hash.Table.mem blocks predecessor then
return acc
else
@ -48,8 +48,8 @@ let wait_for_operation_inclusion
let process block =
Shell_services.Blocks.hash ctxt ~chain ~block () >>=? fun hash ->
Shell_services.Blocks.Header.Shell.predecessor
ctxt ~chain ~block () >>=? fun predecessor ->
Shell_services.Blocks.Header.shell_header
ctxt ~chain ~block () >>=? fun { predecessor } ->
match Block_hash.Table.find blocks predecessor with
| Some (block_with_op, n) ->
ctxt#answer

View File

@ -56,7 +56,7 @@ let build_raw_rpc_directory
(* block header *)
register0 S.Header.header begin fun block () () ->
register0 S.header begin fun block () () ->
let chain_id = State.Block.chain_id block in
let hash = State.Block.hash block in
let header = State.Block.header block in
@ -70,30 +70,6 @@ let build_raw_rpc_directory
register0 S.Header.shell_header begin fun block () () ->
return (State.Block.header block).shell
end ;
register0 S.Header.Shell.level begin fun block () () ->
return (State.Block.header block).shell.level
end ;
register0 S.Header.Shell.protocol_level begin fun block () () ->
return (State.Block.header block).shell.proto_level
end ;
register0 S.Header.Shell.predecessor begin fun block () () ->
return (State.Block.header block).shell.predecessor
end ;
register0 S.Header.Shell.timestamp begin fun block () () ->
return (State.Block.header block).shell.timestamp
end ;
register0 S.Header.Shell.validation_passes begin fun block () () ->
return (State.Block.header block).shell.validation_passes
end ;
register0 S.Header.Shell.operations_hash begin fun block () () ->
return (State.Block.header block).shell.operations_hash
end ;
register0 S.Header.Shell.fitness begin fun block () () ->
return (State.Block.header block).shell.fitness
end ;
register0 S.Header.Shell.context_hash begin fun block () () ->
return (State.Block.header block).shell.context
end ;
register0 S.Header.protocol_data begin fun block () () ->
let header = State.Block.header block in
return
@ -123,40 +99,9 @@ let build_raw_rpc_directory
Next_proto.validation_passes ;
} in
register0 S.Metadata.metadata begin fun block () () ->
register0 S.metadata begin fun block () () ->
metadata block
end ;
register0 S.Metadata.protocol_data begin fun block () () ->
return
(Data_encoding.Binary.of_bytes_exn
Proto.block_header_metadata_encoding
(State.Block.metadata block))
end ;
register0 S.Metadata.protocol_hash begin fun _block () () ->
return Proto.hash
end ;
register0 S.Metadata.next_protocol_hash begin fun _block () () ->
return Next_proto.hash
end ;
register0 S.Metadata.test_chain_status begin fun block () () ->
State.Block.test_chain block >>= return
end ;
register0 S.Metadata.max_operations_ttl begin fun block () () ->
return (State.Block.max_operations_ttl block)
end ;
register0 S.Metadata.max_operation_data_length begin fun block () () ->
return (State.Block.max_operation_data_length block)
end ;
register0 S.Metadata.max_block_header_length begin fun _block () () ->
return (Next_proto.max_block_length) ;
end ;
register0 S.Metadata.operation_list_quota begin fun _block () () ->
return
(List.map
(fun { Tezos_protocol_environment_shell.max_size; max_op } ->
{ Tezos_shell_services.Block_services.max_size ; max_op } )
Next_proto.validation_passes)
end ;
(* operations *)

View File

@ -158,6 +158,24 @@ module type PROTO = sig
(operation_data * operation_receipt) Data_encoding.t
end
type protocols = {
current_protocol: Protocol_hash.t ;
next_protocol: Protocol_hash.t ;
}
let raw_protocol_encoding =
conv
(fun { current_protocol ; next_protocol } ->
((current_protocol, next_protocol), ()))
(fun ((current_protocol, next_protocol), ()) ->
{ current_protocol ; next_protocol })
(merge_objs
(obj2
(req "protocol" Protocol_hash.encoding)
(req "next_protocol" Protocol_hash.encoding))
unit)
module Make(Proto : PROTO)(Next_proto : PROTO) = struct
let protocol_hash = Protocol_hash.to_b58check Proto.hash
@ -310,16 +328,31 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
~output: Block_hash.encoding
RPC_path.(path / "hash")
module Header = struct
let path = RPC_path.(path / "header")
let header =
RPC_service.get_service
~description:"The whole block header."
~query: RPC_query.empty
~output: block_header_encoding
path
RPC_path.(path / "header")
let metadata =
RPC_service.get_service
~description:"All the metadata associated to the block."
~query: RPC_query.empty
~output: block_metadata_encoding
RPC_path.(path / "metadata")
let protocols =
(* same endpoint than 'metadata' *)
RPC_service.get_service
~description:".. unexported ..."
~query: RPC_query.empty
~output: raw_protocol_encoding
RPC_path.(path / "metadata")
module Header = struct
let path = RPC_path.(path / "header")
let shell_header =
RPC_service.get_service
@ -340,142 +373,6 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
Proto.block_header_data_encoding))
RPC_path.(path / "protocol_data")
module Shell = struct
let path = RPC_path.(path / "shell")
let level =
RPC_service.get_service
~description:"The block's level."
~query: RPC_query.empty
~output: int32
RPC_path.(path / "level")
let protocol_level =
RPC_service.get_service
~description:"The block's protocol level (modulo 256)."
~query: RPC_query.empty
~output: uint8
RPC_path.(path / "proto_level")
let predecessor =
RPC_service.get_service
~description:"The previous block's id."
~query: RPC_query.empty
~output: Block_hash.encoding
RPC_path.(path / "predecessor")
let timestamp =
RPC_service.get_service
~description:"The block's timestamp."
~query: RPC_query.empty
~output: Time.encoding
RPC_path.(path / "timestamp")
let validation_passes =
RPC_service.get_service
~description:"The number of validation passes for the block."
~query: RPC_query.empty
~output: uint8
RPC_path.(path / "validation_passes")
let operations_hash =
RPC_service.get_service
~description:"The hash of merkle tree of the operations included in the block."
~query: RPC_query.empty
~output: Operation_list_list_hash.encoding
RPC_path.(path / "operations_hash")
let fitness =
RPC_service.get_service
~description:"The block's fitness."
~query: RPC_query.empty
~output: Fitness.encoding
RPC_path.(path / "fitness")
let context_hash =
RPC_service.get_service
~description:"The hash of the resulting validation context."
~query: RPC_query.empty
~output: Context_hash.encoding
RPC_path.(path / "context_hash")
end
end
module Metadata = struct
let path = RPC_path.(path / "metadata")
let metadata =
RPC_service.get_service
~description:"All the metadata associated to the block."
~query: RPC_query.empty
~output: block_metadata_encoding
path
let protocol_data =
RPC_service.get_service
~description:"The protocol-specific metadata associated to the block."
~query: RPC_query.empty
~output:
(conv
(fun h -> ((), h)) (fun ((), h) -> h)
(merge_objs
(obj1 (req "protocol" (constant protocol_hash)))
Proto.block_header_metadata_encoding))
RPC_path.(path / "protocol_data")
let protocol_hash =
RPC_service.get_service
~description:"The protocol used to bake this block."
~query: RPC_query.empty
~output: Protocol_hash.encoding
RPC_path.(path / "protocol_hash")
let next_protocol_hash =
RPC_service.get_service
~description:"The protocol required to bake the next block."
~query: RPC_query.empty
~output: Protocol_hash.encoding
RPC_path.(path / "next_protocol_hash")
let test_chain_status =
RPC_service.get_service
~description:"The status of the associated test chain."
~query: RPC_query.empty
~output: Test_chain_status.encoding
RPC_path.(path / "test_chain_status")
let max_operations_ttl =
RPC_service.get_service
~description:"... FIXME ..."
~query: RPC_query.empty
~output: int31
RPC_path.(path / "max_operations_ttl")
let max_operation_data_length =
RPC_service.get_service
~description:"... FIXME ..."
~query: RPC_query.empty
~output: int31
RPC_path.(path / "max_operation_data_length")
let max_block_header_length =
RPC_service.get_service
~description:"... FIXME ..."
~query: RPC_query.empty
~output: int31
RPC_path.(path / "max_block_header_length")
let operation_list_quota =
RPC_service.get_service
~description:"... FIXME ..."
~query: RPC_query.empty
~output: (list operation_list_quota_encoding)
RPC_path.(path / "operation_list_quota")
end
module Operation = struct
@ -707,120 +604,34 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
| `Hash (h, 0) -> return h
| _ -> f chain block () ()
module Header = struct
module S = S.Header
let header ctxt =
let f = make_call0 S.header ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let shell_header ctxt =
let f = make_call0 S.shell_header ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let protocol_data ctxt =
let f = make_call0 S.protocol_data ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
module Shell = struct
module S = S.Shell
let level ctxt =
let f = make_call0 S.level ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let protocol_level ctxt =
let f = make_call0 S.protocol_level ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let predecessor ctxt =
let f = make_call0 S.predecessor ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let timestamp ctxt =
let f = make_call0 S.timestamp ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let validation_passes ctxt =
let f = make_call0 S.validation_passes ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let operations_hash ctxt =
let f = make_call0 S.operations_hash ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let fitness ctxt =
let f = make_call0 S.fitness ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let context_hash ctxt =
let f = make_call0 S.context_hash ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
end
end
module Metadata = struct
module S = S.Metadata
let metadata ctxt =
let f = make_call0 S.metadata ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let protocols ctxt =
let f = make_call0 S.protocols ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
module Header = struct
module S = S.Header
let shell_header ctxt =
let f = make_call0 S.shell_header ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let protocol_data ctxt =
let f = make_call0 S.protocol_data ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let protocol_hash ctxt =
let f = make_call0 S.protocol_hash ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let next_protocol_hash ctxt =
let f = make_call0 S.next_protocol_hash ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let test_chain_status ctxt =
let f = make_call0 S.test_chain_status ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let max_operations_ttl ctxt =
let f = make_call0 S.max_operations_ttl ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let max_operation_data_length ctxt =
let f = make_call0 S.max_operation_data_length ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let max_block_header_length ctxt =
let f = make_call0 S.max_block_header_length ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
let max_operation_list_length ctxt =
let f = make_call0 S.operation_list_quota ctxt in
fun ?(chain = `Main) ?(block = `Head 0) () ->
f chain block () ()
end
module Operation = struct
@ -961,3 +772,5 @@ let () =
| Json_schema.Duplicate_definition _ ) as exn ->
Some (Format.asprintf "%a" (fun ppf -> Json_schema.print_error ppf) exn)
| _ -> None)
let protocols = Empty.protocols

View File

@ -120,11 +120,16 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
#simple -> ?chain:chain -> ?block:block ->
unit -> Block_hash.t tzresult Lwt.t
module Header : sig
val header:
#simple -> ?chain:chain -> ?block:block ->
unit -> block_header tzresult Lwt.t
val metadata:
#simple -> ?chain:chain -> ?block:block ->
unit -> block_metadata tzresult Lwt.t
module Header : sig
val shell_header:
#simple -> ?chain:chain -> ?block:block ->
unit -> Block_header.shell_header tzresult Lwt.t
@ -132,67 +137,6 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
#simple -> ?chain:chain -> ?block:block ->
unit -> Proto.block_header_data tzresult Lwt.t
module Shell : sig
val level:
#simple -> ?chain:chain -> ?block:block ->
unit -> Int32.t tzresult Lwt.t
val protocol_level:
#simple -> ?chain:chain -> ?block:block ->
unit -> int tzresult Lwt.t
val predecessor:
#simple -> ?chain:chain -> ?block:block ->
unit -> Block_hash.t tzresult Lwt.t
val timestamp:
#simple -> ?chain:chain -> ?block:block ->
unit -> Time.t tzresult Lwt.t
val validation_passes:
#simple -> ?chain:chain -> ?block:block ->
unit -> int tzresult Lwt.t
val operations_hash:
#simple -> ?chain:chain -> ?block:block ->
unit -> Operation_list_list_hash.t tzresult Lwt.t
val fitness:
#simple -> ?chain:chain -> ?block:block ->
unit -> Fitness.t tzresult Lwt.t
val context_hash:
#simple -> ?chain:chain -> ?block:block ->
unit -> Context_hash.t tzresult Lwt.t
end
end
module Metadata : sig
val metadata:
#simple -> ?chain:chain -> ?block:block ->
unit -> block_metadata tzresult Lwt.t
val protocol_data:
#simple -> ?chain:chain -> ?block:block ->
unit -> Proto.block_header_metadata tzresult Lwt.t
val protocol_hash:
#simple -> ?chain:chain -> ?block:block ->
unit -> Protocol_hash.t tzresult Lwt.t
val next_protocol_hash:
#simple -> ?chain:chain -> ?block:block ->
unit -> Protocol_hash.t tzresult Lwt.t
val test_chain_status:
#simple -> ?chain:chain -> ?block:block ->
unit -> Test_chain_status.t tzresult Lwt.t
val max_operations_ttl:
#simple -> ?chain:chain -> ?block:block ->
unit -> int tzresult Lwt.t
val max_operation_data_length:
#simple -> ?chain:chain -> ?block:block ->
unit -> int tzresult Lwt.t
val max_block_header_length:
#simple -> ?chain:chain -> ?block:block ->
unit -> int tzresult Lwt.t
val max_operation_list_length:
#simple -> ?chain:chain -> ?block:block ->
unit -> operation_list_quota list tzresult Lwt.t
end
module Operation : sig
@ -280,13 +224,18 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
prefix, unit, unit,
block_info) RPC_service.t
module Header : sig
val header:
([ `GET ], prefix,
prefix, unit, unit,
block_header) RPC_service.t
val metadata:
([ `GET ], prefix,
prefix, unit, unit,
block_metadata) RPC_service.t
module Header : sig
val shell_header:
([ `GET ], prefix,
prefix, unit, unit,
@ -297,99 +246,6 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
prefix, unit, unit,
Proto.block_header_data) RPC_service.t
module Shell : sig
val level:
([ `GET ], prefix,
prefix, unit, unit,
Int32.t) RPC_service.t
val protocol_level:
([ `GET ], prefix,
prefix, unit, unit,
int) RPC_service.t
val predecessor:
([ `GET ], prefix,
prefix, unit, unit,
Block_hash.t) RPC_service.t
val timestamp:
([ `GET ], prefix,
prefix, unit, unit,
Time.t) RPC_service.t
val validation_passes:
([ `GET ], prefix,
prefix, unit, unit,
int) RPC_service.t
val operations_hash:
([ `GET ], prefix,
prefix, unit, unit,
Operation_list_list_hash.t) RPC_service.t
val fitness:
([ `GET ], prefix,
prefix, unit, unit,
Fitness.t) RPC_service.t
val context_hash:
([ `GET ], prefix,
prefix, unit, unit,
Context_hash.t) RPC_service.t
end
end
module Metadata : sig
val metadata:
([ `GET ], prefix,
prefix, unit, unit,
block_metadata) RPC_service.t
val protocol_data:
([ `GET ], prefix,
prefix, unit, unit,
Proto.block_header_metadata) RPC_service.t
val protocol_hash:
([ `GET ], prefix,
prefix, unit, unit,
Protocol_hash.t) RPC_service.t
val next_protocol_hash:
([ `GET ], prefix,
prefix, unit, unit,
Protocol_hash.t) RPC_service.t
val test_chain_status:
([ `GET ], prefix,
prefix, unit, unit,
Test_chain_status.t) RPC_service.t
val max_operations_ttl:
([ `GET ], prefix,
prefix, unit, unit,
int) RPC_service.t
val max_operation_data_length:
([ `GET ], prefix,
prefix, unit, unit,
int) RPC_service.t
val max_block_header_length:
([ `GET ], prefix,
prefix, unit, unit,
int) RPC_service.t
val operation_list_quota:
([ `GET ], prefix,
prefix, unit, unit,
operation_list_quota list) RPC_service.t
end
module Operation : sig
@ -482,3 +338,12 @@ end
module Fake_protocol : PROTO
module Empty : (module type of Make(Fake_protocol)(Fake_protocol))
type protocols = {
current_protocol: Protocol_hash.t ;
next_protocol: Protocol_hash.t ;
}
val protocols:
#RPC_context.simple -> ?chain:chain -> ?block:block ->
unit -> protocols tzresult Lwt.t

View File

@ -190,6 +190,13 @@ module Blocks = struct
include Block_services.Empty
type protocols = Block_services.protocols = {
current_protocol: Protocol_hash.t ;
next_protocol: Protocol_hash.t ;
}
let protocols = Block_services.protocols
end
module Invalid_blocks = struct

View File

@ -56,6 +56,15 @@ module Blocks : sig
include (module type of Block_services.Empty)
type protocols = {
current_protocol: Protocol_hash.t ;
next_protocol: Protocol_hash.t ;
}
val protocols:
#RPC_context.simple -> ?chain:chain -> ?block:Block_services.block ->
unit -> protocols tzresult Lwt.t
end
module Invalid_blocks : sig

View File

@ -25,11 +25,11 @@ let info cctxt ?(chain = `Main) block =
Shell_services.Chain.chain_id cctxt ~chain () >>=? fun chain_id ->
Shell_services.Blocks.hash cctxt ~chain ~block () >>=? fun hash ->
Shell_services.Blocks.Header.shell_header cctxt ~chain ~block () >>=? fun header ->
Shell_services.Blocks.Metadata.next_protocol_hash
cctxt ~chain ~block () >>=? fun next_protocol ->
Shell_services.Blocks.Metadata.protocol_hash
cctxt ~chain ~block () >>=? fun protocol ->
Alpha_block_services.Metadata.protocol_data cctxt ~chain ~block () >>=? fun { level } ->
Shell_services.Blocks.protocols
cctxt ~chain ~block () >>=? fun { current_protocol = protocol ;
next_protocol } ->
Alpha_block_services.metadata cctxt
~chain ~block () >>=? fun { protocol_data = { level } } ->
let { Tezos_base.Block_header.predecessor ; fitness ; timestamp ; _ } = header in
return { hash ; chain_id ; predecessor ; fitness ;
timestamp ; protocol ; next_protocol ; level }
@ -50,8 +50,8 @@ let monitor_heads cctxt ?next_protocols chain =
let blocks_from_current_cycle cctxt ?(chain = `Main) block ?(offset = 0l) () =
Shell_services.Blocks.hash cctxt ~chain ~block () >>=? fun hash ->
Alpha_block_services.Metadata.protocol_data
cctxt ~chain ~block () >>=? fun { level } ->
Alpha_block_services.metadata
cctxt ~chain ~block () >>=? fun { protocol_data = { level } } ->
Alpha_services.Helpers.levels_in_current_cycle
cctxt ~offset (chain, block) >>=? fun (first, last) ->
let length = Int32.to_int (Raw_level.diff level.level first) in

View File

@ -130,8 +130,8 @@ let forge_endorsement (cctxt : #Proto_alpha.full)
?(chain = `Main) block
~src_sk ?slots src_pk =
let src_pkh = Signature.Public_key.hash src_pk in
Alpha_block_services.Metadata.protocol_data
cctxt ~chain ~block () >>=? fun { level = { level } } ->
Alpha_block_services.metadata cctxt
~chain ~block () >>=? fun { protocol_data = { level = { level } } } ->
begin
match slots with
| Some slots -> return slots

View File

@ -410,8 +410,8 @@ let get_unrevealed_nonces
Client_baking_nonces.find cctxt hash >>=? function
| None -> return None
| Some nonce ->
Alpha_block_services.Metadata.protocol_data
cctxt ~chain ~block:(`Hash (hash, 0)) () >>=? fun { level } ->
Alpha_block_services.metadata
cctxt ~chain ~block:(`Hash (hash, 0)) () >>=? fun { protocol_data = { level } } ->
if force then
return (Some (hash, (level.level, nonce)))
else

View File

@ -147,8 +147,8 @@ let init ?exe ?vote ?rpc_port () =
return (pid, hash)
let level (chain, block) =
Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain ~block () >>=? fun { level } ->
Alpha_block_services.metadata
!rpc_ctxt ~chain ~block () >>=? fun { protocol_data = { level } } ->
return level
let rpc_raw_context block path depth =
@ -336,8 +336,8 @@ module Protocol = struct
open Account
let voting_period_kind ?(block = `Head 0) () =
Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { voting_period_kind } ->
Alpha_block_services.metadata
!rpc_ctxt ~chain:`Main ~block () >>=? fun { protocol_data = { voting_period_kind } } ->
return voting_period_kind
let proposals ?(block = `Head 0) ~src:({ pkh; sk } : Account.t) proposals =
@ -488,17 +488,17 @@ module Assert = struct
end
let check_protocol ?msg ~block h =
Alpha_block_services.Metadata.next_protocol_hash
!rpc_ctxt ~block () >>=? fun block_proto ->
Block_services.protocols
!rpc_ctxt ~block () >>=? fun { next_protocol } ->
return @@ equal
?msg
~prn:Protocol_hash.to_b58check
~eq:Protocol_hash.equal
block_proto h
next_protocol h
let check_voting_period_kind ?msg ~block kind =
Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { voting_period_kind } ->
Alpha_block_services.metadata
!rpc_ctxt ~chain:`Main ~block () >>=? fun { protocol_data = { voting_period_kind } } ->
return @@ equal
?msg
voting_period_kind
@ -550,8 +550,8 @@ module Endorse = struct
src_sk
slot =
Shell_services.Blocks.hash !rpc_ctxt ~block () >>=? fun hash ->
Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { level } ->
Alpha_block_services.metadata
!rpc_ctxt ~chain:`Main ~block () >>=? fun { protocol_data = { level } } ->
let level = level.level in
let shell = { Tezos_base.Operation.branch = hash } in
let contents =
@ -572,8 +572,8 @@ module Endorse = struct
?slot
(contract : Account.t)
block =
Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { level } ->
Alpha_block_services.metadata
!rpc_ctxt ~chain:`Main ~block () >>=? fun { protocol_data = { level } } ->
let level = level.level in
begin
match slot with
@ -601,8 +601,8 @@ module Endorse = struct
| _ -> () in
let { Account.b1 ; b2 ; b3 ; b4 ; b5 } = Account.bootstrap_accounts in
let result = Array.make 32 b1 in
Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { level } ->
Alpha_block_services.metadata
!rpc_ctxt ~chain:`Main ~block () >>=? fun { protocol_data = { level } } ->
let level = level.level in
get_endorser_list result b1 level block >>=? fun () ->
get_endorser_list result b2 level block >>=? fun () ->
@ -613,8 +613,8 @@ module Endorse = struct
let endorsement_rights
(contract : Account.t) block =
Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { level } ->
Alpha_block_services.metadata
!rpc_ctxt ~chain:`Main ~block () >>=? fun { protocol_data = { level } } ->
let level = level.level in
let delegate = contract.pkh in
Alpha_services.Delegate.Endorsing_rights.get
@ -628,8 +628,8 @@ module Endorse = struct
end
let display_level block =
Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { level } ->
Alpha_block_services.metadata
!rpc_ctxt ~chain:`Main ~block () >>=? fun { protocol_data = { level } } ->
Format.eprintf "Level: %a@." Level.pp_full level ;
return ()

View File

@ -56,8 +56,8 @@ let commands () =
(switch ~doc:"output time in seconds" ~short:'s' ~long:"seconds" ()))
(fixed [ "get" ; "timestamp" ])
begin fun seconds (cctxt : Proto_alpha.full) ->
Shell_services.Blocks.Header.Shell.timestamp
cctxt ~block:cctxt#block () >>=? fun v ->
Shell_services.Blocks.Header.shell_header
cctxt ~block:cctxt#block () >>=? fun { timestamp = v } ->
begin
if seconds
then cctxt#message "%Ld" (Time.to_seconds v)