Skip to content

Commit 67560d8

Browse files
committed
fix: update block_rejection_signer_addrs table's primary key
Previously, this table was keyed on the `signer_addr` only, but now we want to key on the signer address and the sighash of the block.
1 parent adca9d4 commit 67560d8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

stacks-signer/src/signerdb.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,28 @@ static CREATE_BLOCK_SIGNATURES_INDEX: &str = r#"
671671
CREATE INDEX IF NOT EXISTS idx_block_signatures_by_sighash ON block_signatures(signer_signature_hash);
672672
"#;
673673

674+
static DROP_BLOCK_REJECTION_SIGNER_ADDRS: &str = r#"
675+
DROP TABLE IF EXISTS block_rejection_signer_addrs;
676+
"#;
677+
678+
static CREATE_BLOCK_REJECTION_SIGNER_ADDRS_V17: &str = r#"
679+
CREATE TABLE IF NOT EXISTS block_rejection_signer_addrs (
680+
-- The block sighash commits to all of the stacks and burnchain state as of its parent,
681+
-- as well as the tenure itself so there's no need to include the reward cycle. Just
682+
-- the sighash is sufficient to uniquely identify the block across all burnchain, PoX,
683+
-- and stacks forks.
684+
signer_signature_hash TEXT NOT NULL,
685+
-- the signer address that rejected the block
686+
signer_addr TEXT NOT NULL,
687+
-- the reject reason code
688+
reject_code INTEGER NOT NULL,
689+
PRIMARY KEY (signer_addr, signer_signature_hash)
690+
) STRICT;"#;
691+
692+
static CREATE_BLOCK_REJECTION_SIGNER_ADDRS_INDEX: &str = r#"
693+
CREATE INDEX IF NOT EXISTS idx_block_rejection_signer_addrs_by_sighash ON block_rejection_signer_addrs(signer_signature_hash);
694+
"#;
695+
674696
static SCHEMA_1: &[&str] = &[
675697
DROP_SCHEMA_0,
676698
CREATE_DB_CONFIG,
@@ -785,6 +807,9 @@ static SCHEMA_17: &[&str] = &[
785807
DROP_BLOCK_SIGNATURES_TABLE,
786808
CREATE_BLOCK_SIGNATURES_TABLE_V17,
787809
CREATE_BLOCK_SIGNATURES_INDEX,
810+
DROP_BLOCK_REJECTION_SIGNER_ADDRS,
811+
CREATE_BLOCK_REJECTION_SIGNER_ADDRS_V17,
812+
CREATE_BLOCK_REJECTION_SIGNER_ADDRS_INDEX,
788813
"INSERT INTO db_config (version) VALUES (17);",
789814
];
790815

0 commit comments

Comments
 (0)