diff --git a/whitepapers/0013_ccq.md b/whitepapers/0013_ccq.md index 37437db007..c18c721008 100644 --- a/whitepapers/0013_ccq.md +++ b/whitepapers/0013_ccq.md @@ -217,7 +217,7 @@ uint32 query_len []byte query_data ``` -Currently the only supported query type is `eth_call`. This can be expanded to support other protocols. +Currently the only supported query types are `eth_call` and `eth_call_by_timestamp`. This can be expanded to support other protocols. 1. eth_call (query type 1) @@ -236,6 +236,30 @@ Currently the only supported query type is `eth_call`. This can be expanded to s []byte call_data ``` +1. eth_call_by_timestamp (query type 2) + + This query type is identical to `eth_call` but targets a timestamp instead of a specific block_id. This can be useful when forming requests based on uncorrelated data, such as requiring data from another chain based on the block timestamp of a given chain. + + The request MUST include the target timestamp. The request MAY include block hints for the target block and following block. These fields are reserved for the possibility that guardians can optionally perform the timestamp -> block lookup. The resulting block numbers MUST be `1` different and their timestamps MUST be such that the target block is _before_ the target time (inclusive) and the following block is _after_ (exclusive). In other words, + + ``` + target_block.timestamp <= target_time < following_block.timestamp + and + following_block_num - 1 == target_block_num + ``` + + The guardian code MUST enforce the above condition before signing the result. + + ```go + u64 target_time_us + u32 target_block_id_hint_len + []byte target_block_id_hint + u32 following_block_id_hint_len + []byte following_block_id_hint + u8 num_batch_call_data + []byte batch_call_data + ``` + ## Query Response - Off-Chain @@ -280,6 +304,24 @@ Currently the only supported query type is `eth_call`. This can be expanded to s []byte result ``` + 1. eth_call_by_timestamp (query type 2) Response Body + + ```go + u64 target_block_number + [32]byte target_block_hash + u64 target_block_time_us + u64 following_block_number + [32]byte following_block_hash + u64 following_block_time_us + u8 num_results + []byte results + ``` + + ```go + u32 result_len + []byte result + ``` + ## REST Service ### Request