stacks-network / stacks-core

The Stacks blockchain implementation
https://docs.stacks.co
GNU General Public License v3.0
3.01k stars 667 forks source link

Reading snapshot state: RPC interface for fetching snapshot state by given a burnchain hash or a burnchain height #3114

Open gzelda opened 2 years ago

gzelda commented 2 years ago

This issue is related to https://github.com/stacks-network/stacks-blockchain/issues/1969 which aims to split mining program from origin stacks-node

Describe the solution you'd like Two endpoints: GET /v2/snapshot/{burnchain_height} GET /v2/snapshot/{hash}

The params includes the following information:

They are all uniqueIndex in snapshot table which can points to a unique row in SQLite query.

If the node cannot provide a valid snapshot state (e.g., if the node haven't reached burnchain_height or there is no burnchain_hash in the database) a 400 response is returned.

The 200 response should contain the following data:

Example response data

{
  "block_height":  666090,
  "burn_header_hash" : "000000000000000000092cb34cb90e88c39fc70f75d786d0f26ebbfc15dd872d",
  "sortition_hash": "e3d7b4e06944adba6a461b2ae50f5b0a7882ff7bbd98e2280ee88df493814439",
  "consensus_hash": "1660396b37a3441508fa954e80f578dc5805e5ed",
  "winner_block_txid": "0a3ee8755e62d83b589adc957286f5f9b09695e2e52c4cea68555be0686da0a4",
}
pavitthrap commented 2 years ago

@jcnelson can I re-assign this issue to @a3slade?

jcnelson commented 2 years ago

Sure, go ahead.