Skip to content

Commit 7c45f53

Browse files
authored
feat: ingestion for TenureChange and NakamotoCoinbase tx types (#1753)
* feat: ingestion for TenureChange and NakamotoCoinbase tx types * fix: add new tx fields to batch tx insert query * chore: bump stacks-encoding-native-js * test: fix flaky socket-io timeout test
1 parent f33d4da commit 7c45f53

24 files changed

+468
-12
lines changed

.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@
4848
},
4949
"killBehavior": "polite",
5050
},
51+
{
52+
"type": "node",
53+
"request": "launch",
54+
"name": "Launch: w/ postgres",
55+
"skipFiles": [
56+
"<node_internals>/**"
57+
],
58+
"runtimeArgs": ["-r", "ts-node/register/transpile-only", "-r", "tsconfig-paths/register"],
59+
"args": ["${workspaceFolder}/src/index.ts"],
60+
"outputCapture": "std",
61+
"internalConsoleOptions": "openOnSessionStart",
62+
"preLaunchTask": "deploy:pg",
63+
"postDebugTask": "stop:pg",
64+
"env": {
65+
"STACKS_CHAIN_ID": "0x80000000",
66+
"NODE_ENV": "development",
67+
"TS_NODE_SKIP_IGNORE": "true"
68+
},
69+
"killBehavior": "polite",
70+
},
5171
{
5272
"type": "node",
5373
"request": "launch",

.vscode/tasks.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,29 @@
4444
},
4545
"presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "dedicated", "clear": false }
4646
},
47+
{
48+
"label": "deploy:pg",
49+
"type": "shell",
50+
"command": "docker compose -f docker/docker-compose.dev.postgres.yml up --force-recreate -V",
51+
"isBackground": true,
52+
"problemMatcher": [{
53+
"pattern": [{ "regexp": ".", "file": 1, "location": 2, "message": 3 }],
54+
"background": { "activeOnStart": true, "beginsPattern": ".", "endsPattern": "." }
55+
}],
56+
"presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "dedicated", "clear": false }
57+
},
58+
{
59+
"label": "stop:pg",
60+
"type": "shell",
61+
"command": "docker compose -f docker/docker-compose.dev.postgres.yml down -v -t 0",
62+
"presentation": {
63+
"echo": true,
64+
"reveal": "silent",
65+
"focus": false,
66+
"panel": "shared",
67+
"clear": false
68+
}
69+
},
4770
{
4871
"label": "deploy:subnets",
4972
"type": "shell",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"type": "object",
3+
"title": "MempoolTenureChangeTransaction",
4+
"description": "Describes representation of a Type 7 Stacks transaction: Tenure Change",
5+
"allOf": [
6+
{
7+
"$ref": "./abstract-transaction.schema.json"
8+
},
9+
{
10+
"$ref": "../transactions/transaction-7-tenure-change-metadata.schema.json"
11+
}
12+
]
13+
}

docs/entities/mempool-transactions/transaction.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
},
1818
{
1919
"$ref": "./transaction-4-coinbase.schema.json"
20+
},
21+
{
22+
"$ref": "./transaction-7-tenure-change.schema.json"
2023
}
2124
]
2225
}

docs/entities/transactions/transaction-4-coinbase-metadata.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"type": "string",
2323
"nullable": true,
2424
"description": "A principal that will receive the miner rewards for this coinbase transaction. Can be either a standard principal or contract principal. Only specified for `coinbase-to-alt-recipient` transaction types, otherwise null."
25+
},
26+
"vrf_proof": {
27+
"type": "string",
28+
"nullable": true,
29+
"description": "Hex encoded 80-byte VRF proof"
2530
}
2631
}
2732
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"type": "object",
3+
"title": "TenureChangeTransactionMetadata",
4+
"description": "Describes representation of a Type 7 Stacks transaction: Tenure Change",
5+
"required": ["tx_type"],
6+
"additionalProperties": false,
7+
"properties": {
8+
"tx_type": {
9+
"type": "string",
10+
"enum": ["tenure_change"]
11+
},
12+
"tenure_change_payload": {
13+
"type": "object",
14+
"additionalProperties": false,
15+
"required": ["previous_tenure_end", "previous_tenure_blocks", "cause", "pubkey_hash", "signature", "signers"],
16+
"properties": {
17+
"previous_tenure_end": {
18+
"type": "string",
19+
"description": "(Hex string) Stacks Block hash"
20+
},
21+
"previous_tenure_blocks": {
22+
"type": "number",
23+
"description": "The number of blocks produced in the previous tenure."
24+
},
25+
"cause": {
26+
"type": "string",
27+
"enum": ["block_found", "no_block_found", "null_miner"],
28+
"description": "Cause of change in mining tenure. Depending on cause, tenure can be ended or extended."
29+
},
30+
"pubkey_hash": {
31+
"type": "string",
32+
"description": "(Hex string) The ECDSA public key hash of the current tenure."
33+
},
34+
"signature": {
35+
"type": "string",
36+
"description": "(Hex string) A Schnorr signature from the Stackers."
37+
},
38+
"signers": {
39+
"type": "string",
40+
"description": "(Hex string) A bitmap of which Stackers signed."
41+
}
42+
}
43+
}
44+
}
45+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"tx_id": "0x5e9f3933e358df6a73fec0d47ce3e1062c20812c129f5294e6f37a8d27c051d9",
3+
"tx_status": "success",
4+
"tx_type": "coinbase",
5+
"fee_rate": "0",
6+
"sender_address": "ST3WCQ6S0DFT7YHF53M8JPKGDS1N1GSSR91677XF1",
7+
"sponsored": false,
8+
"post_condition_mode": "deny",
9+
"is_unanchored": false,
10+
"microblock_hash": "",
11+
"microblock_sequence": 2147483647,
12+
"microblock_canonical": true,
13+
"block_hash": "0x58412b50266debd0c35b1a20348ad9c0f17e5525fb155a97033256c83c9e2491",
14+
"block_height": 3231,
15+
"burn_block_time": 1594230455,
16+
"canonical": true,
17+
"tx_index": 0,
18+
"tx_result": {
19+
"hex": "0x03",
20+
"repr": "true"
21+
},
22+
"coinbase_payload": {
23+
"data": "0x0000000000000000000000000000000000000000000000000000000000000000"
24+
}
25+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"type": "object",
3+
"title": "TenureChangeTransaction",
4+
"description": "Describes representation of a Type 7 Stacks transaction: Tenure Change",
5+
"allOf": [
6+
{
7+
"$ref": "./abstract-transaction.schema.json"
8+
},
9+
{
10+
"$ref": "./transaction-7-tenure-change-metadata.schema.json"
11+
}
12+
]
13+
}

docs/entities/transactions/transaction-metadata.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
},
1717
{
1818
"$ref": "./transaction-4-coinbase-metadata.schema.json"
19+
},
20+
{
21+
"$ref": "./transaction-7-tenure-change-metadata.schema.json"
1922
}
2023
]
2124
}

docs/entities/transactions/transaction-type.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"title": "TransactionType",
33
"description": "String literal of all Stacks 2.0 transaction types",
44
"type": "string",
5-
"enum": ["token_transfer", "smart_contract", "contract_call", "poison_microblock", "coinbase"]
5+
"enum": ["token_transfer", "smart_contract", "contract_call", "poison_microblock", "coinbase", "tenure_change"]
66
}

0 commit comments

Comments
 (0)