-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ingestion for TenureChange and NakamotoCoinbase tx types
- Loading branch information
Showing
23 changed files
with
460 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
docs/entities/mempool-transactions/transaction-7-tenure-change.schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"type": "object", | ||
"title": "MempoolTenureChangeTransaction", | ||
"description": "Describes representation of a Type 7 Stacks transaction: Tenure Change", | ||
"allOf": [ | ||
{ | ||
"$ref": "./abstract-transaction.schema.json" | ||
}, | ||
{ | ||
"$ref": "../transactions/transaction-7-tenure-change-metadata.schema.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
docs/entities/transactions/transaction-7-tenure-change-metadata.schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"type": "object", | ||
"title": "TenureChangeTransactionMetadata", | ||
"description": "Describes representation of a Type 7 Stacks transaction: Tenure Change", | ||
"required": ["tx_type"], | ||
"additionalProperties": false, | ||
"properties": { | ||
"tx_type": { | ||
"type": "string", | ||
"enum": ["tenure_change"] | ||
}, | ||
"tenure_change_payload": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"required": ["previous_tenure_end", "previous_tenure_blocks", "cause", "pubkey_hash", "signature", "signers"], | ||
"properties": { | ||
"previous_tenure_end": { | ||
"type": "string", | ||
"description": "(Hex string) Stacks Block hash" | ||
}, | ||
"previous_tenure_blocks": { | ||
"type": "number", | ||
"description": "The number of blocks produced in the previous tenure." | ||
}, | ||
"cause": { | ||
"type": "string", | ||
"enum": ["block_found", "no_block_found", "null_miner"], | ||
"description": "Cause of change in mining tenure. Depending on cause, tenure can be ended or extended." | ||
}, | ||
"pubkey_hash": { | ||
"type": "string", | ||
"description": "(Hex string) The ECDSA public key hash of the current tenure." | ||
}, | ||
"signature": { | ||
"type": "string", | ||
"description": "(Hex string) A Schnorr signature from the Stackers." | ||
}, | ||
"signers": { | ||
"type": "string", | ||
"description": "(Hex string) A bitmap of which Stackers signed." | ||
} | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
docs/entities/transactions/transaction-7-tenure-change.example.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"tx_id": "0x5e9f3933e358df6a73fec0d47ce3e1062c20812c129f5294e6f37a8d27c051d9", | ||
"tx_status": "success", | ||
"tx_type": "coinbase", | ||
"fee_rate": "0", | ||
"sender_address": "ST3WCQ6S0DFT7YHF53M8JPKGDS1N1GSSR91677XF1", | ||
"sponsored": false, | ||
"post_condition_mode": "deny", | ||
"is_unanchored": false, | ||
"microblock_hash": "", | ||
"microblock_sequence": 2147483647, | ||
"microblock_canonical": true, | ||
"block_hash": "0x58412b50266debd0c35b1a20348ad9c0f17e5525fb155a97033256c83c9e2491", | ||
"block_height": 3231, | ||
"burn_block_time": 1594230455, | ||
"canonical": true, | ||
"tx_index": 0, | ||
"tx_result": { | ||
"hex": "0x03", | ||
"repr": "true" | ||
}, | ||
"coinbase_payload": { | ||
"data": "0x0000000000000000000000000000000000000000000000000000000000000000" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
docs/entities/transactions/transaction-7-tenure-change.schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"type": "object", | ||
"title": "TenureChangeTransaction", | ||
"description": "Describes representation of a Type 7 Stacks transaction: Tenure Change", | ||
"allOf": [ | ||
{ | ||
"$ref": "./abstract-transaction.schema.json" | ||
}, | ||
{ | ||
"$ref": "./transaction-7-tenure-change-metadata.schema.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** @param { import("node-pg-migrate").MigrationBuilder } pgm */ | ||
exports.up = pgm => { | ||
pgm.addColumns('txs', { | ||
// `nakamoto-coinbase` tx types | ||
coinbase_vrf_proof: 'bytea', | ||
|
||
// `tenure-change` tx types | ||
tenure_change_previous_tenure_end: 'bytea', | ||
tenure_change_previous_tenure_blocks: 'integer', | ||
tenure_change_cause: 'smallint', | ||
tenure_change_pubkey_hash: 'bytea', | ||
tenure_change_signature: 'bytea', | ||
tenure_change_signers: 'bytea', | ||
}); | ||
|
||
pgm.addColumns('mempool_txs', { | ||
// `nakamoto-coinbase` tx types | ||
coinbase_vrf_proof: 'bytea', | ||
|
||
// `tenure-change` tx types | ||
tenure_change_previous_tenure_end: 'bytea', | ||
tenure_change_previous_tenure_blocks: 'integer', | ||
tenure_change_cause: 'smallint', | ||
tenure_change_pubkey_hash: 'bytea', | ||
tenure_change_signature: 'bytea', | ||
tenure_change_signers: 'bytea', | ||
}); | ||
|
||
pgm.addConstraint('txs', 'valid_tenure-change', `CHECK (type_id != 7 OR ( | ||
NOT (tenure_change_previous_tenure_end, tenure_change_previous_tenure_blocks, tenure_change_cause, tenure_change_pubkey_hash, tenure_change_signature, tenure_change_signers) IS NULL | ||
))`); | ||
|
||
pgm.addConstraint('txs', 'valid_nakamoto-coinbase', `CHECK (type_id != 8 OR ( | ||
NOT (coinbase_payload, coinbase_vrf_proof) IS NULL | ||
))`); | ||
|
||
pgm.addConstraint('mempool_txs', 'valid_tenure-change', `CHECK (type_id != 7 OR ( | ||
NOT (tenure_change_previous_tenure_end, tenure_change_previous_tenure_blocks, tenure_change_cause, tenure_change_pubkey_hash, tenure_change_signature, tenure_change_signers) IS NULL | ||
))`); | ||
|
||
pgm.addConstraint('mempool_txs', 'valid_nakamoto-coinbase', `CHECK (type_id != 8 OR ( | ||
NOT (coinbase_payload, coinbase_vrf_proof) IS NULL | ||
))`); | ||
}; |
Oops, something went wrong.