Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whitepapers/ccq: add eth_call_by_timestamp #3434

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion whitepapers/0013_ccq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading