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

merge master into nakamoto #1840

Merged
merged 18 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ PG_APPLICATION_NAME=stacks-blockchain-api
# Limit to how many concurrent connections can be created, defaults to 10
# PG_CONNECTION_POOL_MAX=10

# Insert concurrency when processing new blocks
# If your PostgreSQL is operating on SSD and has multiple CPU cores, consider raising this value, for instance, to 8 or 16.
# STACKS_BLOCK_DATA_INSERT_CONCURRENCY=4

# If specified, controls the Stacks Blockchain API mode. The possible values are:
# * `readonly`: Runs the API endpoints without an Event Server that listens to events from a node and
# writes them to the local database. The API will only read data from the PG database
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
57 changes: 57 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
## [7.8.0](https://github.com/hirosystems/stacks-blockchain-api/compare/v7.7.2...v7.8.0) (2024-01-23)


### Features

* add `/extended/v2/smart-contracts/status` endpoint ([#1833](https://github.com/hirosystems/stacks-blockchain-api/issues/1833)) ([3535c11](https://github.com/hirosystems/stacks-blockchain-api/commit/3535c113e0d3b730b3e0d9df630c51b04e516a7e))
* run inserts in batch and in parallel when processing new block ([#1818](https://github.com/hirosystems/stacks-blockchain-api/issues/1818)) ([86dfdb5](https://github.com/hirosystems/stacks-blockchain-api/commit/86dfdb5d536fee8d7490ca5213f7005a8800f9fa))
* upgrade to node 20, use bookworm-slim image ([#1832](https://github.com/hirosystems/stacks-blockchain-api/issues/1832)) ([0a42109](https://github.com/hirosystems/stacks-blockchain-api/commit/0a42109242ab5804004e01338f236f61ef07651b))


### Bug Fixes

* change all HASH indexes to BTREE to optimize writes ([#1825](https://github.com/hirosystems/stacks-blockchain-api/issues/1825)) ([234936b](https://github.com/hirosystems/stacks-blockchain-api/commit/234936b430640fb7108e6cb57bdb21d1085a65b2))
* log block event counts after processing ([#1820](https://github.com/hirosystems/stacks-blockchain-api/issues/1820)) ([9c39743](https://github.com/hirosystems/stacks-blockchain-api/commit/9c397439e6eb2830186cda90a213b3ab3d5a4301)), closes [#1819](https://github.com/hirosystems/stacks-blockchain-api/issues/1819) [#1819](https://github.com/hirosystems/stacks-blockchain-api/issues/1819)
* optimize re-org queries and indexes ([#1821](https://github.com/hirosystems/stacks-blockchain-api/issues/1821)) ([5505d35](https://github.com/hirosystems/stacks-blockchain-api/commit/5505d354ecae6e52c751b3b634752fd56d24642f))
* parallelize re-org update queries ([#1835](https://github.com/hirosystems/stacks-blockchain-api/issues/1835)) ([340a304](https://github.com/hirosystems/stacks-blockchain-api/commit/340a3043529ca12316198d8f4605128396f02560))

## [7.8.0-beta.4](https://github.com/hirosystems/stacks-blockchain-api/compare/v7.8.0-beta.3...v7.8.0-beta.4) (2024-01-16)


### Features

* upgrade to node 20, use bookworm-slim image ([#1832](https://github.com/hirosystems/stacks-blockchain-api/issues/1832)) ([0a42109](https://github.com/hirosystems/stacks-blockchain-api/commit/0a42109242ab5804004e01338f236f61ef07651b))

## [7.8.0-beta.3](https://github.com/hirosystems/stacks-blockchain-api/compare/v7.8.0-beta.2...v7.8.0-beta.3) (2024-01-12)


### Bug Fixes

* change all HASH indexes to BTREE to optimize writes ([#1825](https://github.com/hirosystems/stacks-blockchain-api/issues/1825)) ([234936b](https://github.com/hirosystems/stacks-blockchain-api/commit/234936b430640fb7108e6cb57bdb21d1085a65b2))

## [7.8.0-beta.2](https://github.com/hirosystems/stacks-blockchain-api/compare/v7.8.0-beta.1...v7.8.0-beta.2) (2024-01-12)


### Bug Fixes

* optimize re-org queries and indexes ([#1821](https://github.com/hirosystems/stacks-blockchain-api/issues/1821)) ([5505d35](https://github.com/hirosystems/stacks-blockchain-api/commit/5505d354ecae6e52c751b3b634752fd56d24642f))

## [7.8.0-beta.1](https://github.com/hirosystems/stacks-blockchain-api/compare/v7.7.1...v7.8.0-beta.1) (2024-01-11)


### Features

* run inserts in batch and in parallel when processing new block ([#1818](https://github.com/hirosystems/stacks-blockchain-api/issues/1818)) ([86dfdb5](https://github.com/hirosystems/stacks-blockchain-api/commit/86dfdb5d536fee8d7490ca5213f7005a8800f9fa))

### Bug Fixes

* log block event counts after processing ([#1820](https://github.com/hirosystems/stacks-blockchain-api/issues/1820)) ([9c39743](https://github.com/hirosystems/stacks-blockchain-api/commit/9c397439e6eb2830186cda90a213b3ab3d5a4301)), closes [#1819](https://github.com/hirosystems/stacks-blockchain-api/issues/1819) [#1819](https://github.com/hirosystems/stacks-blockchain-api/issues/1819)


## [7.7.2](https://github.com/hirosystems/stacks-blockchain-api/compare/v7.7.1...v7.7.2) (2024-01-16)


### Bug Fixes

* revive dropped mempool rebroadcasts ([#1823](https://github.com/hirosystems/stacks-blockchain-api/issues/1823)) ([862b36c](https://github.com/hirosystems/stacks-blockchain-api/commit/862b36c3fa896bcf9b5434ecf33c1bc0c9077aed))

## [7.7.1](https://github.com/hirosystems/stacks-blockchain-api/compare/v7.7.0...v7.7.1) (2024-01-11)


Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM node:18-bullseye
FROM node:20-bookworm-slim

WORKDIR /app
COPY . .
COPY --from=qldrsc/duckdb /usr/local/bin/duckdb /bin/duckdb

RUN apt-get update && \
apt-get install -y git openjdk-11-jre && \
apt-get install -y git openjdk-17-jre && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN echo "GIT_TAG=$(git tag --points-at HEAD)" >> .env
Expand Down
7 changes: 4 additions & 3 deletions docker/rosetta.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ ARG ARCHIVE_VERSION=latest

#######################################################################
## Build the stacks-blockchain-api
FROM node:18-buster as stacks-blockchain-api-build
FROM node:20-bookworm-slim as stacks-blockchain-api-build
ARG STACKS_API_VERSION
ENV STACKS_API_REPO=hirosystems/stacks-blockchain-api
ENV STACKS_API_VERSION=${STACKS_API_VERSION}
ENV DEBIAN_FRONTEND noninteractive
WORKDIR /app
RUN apt-get update -y \
&& apt-get install -y \
git \
curl \
jq \
openjdk-11-jre-headless \
openjdk-17-jre-headless \
cmake \
&& git clone -b ${STACKS_API_VERSION} https://github.com/${STACKS_API_REPO} . \
&& echo "GIT_TAG=$(git tag --points-at HEAD)" >> .env \
Expand Down Expand Up @@ -102,7 +103,7 @@ RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen

RUN curl -sL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" > /etc/apt/sources.list.d/pgsql.list \
&& curl -sL https://deb.nodesource.com/setup_16.x | bash -
&& curl -sL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get update \
&& apt-get install -y \
postgresql-${PG_VERSION} \
Expand Down
2 changes: 1 addition & 1 deletion docker/standalone-regtest.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

FROM node:18-bullseye as api-builder
FROM node:20-bookworm-slim as api-builder

ARG API_GIT_COMMIT
ARG STACKS_API_VERSION
Expand Down
31 changes: 31 additions & 0 deletions docs/api/smart-contracts/get-smart-contracts-status.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.swap-helper-bridged-v1-1": {
"found": true,
"result": {
"contract_id": "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.swap-helper-bridged-v1-1",
"status": "success",
"tx_id": "0x8542d28e427256ea3c29dcd8793222891999ceff4ef1bb062e2f21cb6def6884",
"block_height": 111021
}
},
"SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60.name-registrar": {
"found": true,
"result": {
"contract_id": "SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60.name-registrar",
"status": "success",
"tx_id": "0x6e1114cce8c6f2e9c8130f9acd75d67bb667ae584f882acdd2db6dd74e6cbe5e",
"block_height": 113010
}
},
"SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.stacking-dao-core-v1": {
"found": true,
"result": {
"contract_id": "SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.stacking-dao-core-v1",
"status": "pending",
"tx_id": "0x10bdcf10ffee72994f493ac36760f4e95a76c8471370182fd4705c2153dc173d"
}
},
"SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.stacking-dao-core": {
"found": false
}
}
15 changes: 15 additions & 0 deletions docs/api/smart-contracts/get-smart-contracts-status.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"description": "GET request that returns the deployment status of multiple smart contracts",
"title": "SmartContractsStatusResponse",
"type": "object",
"additionalProperties": {
"anyOf": [
{
"$ref": "./smart-contract-found.schema.json"
},
{
"$ref": "./smart-contract-not-found.schema.json"
}
]
}
}
15 changes: 15 additions & 0 deletions docs/api/smart-contracts/smart-contract-found.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"type": "object",
"title": "SmartContractFound",
"additionalProperties": false,
"required": ["found", "result"],
"properties": {
"found": {
"type": "boolean",
"enum": [true]
},
"result": {
"$ref": "../../entities/smart-contracts/smart-contract-status.schema.json"
}
}
}
12 changes: 12 additions & 0 deletions docs/api/smart-contracts/smart-contract-not-found.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "object",
"title": "SmartContractNotFound",
"additionalProperties": false,
"properties": {
"found": {
"type": "boolean",
"enum": [false]
}
},
"required": ["found"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"contract_id": "SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.swap-helper-bridged-v1-1",
"status": "success",
"tx_id": "0x8542d28e427256ea3c29dcd8793222891999ceff4ef1bb062e2f21cb6def6884",
"block_height": 111021
}
29 changes: 29 additions & 0 deletions docs/entities/smart-contracts/smart-contract-status.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"title": "SmartContractStatus",
"description": "Deployment status of a smart contract",
"type": "object",
"additionalProperties": false,
"required": [
"status",
"tx_id",
"contract_id"
],
"properties": {
"status": {
"type": "string",
"description": "Smart contract deployment transaction status"
},
"tx_id": {
"type": "string",
"description": "Deployment transaction ID"
},
"contract_id": {
"type": "string",
"description": "Smart contract ID"
},
"block_height": {
"type": "integer",
"description": "Height of the transaction confirmation block"
}
}
}
38 changes: 38 additions & 0 deletions docs/generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export type SchemaMergeRootStub =
| SearchSuccessResult
| TxSearchResult
| SearchResult
| SmartContractsStatusResponse
| SmartContractFound
| SmartContractNotFound
| PoolDelegationsResponse
| {
[k: string]: unknown | undefined;
Expand Down Expand Up @@ -177,6 +180,7 @@ export type SchemaMergeRootStub =
| RosettaSyncStatus
| TransactionIdentifier
| RosettaTransaction
| SmartContractStatus
| PoolDelegation
| NonFungibleTokenHistoryEventWithTxId
| NonFungibleTokenHistoryEventWithTxMetadata
Expand Down Expand Up @@ -3059,6 +3063,40 @@ export interface TxSearchResult {
metadata?: Transaction;
};
}
/**
* GET request that returns the deployment status of multiple smart contracts
*/
export interface SmartContractsStatusResponse {
[k: string]: (SmartContractFound | SmartContractNotFound) | undefined;
}
export interface SmartContractFound {
found: true;
result: SmartContractStatus;
}
/**
* Deployment status of a smart contract
*/
export interface SmartContractStatus {
/**
* Smart contract deployment transaction status
*/
status: string;
/**
* Deployment transaction ID
*/
tx_id: string;
/**
* Smart contract ID
*/
contract_id: string;
/**
* Height of the transaction confirmation block
*/
block_height?: number;
}
export interface SmartContractNotFound {
found: false;
}
/**
* GET request that returns stacking pool member details for a given pool (delegator) principal
*/
Expand Down
34 changes: 34 additions & 0 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,36 @@ paths:
example:
$ref: ./api/transaction/get-transactions.example.json

/extended/v2/smart-contracts/status:
get:
summary: Get smart contracts status
description: |
Retrieves the deployment status of multiple smart contracts.
tags:
- Smart Contracts
operationId: get_smart_contracts_status
parameters:
- name: contract_id
in: query
description: contract ids to fetch status for
required: true
style: form
explode: true
schema:
type: array
example: "SPQZF23W7SEYBFG5JQ496NMY0G7379SRYEDREMSV.Candy"
items:
type: string
responses:
200:
description: List of smart contract status
content:
application/json:
schema:
$ref: ./api/smart-contracts/get-smart-contracts-status.schema.json
example:
$ref: ./api/smart-contracts/get-smart-contracts-status.example.json

/extended/v1/block:
get:
summary: Get recent blocks
Expand Down Expand Up @@ -3367,10 +3397,12 @@ paths:
endpoint with an estimation of the final length (in bytes)
of the transaction, including any post-conditions and
signatures
If the node cannot provide an estimate for the transaction
(e.g., if the node has never seen a contract-call for the
given contract and function) or if estimation is not
configured on this node, a 400 response is returned.
The 400 response will be a JSON error containing a `reason`
field which can be one of the following:
* `DatabaseError` - this Stacks node has had an internal
Expand All @@ -3382,6 +3414,7 @@ paths:
* `CostEstimationDisabled` - this Stacks node does not perform
fee or cost estimation, and it cannot respond on this
endpoint.
The 200 response contains the following data:
* `estimated_cost` - the estimated multi-dimensional cost of
executing the Clarity VM on the provided transaction.
Expand Down Expand Up @@ -3410,6 +3443,7 @@ paths:
If the estimated fees are less than the minimum relay
fee `(1 ustx x estimated_len)`, then that minimum relay
fee will be returned here instead.
Note: If the final transaction's byte size is larger than
supplied to `estimated_len`, then applications should increase
this fee amount by:
Expand Down
Loading