feat: add execution cost data to transactions

* feat: start capturing execution costs in transactions

* chore: update tx schema and fine tune unit tests

* chore: revert automatic vscode changes
This commit is contained in:
Rafael Cárdenas
2021-09-02 13:05:50 -05:00
committed by GitHub
parent 33f11bbcf3
commit d9e1131f83
11 changed files with 468 additions and 5 deletions

View File

@@ -25,7 +25,12 @@
"is_unanchored",
"microblock_hash",
"microblock_sequence",
"microblock_canonical"
"microblock_canonical",
"execution_cost_read_count",
"execution_cost_read_length",
"execution_cost_runtime",
"execution_cost_write_count",
"execution_cost_write_length"
],
"additionalProperties": false,
"properties": {
@@ -105,6 +110,26 @@
"type": "boolean",
"description": "Set to `true` if microblock is anchored in the canonical chain tip, `false` if the transaction was orphaned in a micro-fork."
},
"execution_cost_read_count": {
"type": "integer",
"description": "Execution cost read count."
},
"execution_cost_read_length": {
"type": "integer",
"description": "Execution cost read length."
},
"execution_cost_runtime": {
"type": "integer",
"description": "Execution cost runtime."
},
"execution_cost_write_count": {
"type": "integer",
"description": "Execution cost write count."
},
"execution_cost_write_length": {
"type": "integer",
"description": "Execution cost write length."
},
"events" : {
"type": "array",
"description": "List of transaction events",

20
docs/generated.d.ts vendored
View File

@@ -450,6 +450,26 @@ export type AbstractTransaction = BaseTransaction & {
* Set to `true` if microblock is anchored in the canonical chain tip, `false` if the transaction was orphaned in a micro-fork.
*/
microblock_canonical: boolean;
/**
* Execution cost read count.
*/
execution_cost_read_count: number;
/**
* Execution cost read length.
*/
execution_cost_read_length: number;
/**
* Execution cost runtime.
*/
execution_cost_runtime: number;
/**
* Execution cost write count.
*/
execution_cost_write_count: number;
/**
* Execution cost write length.
*/
execution_cost_write_length: number;
/**
* List of transaction events
*/

View File

@@ -718,6 +718,11 @@ function parseDbAbstractTx(dbTx: DbTx, baseTx: BaseTransaction): AbstractTransac
microblock_canonical: dbTx.microblock_canonical,
event_count: dbTx.event_count,
events: [],
execution_cost_read_count: dbTx.execution_cost_read_count,
execution_cost_read_length: dbTx.execution_cost_read_length,
execution_cost_runtime: dbTx.execution_cost_runtime,
execution_cost_write_count: dbTx.execution_cost_write_count,
execution_cost_write_length: dbTx.execution_cost_write_length,
};
return abstractTx;
}

View File

