Availability Gateway
- class services.starkex.availability_gateway.availability_gateway.AvailabilityGateway(availability_gateway_config: services.starkex.availability_gateway.availability_gateway_config.AvailabilityGatewayConfig, storage: starkware.storage.storage.Storage, lock_manager: starkware.storage.storage.LockManager, hash_func)
This is the StarkEx Services HTTP gateway for committee interactions.
- async approve_new_roots(request)
Process committee signature for a batch.
- Parameters
data – Committee signature data in message body (
CommitteeSignature
)- Returns
Acknowledgement.
- Return type
str
- Example
http
POST /availability_gateway/approve_new_roots HTTP/1.1 Host: localhost:9414 Accept: application/json {"batch_id": 5678, "signature": "0x1256a4d7d152a0aafa2b75eb06eddbd0abb5621572fd4292", "member_key": "0xb2849CBc25853685bfc4815Ab51d28E810606A48", "claim_hash": "0x476a9f237758279caadaa21ecadd0126fe7ae99eb5c41b7cfdf1f42fd63db577"}
curl
curl -i -X POST https://localhost:9414/availability_gateway/approve_new_roots -H "Accept: application/json" --data-raw '{"batch_id": 5678, "signature": "0x1256a4d7d152a0aafa2b75eb06eddbd0abb5621572fd4292", "member_key": "0xb2849CBc25853685bfc4815Ab51d28E810606A48", "claim_hash": "0x476a9f237758279caadaa21ecadd0126fe7ae99eb5c41b7cfdf1f42fd63db577"}'
wget
wget -S -O- https://localhost:9414/availability_gateway/approve_new_roots --header="Accept: application/json" --post-data='{"batch_id": 5678, "signature": "0x1256a4d7d152a0aafa2b75eb06eddbd0abb5621572fd4292", "member_key": "0xb2849CBc25853685bfc4815Ab51d28E810606A48", "claim_hash": "0x476a9f237758279caadaa21ecadd0126fe7ae99eb5c41b7cfdf1f42fd63db577"}'
httpie
echo '{"batch_id": 5678, "signature": "0x1256a4d7d152a0aafa2b75eb06eddbd0abb5621572fd4292", "member_key": "0xb2849CBc25853685bfc4815Ab51d28E810606A48", "claim_hash": "0x476a9f237758279caadaa21ecadd0126fe7ae99eb5c41b7cfdf1f42fd63db577"}' | http POST https://localhost:9414/availability_gateway/approve_new_roots Accept:application/json
python-requests
requests.post('https://localhost:9414/availability_gateway/approve_new_roots', headers={'Accept': 'application/json'}, data='{"batch_id": 5678, "signature": "0x1256a4d7d152a0aafa2b75eb06eddbd0abb5621572fd4292",\r\n\n "member_key": "0xb2849CBc25853685bfc4815Ab51d28E810606A48",\r\n\n "claim_hash": "0x476a9f237758279caadaa21ecadd0126fe7ae99eb5c41b7cfdf1f42fd63db577"}')
response
HTTP/1.1 200 OK Content-Type: application/str signature accepted
- async get_batch_data(request)
Get the data availability information for a specific batch.
The availability information includes the ID of the previous batch in chronological order and the list of Merkle leaves (vaults and orders) that were modified in the requested batch.
prev_batch_id of -1 indicates that there is no previous state.
Note that prev_batch_id might differ from batch_id - 1. This happens when a previously submitted batch is rejected on-chain.
- Parameters
batch_id (int) – Batch ID to query.
- Returns
Batch information (
StateUpdate
)- Example
http
GET /availability_gateway/get_batch_data?batch_id=5678 HTTP/1.1 Host: localhost:9414 Accept: application/json
curl
curl -i -X GET 'https://localhost:9414/availability_gateway/get_batch_data?batch_id=5678' -H "Accept: application/json"
wget
wget -S -O- 'https://localhost:9414/availability_gateway/get_batch_data?batch_id=5678' --header="Accept: application/json"
httpie
http 'https://localhost:9414/availability_gateway/get_batch_data?batch_id=5678' Accept:application/json
python-requests
requests.get('https://localhost:9414/availability_gateway/get_batch_data?batch_id=5678', headers={'Accept': 'application/json'})
response
HTTP/1.1 200 OK Content-Type: application/json { "update": { "order_root": "288735371032173331189347145308275335038811166444850212885591078739326", "orders": { "54850": { "fulfilled_amount": "845" }, "54851": { "fulfilled_amount": "1975" } }, "prev_batch_id": 5677, "vault_root": "23969317203103658488084840304811879604602091680197177586448255448540369", "vaults": { "168668519": { "balance": "300", "stark_key": "0xc35327b2be68ae537e02f0d16dd81cf6baac5e02ba28d0342ec8e", "token": "0x31e95e8dc9447dfb706f0dfa2d8243c832de7d8da4edd87aa8f3f0008" }, "694774812": { "balance": "1000", "stark_key": "0x7c5a4b3c65e46bc7b7b1e5dce60b5b5c56d9429f27acf53ec45b9", "token": "0x31e95e8dc9447dfb706f0dfa2d8243c832de7d8da4edd87aa8f3f0008" } } } }
- is_mandatory_committee_member(committee_member: str) bool
Returns True iff the committee_member is a mandatory committee member in one of the committees.
- class starkware.starkware_utils.objects.availability.CommitteeSignature(batch_id: int, signature: str, member_key: str, claim_hash: str)
The information describing a committee signature.
- Parameters
batch_id (int) – ID of signed batch.
signature (str) – Committee signature for batch.
member_key (str) – Committee member public key used for identification.
claim_hash (str) – Claim hash being signed used for validating the expected claim.
- class starkware.starkware_utils.objects.starkex_state.StateUpdate(prev_batch_id: int, vaults: Dict[int, starkware.starkware_utils.objects.starkex_state.VaultState], orders: Dict[int, starkware.starkware_utils.objects.starkex_state.OrderState], vault_root: str, order_root: str)
The information describing a state update.
- Parameters
vaults (dict) – Dictionary mapping vault_id to vault state.
orders (dict) – Dictionary mapping order_id to order state.
vault_root (str) – expected vault root after update (hex str without prefix).
order_root (str) – expected order root after update (hex str without prefix).
prev_batch_id (int) – Previous batch ID.
- class starkware.starkware_utils.objects.starkex_state.VaultState(stark_key: int, token: int, balance: int)
Vault state.
- Parameters
stark_key (int) – Public key of the party as registered on the StarkEx contract.
token (int) – Unique token ID as registered on the StarkEx contract.
balance (int) – Vault balance.
- class starkware.starkware_utils.objects.starkex_state.OrderState(fulfilled_amount: int)
Order state.
- Parameters
fulfilled_amount (int) – Order fulfilled amount.