Merge branch 'develop' into feat/appchain-network-improvements

This commit is contained in:
Jude Nelson
2021-12-06 16:47:04 -05:00
129 changed files with 15502 additions and 1551 deletions

View File

@@ -87,7 +87,21 @@ Example:
"from_stacks_block_hash": "0xf5d4ce0efe1d42c963d615ce57f0d014f263a985175e4ece766eceff10e0a358",
"from_index_block_hash": "0x329efcbcc6daf5ac3f264522e0df50eddb5be85df6ee8a9fc2384c54274d7afc",
}
]
],
"anchored_cost": {
"runtime": 100,
"read_count": 10,
"write_count": 5,
"read_length": 150,
"write_length": 75
},
"confirmed_microblocks_cost": {
"runtime": 100,
"read_count": 10,
"write_count": 5,
"read_length": 150,
"write_length": 75
}
}
```
@@ -216,3 +230,37 @@ Reason can be one of:
* `ReplaceAcrossFork` - replaced by a transaction with the same nonce but in the canonical fork
* `TooExpensive` - the transaction is too expensive to include in a block
* `StaleGarbageCollect` - transaction was dropped because it became stale
### `POST /mined_block`
This payload includes data related to block mined by this Stacks node. This
will never be invoked if the node is configured only as a follower. This is invoked
when the miner **assembles** the block; this block may or may not win the sortition.
This endpoint will only broadcast events to observers that explicitly register for
`MinedBlocks` events, `AnyEvent` observers will not receive the events by default.
Example:
```json
{
"block_hash": "0x4eaabcd105865e471f697eff5dd5bd85d47ecb5a26a3379d74fae0ae87c40904",
"staks_height": 3,
"target_burn_height": 745000,
"block_size": 145000,
"anchored_cost": {
"runtime": 100,
"read_count": 10,
"write_count": 5,
"read_length": 150,
"write_length": 75
},
"confirmed_microblocks_cost": {
"runtime": 100,
"read_count": 10,
"write_count": 5,
"read_length": 150,
"write_length": 75
}
}
```

View File

@@ -28,6 +28,9 @@ Possible values for the "reason" field and "reason_data" field are:
* `Deserialization`
* The `reason_data` field will be an object containing a `message`
string detailing the deserialization error
* `EstimatorError`
* The `reason_data` field will be an object containing a `message`
string detailing the error
* `SignatureValidation`
* The `reason_data` field will be an object containing a `message`
string detailing the signature validation error

View File

@@ -0,0 +1,25 @@
{
"cost_scalar_change_by_byte": 0.00476837158203125,
"estimated_cost": {
"read_count": 19,
"read_length": 4814,
"runtime": 7175000,
"write_count": 2,
"write_length": 1020
},
"estimated_cost_scalar": 14,
"estimations": [
{
"fee": 17,
"fee_rate": 1.2410714285714286
},
{
"fee": 125,
"fee_rate": 8.958333333333332
},
{
"fee": 140,
"fee_rate": 10
}
]
}

View File

@@ -0,0 +1,42 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST response for estimated fee",
"title": "TransactionFeeEstimateResponse",
"type": "object",
"additionalProperties": false,
"required": ["estimated_cost", "estimated_cost_scalar", "estimated_fee_rates", "estimated_fees"],
"properties": {
"estimated_cost_scalar": {
"type": "integer"
},
"cost_scalar_change_by_byte": {
"type": "number"
},
"estimated_cost": {
"type": "object",
"additionalProperties": false,
"required": ["read_count", "write_count", "read_length", "write_length", "runtime"],
"properties": {
"read_count": { "type": "integer" },
"read_length": { "type": "integer" },
"runtime": { "type": "integer" },
"write_count": { "type": "integer" },
"write_length": { "type": "integer" }
}
},
"estimations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fee_rate": {
"type": "number"
},
"fee": {
"type": "number"
}
}
}
}
}
}

View File

@@ -0,0 +1,4 @@
{
"estimated_len": 350,
"transaction_payload": "021af942874ce525e87f21bbe8c121b12fac831d02f4086765742d696e666f0b7570646174652d696e666f00000000"
}

View File

@@ -0,0 +1,16 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST request for estimated fee",
"title": "TransactionFeeEstimateRequest",
"type": "object",
"additionalProperties": false,
"required": ["transaction_payload"],
"properties": {
"transaction_payload": {
"type": "string"
},
"estimated_len": {
"type": "integer"
}
}
}

View File

@@ -276,6 +276,96 @@ paths:
example:
$ref: ./api/core-node/get-account-data.example.json
/v2/fees/transaction:
post:
summary: Get approximate fees for the given transaction
tags:
- Fees
description: |
Get an estimated fee for the supplied transaction. This
estimates the execution cost of the transaction, the current
fee rate of the network, and returns estimates for fee
amounts.
* `transaction_payload` is a hex-encoded serialization of
the TransactionPayload for the transaction.
* `estimated_len` is an optional argument that provides the
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
database error while trying to estimate the costs of the
supplied transaction.
* `NoEstimateAvailable` - this Stacks node has not seen this
kind of contract-call before, and it cannot provide an
estimate yet.
* `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.
* `estimated_cost_scalar` - a unitless integer that the Stacks
node uses to compare how much of the block limit is consumed
by different transactions. This value incorporates the
estimated length of the transaction and the estimated
execution cost of the transaction. The range of this integer
may vary between different Stacks nodes. In order to compute
an estimate of total fee amount for the transaction, this
value is multiplied by the same Stacks node's estimated fee
rate.
* `cost_scalar_change_by_byte` - a float value that indicates how
much the `estimated_cost_scalar` value would increase for every
additional byte in the final transaction.
* `estimations` - an array of estimated fee rates and total fees to
pay in microSTX for the transaction. This array provides a range of
estimates (default: 3) that may be used. Each element of the array
contains the following fields:
* `fee_rate` - the estimated value for the current fee
rates in the network
* `fee` - the estimated value for the total fee in
microSTX that the given transaction should pay. These
values are the result of computing:
`fee_rate` x `estimated_cost_scalar`.
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:
`fee_rate` x `cost_scalar_change_by_byte` x (`final_size` - `estimated_size`)
operationId: post_fee_transaction
requestBody:
content:
application/json:
schema:
$ref: ./api/core-node/post-fee-transaction.schema.json
example:
$ref: ./api/core-node/post-fee-transaction.example.json
responses:
200:
description: Estimated fees for the transaction
content:
application/json:
schema:
$ref: ./api/core-node/post-fee-transaction-response.schema.json
example:
$ref: ./api/core-node/post-fee-transaction-response.example.json
/v2/fees/transfer:
get:
summary: Get estimated fee
@@ -378,4 +468,4 @@ paths:
in: query
schema:
type: string
description: The Stacks chain tip to query from
description: The Stacks chain tip to query from