@@ -183,6 +183,12 @@ export interface DbTx extends BaseTx {
coinbase_payload?: Buffer;
event_count: number;
execution_cost_read_count: number;
execution_cost_read_length: number;
execution_cost_runtime: number;
execution_cost_write_count: number;
execution_cost_write_length: number;
}
export interface DbMempoolTx extends BaseTx {
@@ -976,6 +982,11 @@ export function createDbTxFromCoreMsg(msg: CoreNodeParsedTxMessage): DbTx {
microblock_hash: msg.microblock_hash,
post_conditions: parsedTx.rawPostConditions,
event_count: 0,
execution_cost_read_count: coreTx.execution_cost.read_count,
execution_cost_read_length: coreTx.execution_cost.read_length,
execution_cost_runtime: coreTx.execution_cost.runtime,
execution_cost_write_count: coreTx.execution_cost.write_count,
execution_cost_write_length: coreTx.execution_cost.write_length,
};
extractTransactionPayload(parsedTx, dbTx);
return dbTx;

View File

@@ -249,8 +249,10 @@ const TX_COLUMNS = `
raw_result,
-- event count
event_count
event_count,
-- execution cost
execution_cost_read_count, execution_cost_read_length, execution_cost_runtime, execution_cost_write_count, execution_cost_write_length
`;
const MEMPOOL_TX_COLUMNS = `
@@ -417,6 +419,12 @@ interface TxQueryResult {
// events count
event_count: number;
execution_cost_read_count: number;
execution_cost_read_length: number;
execution_cost_runtime: number;
execution_cost_write_count: number;
execution_cost_write_length: number;
}
interface MempoolTxIdQueryResult {
@@ -2844,8 +2852,9 @@ export class PgDataStore
INSERT INTO txs(
${TX_COLUMNS}
) values(
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19,
$20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19,
$20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37,
$38, $39, $40, $41, $42
)
-- ON CONFLICT ON CONSTRAINT unique_tx_id_index_block_hash
-- DO NOTHING
@@ -2888,6 +2897,11 @@ export class PgDataStore
tx.coinbase_payload,
hexToBuffer(tx.raw_result),
tx.event_count,
tx.execution_cost_read_count,
tx.execution_cost_read_length,
tx.execution_cost_runtime,
tx.execution_cost_write_count,
tx.execution_cost_write_length,
]
);
return result.rowCount;
@@ -3015,6 +3029,11 @@ export class PgDataStore
sender_address: result.sender_address,
origin_hash_mode: result.origin_hash_mode,
event_count: result.event_count,
execution_cost_read_count: result.execution_cost_read_count,
execution_cost_read_length: result.execution_cost_read_length,
execution_cost_runtime: result.execution_cost_runtime,
execution_cost_write_count: result.execution_cost_write_count,
execution_cost_write_length: result.execution_cost_write_length,
};
this.parseTxTypeSpecificQueryResult(result, tx);
return tx;

View File

@@ -166,7 +166,7 @@ export interface CoreNodeTxMessage {
txid: string;
tx_index: number;
contract_abi: ClarityAbi | null;
execution_cost?: CoreNodeExecutionCostMessage;
execution_cost: CoreNodeExecutionCostMessage;
microblock_sequence: number | null;
microblock_hash: string | null;
microblock_parent_hash: string | null;

View File

@@ -89,6 +89,26 @@ export async function up(pgm: MigrationBuilder): Promise<void> {
type: 'integer',
notNull: true,
},
execution_cost_read_count: {
type: 'integer',
notNull: true,
},
execution_cost_read_length: {
type: 'integer',
notNull: true,
},
execution_cost_runtime: {
type: 'integer',
notNull: true,
},
execution_cost_write_count: {
type: 'integer',
notNull: true,
},
execution_cost_write_length: {
type: 'integer',
notNull: true,
},
raw_tx: {
type: 'bytea',

View File

@@ -127,6 +127,11 @@ describe('api tests', () => {
sender_address: testAddr1,
origin_hash_mode: 1,
event_count: 5,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const stxMintEvent1: DbStxEvent = {
event_index: 0,
@@ -1015,6 +1020,11 @@ describe('api tests', () => {
microblock_hash: '',
parent_index_block_hash: '',
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const dataStoreUpdate1: DataStoreBlockUpdateData = {
block: dbBlock1,
@@ -1581,6 +1591,11 @@ describe('api tests', () => {
sender_address: 'sender-addr',
origin_hash_mode: 1,
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, tx);
@@ -1782,6 +1797,11 @@ describe('api tests', () => {
sender_address: addr1,
origin_hash_mode: 1,
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, stxTx1);
@@ -1828,6 +1848,11 @@ describe('api tests', () => {
sender_address: 'none',
origin_hash_mode: 1,
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, stxTx2);
@@ -2039,6 +2064,11 @@ describe('api tests', () => {
sender_address: 'none',
origin_hash_mode: 1,
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, smartContract);
@@ -2200,6 +2230,11 @@ describe('api tests', () => {
sender_address: sender,
origin_hash_mode: 1,
event_count: 0,
execution_cost_read_count: 1,
execution_cost_read_length: 2,
execution_cost_runtime: 3,
execution_cost_write_count: 4,
execution_cost_write_length: 5,
};
const stxEvents: DbStxEvent[] = [];
for (let i = 0; i < stxEventCount; i++) {
@@ -2318,6 +2353,11 @@ describe('api tests', () => {
},
events: [],
event_count: 0,
execution_cost_read_count: 1,
execution_cost_read_length: 2,
execution_cost_runtime: 3,
execution_cost_write_count: 4,
execution_cost_write_length: 5,
},
stx_sent: '1339',
stx_received: '0',
@@ -2394,6 +2434,11 @@ describe('api tests', () => {
},
events: [],
event_count: 0,
execution_cost_read_count: 1,
execution_cost_read_length: 2,
execution_cost_runtime: 3,
execution_cost_write_count: 4,
execution_cost_write_length: 5,
},
stx_sent: '1484',
stx_received: '0',
@@ -2447,6 +2492,11 @@ describe('api tests', () => {
},
events: [],
event_count: 0,
execution_cost_read_count: 1,
execution_cost_read_length: 2,
execution_cost_runtime: 3,
execution_cost_write_count: 4,
execution_cost_write_length: 5,
},
stx_sent: '1334',
stx_received: '0',
@@ -2523,6 +2573,11 @@ describe('api tests', () => {
},
events: [],
event_count: 0,
execution_cost_read_count: 1,
execution_cost_read_length: 2,
execution_cost_runtime: 3,
execution_cost_write_count: 4,
execution_cost_write_length: 5,
},
stx_sent: '0',
stx_received: '105',
@@ -2590,6 +2645,11 @@ describe('api tests', () => {
},
events: [],
event_count: 0,
execution_cost_read_count: 1,
execution_cost_read_length: 2,
execution_cost_runtime: 3,
execution_cost_write_count: 4,
execution_cost_write_length: 5,
},
stx_sent: '0',
stx_received: '105',
@@ -2666,6 +2726,11 @@ describe('api tests', () => {
},
events: [],
event_count: 0,
execution_cost_read_count: 1,
execution_cost_read_length: 2,
execution_cost_runtime: 3,
execution_cost_write_count: 4,
execution_cost_write_length: 5,
},
stx_sent: '0',
stx_received: '15',
@@ -2750,6 +2815,11 @@ describe('api tests', () => {
sender_address: sender,
origin_hash_mode: 1,
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
return tx;
};
@@ -2794,6 +2864,11 @@ describe('api tests', () => {
sender_address: testAddr1,
origin_hash_mode: 1,
event_count: 5,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const createStxEvent = (
sender: string,
@@ -3184,6 +3259,11 @@ describe('api tests', () => {
},
event_count: 0,
events: [],
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
},
{
tx_id: '0x12340003',
@@ -3220,6 +3300,11 @@ describe('api tests', () => {
},
event_count: 0,
events: [],
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
},
{
tx_id: '0x12340002',
@@ -3256,6 +3341,11 @@ describe('api tests', () => {
},
event_count: 0,
events: [],
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
},
],
};
@@ -3305,6 +3395,11 @@ describe('api tests', () => {
origin_hash_mode: 1,
coinbase_payload: Buffer.from('hi'),
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const tx2: DbTx = {
...tx1,
@@ -3440,6 +3535,11 @@ describe('api tests', () => {
sender_address: 'sender-addr',
origin_hash_mode: 1,
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, tx);
@@ -3584,6 +3684,13 @@ describe('api tests', () => {
microblock_hash: null,
microblock_parent_hash: null,
microblock_sequence: null,
execution_cost: {
read_count: 0,
read_length: 0,
runtime: 0,
write_count: 0,
write_length: 0,
},
},
nonce: 0,
raw_tx: Buffer.alloc(0),
@@ -3669,6 +3776,11 @@ describe('api tests', () => {
},
event_count: 0,
events: [],
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
expect(txQuery.result).toEqual(expectedResp);
@@ -3738,6 +3850,13 @@ describe('api tests', () => {
microblock_hash: null,
microblock_parent_hash: null,
microblock_sequence: null,
execution_cost: {
read_count: 0,
read_length: 0,
runtime: 0,
write_count: 0,
write_length: 0,
},
},
nonce: 0,
raw_tx: Buffer.alloc(0),
@@ -3864,6 +3983,11 @@ describe('api tests', () => {
},
event_count: 0,
events: [],
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
expect(txQuery.result).toEqual(expectedResp);
@@ -3910,6 +4034,13 @@ describe('api tests', () => {
microblock_hash: null,
microblock_parent_hash: null,
microblock_sequence: null,
execution_cost: {
read_count: 0,
read_length: 0,
runtime: 0,
write_count: 0,
write_length: 0,
},
},
nonce: 0,
raw_tx: Buffer.alloc(0),
@@ -3970,6 +4101,11 @@ describe('api tests', () => {
},
event_count: 0,
events: [],
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
expect(txQuery.result).toEqual(expectedResp);
@@ -4016,6 +4152,13 @@ describe('api tests', () => {
microblock_hash: null,
microblock_parent_hash: null,
microblock_sequence: null,
execution_cost: {
read_count: 0,
read_length: 0,
runtime: 0,
write_count: 0,
write_length: 0,
},
},
nonce: 0,
raw_tx: Buffer.alloc(0),
@@ -4076,6 +4219,11 @@ describe('api tests', () => {
},
event_count: 0,
events: [],
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
expect(txQuery.result).toEqual(expectedResp);
@@ -4128,6 +4276,11 @@ describe('api tests', () => {
origin_hash_mode: 1,
coinbase_payload: Buffer.from('hi'),
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.update({
@@ -4233,6 +4386,11 @@ describe('api tests', () => {
origin_hash_mode: 1,
coinbase_payload: Buffer.from('hi'),
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.update({
@@ -4306,6 +4464,11 @@ describe('api tests', () => {
sender_address: addr1,
origin_hash_mode: 1,
event_count: 10,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, stxTx);
@@ -4373,6 +4536,11 @@ describe('api tests', () => {
sender_address: addr2,
origin_hash_mode: 1,
event_count: 1,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, stxTx1);
@@ -4465,6 +4633,11 @@ describe('api tests', () => {
sender_address: 'sender-addr',
origin_hash_mode: 1,
event_count: 1,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, tx);
@@ -4530,6 +4703,11 @@ describe('api tests', () => {
},
},
],
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const fetchTx = await supertest(api.server).get(`/extended/v1/tx/${tx.tx_id}`);
@@ -4720,6 +4898,11 @@ describe('api tests', () => {
sender_address: 'sender-addr',
origin_hash_mode: 1,
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, tx);
const result = await supertest(api.server).get(
@@ -4773,6 +4956,11 @@ describe('api tests', () => {
sender_address: 'sender-addr',
origin_hash_mode: 1,
event_count: 0,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, tx);
const result1 = await supertest(api.server).get(`/extended/v1/tx/block/${block.block_hash}`);

View File

@@ -262,6 +262,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const tx2 = {
...tx,
@@ -430,6 +435,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const createFtEvent = (
sender: string,
@@ -567,6 +577,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const createNFtEvents = (
sender: string,
@@ -712,6 +727,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, tx);
const blockTxs = await db.getBlockTxs(block.index_block_hash);
@@ -772,6 +792,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
return tx;
};
@@ -975,6 +1000,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const createStxEvent = (
sender: string,
@@ -1036,6 +1066,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const createFtEvent = (
sender: string,
@@ -1108,6 +1143,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const createNFtEvents = (
sender: string,
@@ -1875,6 +1915,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, tx);
const txQuery = await db.getTx({ txId: tx.tx_id, includeUnanchored: false });
@@ -1925,6 +1970,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await expect(db.updateTx(client, tx)).rejects.toEqual(
new Error('new row for relation "txs" violates check constraint "valid_token_transfer"')
@@ -1981,6 +2031,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await expect(db.updateTx(client, tx)).rejects.toEqual(
new Error('new row for relation "txs" violates check constraint "valid_smart_contract"')
@@ -2036,6 +2091,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await expect(db.updateTx(client, tx)).rejects.toEqual(
new Error('new row for relation "txs" violates check constraint "valid_contract_call"')
@@ -2092,6 +2152,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await expect(db.updateTx(client, tx)).rejects.toEqual(
new Error('new row for relation "txs" violates check constraint "valid_poison_microblock"')
@@ -2147,6 +2212,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await expect(db.updateTx(client, tx)).rejects.toEqual(
new Error('new row for relation "txs" violates check constraint "valid_coinbase"')
@@ -2203,6 +2273,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const updatedRows = await db.updateTx(client, tx);
expect(updatedRows).toBe(1);
@@ -2260,6 +2335,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const tx2: DbTx = {
...tx1,
@@ -2711,6 +2791,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const tx1b: DbTx = {
...tx1,
@@ -2938,6 +3023,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const tx2: DbTx = {
@@ -2968,6 +3058,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const stxLockEvent1: DbStxLockEvent = {
@@ -3152,6 +3247,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const tx2: DbTx = {
@@ -3182,6 +3282,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const stxLockEvent1: DbStxLockEvent = {
@@ -3282,6 +3387,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const contract1: DbSmartContract = {
tx_id: tx3.tx_id,
@@ -3515,6 +3625,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.update({
@@ -3584,6 +3699,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.update({
@@ -3652,6 +3772,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const tx2: DbTx = {
...tx1,
@@ -3945,6 +4070,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, tx);
@@ -3976,6 +4106,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, tx2);
const blockTxs = await db.getTxsFromBlock(block.block_hash, 20, 0);
@@ -4031,6 +4166,11 @@ describe('postgres datastore', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.updateTx(client, tx);
const blockTxs = await db.getTxsFromBlock(block.block_hash, 20, 6);

View File

@@ -235,6 +235,11 @@ describe('microblock tests', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
await db.update({
@@ -292,6 +297,11 @@ describe('microblock tests', () => {
microblock_sequence: mb1.microblock_sequence,
microblock_hash: mb1.microblock_hash,
parent_burn_block_time: mb1.parent_burn_block_time,
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
// These properties aren't known until the next anchor block that accepts this microblock.
index_block_hash: '',

View File

@@ -95,6 +95,11 @@ describe('websocket notifications', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const mempoolTx: DbMempoolTx = {
@@ -247,6 +252,11 @@ describe('websocket notifications', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const mempoolTx: DbMempoolTx = {
@@ -388,6 +398,11 @@ describe('websocket notifications', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const stxEvent: DbStxEvent = {
@@ -516,6 +531,11 @@ describe('websocket notifications', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const stxEvent: DbStxEvent = {
@@ -622,6 +642,11 @@ describe('websocket notifications', () => {
microblock_canonical: true,
microblock_sequence: I32_MAX,
microblock_hash: '',
execution_cost_read_count: 0,
execution_cost_read_length: 0,
execution_cost_runtime: 0,
execution_cost_write_count: 0,
execution_cost_write_length: 0,
};
const mempoolTx: DbMempoolTx = {