Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 122 additions & 45 deletions common/database/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ func (m *Migration) Init() error {
"recipient_account_address" VARCHAR(255),
PRIMARY KEY("id")
);`,
`CREATE INDEX "idx_sender_mempool"
ON "mempool" ("sender_account_address");`,
`
ALTER TABLE "mempool"
ADD COLUMN "block_height" INTEGER AFTER "id";
`,
`
CREATE TABLE IF NOT EXISTS "transaction" (
"id" INTEGER,
Expand All @@ -67,6 +73,17 @@ func (m *Migration) Init() error {
PRIMARY KEY("id")
);`,
`
ALTER TABLE "transaction"
ADD COLUMN "transaction_index" INTEGER AFTER "version";
`,

`CREATE INDEX "idx_id_transaction"
ON "transaction" ("id");`,
`CREATE INDEX "idx_blockid_transaction"
ON "transaction" ("block_id");`,
`CREATE INDEX "idx_blockheight_transaction"
ON "transaction" ("block_height");`,
`
CREATE TABLE IF NOT EXISTS "account_balance" (
"account_address" VARCHAR(255),
"block_height" INTEGER,
Expand All @@ -76,6 +93,8 @@ func (m *Migration) Init() error {
"latest" INTEGER,
PRIMARY KEY("account_address","block_height")
);`,
`CREATE INDEX "idx_blockheight_account_balance"
ON "account_balance" ("block_height");`,
`
CREATE TABLE IF NOT EXISTS "main_block" (
"id" INTEGER,
Expand All @@ -94,6 +113,12 @@ func (m *Migration) Init() error {
"payload_hash" BLOB,
UNIQUE("height")
);`,
`CREATE INDEX "idx_height_main_block"
ON "main_block" ("height");`,
`
AlTER TABLE "main_block"
ADD COLUMN "block_hash" BLOB AFTER "id";
`,
`
CREATE TABLE IF NOT EXISTS "node_registry" (
"id" INTEGER,
Expand All @@ -105,8 +130,15 @@ func (m *Migration) Init() error {
"queued" INTEGER,
"latest" INTEGER,
"height" INTEGER,
PRIMARY KEY("id", "height")
PRIMARY KEY("id")
);`,
`CREATE INDEX "idx_height_node_registry"
ON "node_registry" ("height");`,
`CREATE INDEX "idx_nodeaddr_node_registry"
ON "node_registry" ("node_address");`,
`
ALTER TABLE "node_registry"
RENAME COLUMN "queued" TO "registration_status";`,
`
CREATE TABLE IF NOT EXISTS "account_dataset"(
"setter_account_address" VARCHAR(255),
Expand All @@ -119,18 +151,22 @@ func (m *Migration) Init() error {
"latest" INTEGER,
PRIMARY KEY("setter_account_address","recipient_account_address", "property", "height")
);`,
`
ALTER TABLE "transaction"
ADD COLUMN "transaction_index" INTEGER AFTER "version"
`,
`CREATE INDEX "idx_recipient_account_dataset"
ON "account_dataset" ("recipient_account_address");`,
`CREATE INDEX "idx_property_account_dataset"
ON "account_dataset" ("property");`,
`CREATE INDEX "idx_height_account_dataset"
ON "account_dataset" ("height");`,
`
CREATE TABLE IF NOT EXISTS "participation_score"(
"node_id" INTEGER,
"score" INTEGER,
"latest" INTEGER,
"height" INTEGER,
PRIMARY KEY("node_id", "height")
PRIMARY KEY("node_id","height")
);`,
`CREATE INDEX "idx_height_participation_score"
ON "participation_score" ("height");`,
`
CREATE TABLE IF NOT EXISTS "node_receipt" (
"sender_public_key" BLOB,
Expand All @@ -142,9 +178,14 @@ func (m *Migration) Init() error {
"rmr_linked" BLOB,
"recipient_signature" BLOB,
"rmr" BLOB,
"rmr_index" INTEGER
)
"rmr_index" INTEGER,
PRIMARY KEY ("sender_public_key")
);
`,
`CREATE INDEX "idx_height_node_receipt"
ON "node_receipt" ("sender_public_key");`,
`CREATE INDEX "idx_rmr_node_receipt"
ON "node_receipt" ("rmr_index");`,
`
CREATE TABLE IF NOT EXISTS "batch_receipt" (
"sender_public_key" BLOB,
Expand All @@ -154,16 +195,28 @@ func (m *Migration) Init() error {
"reference_block_height" INTEGER,
"reference_block_hash" BLOB,
"rmr_linked" BLOB,
"recipient_signature" BLOB
"recipient_signature" BLOB,
PRIMARY KEY ("sender_public_key")
)
`,
`CREATE INDEX "idx_sender_batch_receipt"
ON "batch_receipt" ("sender_public_key");`,
`
CREATE TABLE IF NOT EXISTS "merkle_tree" (
"id" BLOB,
"tree" BLOB
)
"tree" BLOB,
PRIMARY KEY("id")
);
`,
`CREATE INDEX "idx_merkle"
ON "merkle_tree" ("id");`,
`
ALTER TABLE "merkle_tree"
ADD COLUMN "block_height" INTEGER AFTER "id";`,
`
ALTER TABLE "merkle_tree"
ADD COLUMN "timestamp" INTEGER AFTER "tree";`,
`,
CREATE TABLE IF NOT EXISTS "published_receipt" (
"sender_public_key" BLOB,
"recipient_public_key" BLOB,
Expand All @@ -177,38 +230,22 @@ func (m *Migration) Init() error {
"block_height" INTEGER,
"receipt_index" INTEGER,
"published_index" INTEGER
)
`,
`
ALTER TABLE "merkle_tree"
ADD COLUMN "timestamp" INTEGER AFTER "tree"
`,
`
ALTER TABLE "node_registry"
RENAME COLUMN "queued" TO "registration_status"
`,
`
AlTER TABLE "main_block"
ADD COLUMN "block_hash" BLOB AFTER "id"
`,

);`,
`CREATE INDEX "idx_pubindex_published_receipt"
ON "published_receipt" ("published_index");`,
`CREATE INDEX "idx_sender_published_receipt"
ON "published_receipt" ("sender_public_key");`,
`
CREATE TABLE IF NOT EXISTS "skipped_blocksmith" (
"blocksmith_public_key" BLOB,
"pop_change" INTEGER,
"block_height" INTEGER,
"blocksmith_index" INTEGER
)
`,
`
ALTER TABLE "mempool"
ADD COLUMN "block_height" INTEGER AFTER "id"
`,
`
ALTER TABLE "merkle_tree"
ADD COLUMN "block_height" INTEGER AFTER "id"
`,
`
CREATE TABLE IF NOT EXISTS "spine_block" (
);`,
`CREATE INDEX "idx_pubkey_skipped_blocksmith"
ON "skipped_blocksmith" ("blocksmith_public_key");`,
`CREATE TABLE IF NOT EXISTS "spine_block" (
"id" INTEGER,
"block_hash" BLOB,
"previous_block_hash" BLOB,
Expand All @@ -226,15 +263,23 @@ func (m *Migration) Init() error {
"payload_hash" BLOB,
UNIQUE("height")
);`,
`CREATE INDEX "idx_id_spine_block"
ON "spine_block" ("id");`,
`
CREATE TABLE IF NOT EXISTS "spine_public_key"(
"node_public_key" BLOB,
"public_key_action" INTEGER,
"main_block_height" INTEGER,
"latest" INTEGER,
"height" INTEGER,
PRIMARY KEY("node_public_key", "height")
PRIMARY KEY("node_public_key")
);`,
`CREATE INDEX "idx_nodepubkey_spine_pubkey"
ON "spine_public_key" ("node_public_key");
`,
`CREATE INDEX "idx_height_spine_pubkey"
ON "spine_public_key" ("height");
`,
`
CREATE TABLE IF NOT EXISTS "account_ledger" (
"account_address" VARCHAR(255) NULL,
Expand All @@ -244,9 +289,12 @@ func (m *Migration) Init() error {
"event_type" INTEGER
)
`,
`CREATE INDEX "idx_accaddr_account_ledger"
ON "account_ledger" ("account_address");
`,
`
ALTER TABLE "account_ledger"
ADD COLUMN "timestamp" INTEGER
ADD COLUMN "timestamp" INTEGER;
`,
`
CREATE TABLE IF NOT EXISTS "escrow_transaction" (
Expand All @@ -260,8 +308,15 @@ func (m *Migration) Init() error {
"status" INTEGER,
"block_height" INTEGER,
"latest" INTEGER,
"instruction" TEXT
)
"instruction" TEXT,
PRIMARY KEY("id")
);
`,
`CREATE INDEX "idx_id_escrow_transaction"
ON "escrow_transaction" ("id");
`,
`CREATE INDEX "idx_sender_escrow_transaction"
ON "escrow_transaction" ("sender_address");
`,
`
CREATE TABLE IF NOT EXISTS "spine_block_manifest" (
Expand All @@ -276,6 +331,9 @@ func (m *Migration) Init() error {
UNIQUE("id")
)
`,
`CREATE INDEX "idx_id_spine_block_manifest"
ON "spine_block_manifest" ("id");
`,
`
CREATE TABLE IF NOT EXISTS "pending_transaction" (
"sender_address" TEXT, -- sender of transaction
Expand All @@ -287,6 +345,9 @@ func (m *Migration) Init() error {
PRIMARY KEY("transaction_hash", "block_height")
)
`,
`CREATE INDEX "idx_id_pending_transaction"
ON "pending_transaction" ("transaction_hash");
`,
`
CREATE TABLE IF NOT EXISTS "pending_signature" (
"transaction_hash" BLOB, -- transaction hash of pending transaction being signed
Expand All @@ -297,6 +358,12 @@ func (m *Migration) Init() error {
PRIMARY KEY("account_address", "transaction_hash", "block_height")
)
`,
`CREATE INDEX "idx_id_pending_signature"
ON "pending_signature" ("transaction_hash");
`,
`CREATE INDEX "idx_height_pending_signature"
ON "pending_signature" ("height");
`,
`
CREATE TABLE IF NOT EXISTS "multisignature_info" (
"multisig_address" TEXT, -- address of multisig account / hash of multisignature_info
Expand All @@ -308,18 +375,28 @@ func (m *Migration) Init() error {
PRIMARY KEY("multisig_address", "block_height")
)
`,
`CREATE INDEX "idx_msgaddr_multisignature_info"
ON "multisignature_info" ("multisig_address");
`,
`CREATE INDEX "idx_blockheight_multisignature_info"
ON "multisignature_info" ("block_height");
`,
`
ALTER TABLE "transaction"
ADD COLUMN "multisig_child" INTEGER DEFAULT 0
ADD COLUMN "multisig_child" INTEGER DEFAULT 0;
`,
`
CREATE INDEX "node_registry_height_idx" ON "node_registry" ("height")
CREATE INDEX "node_registry_height_idx" ON "node_registry" ("height");
`,
`
CREATE INDEX "skipped_blocksmith_block_height_idx" ON "skipped_blocksmith" ("block_height")
CREATE INDEX "skipped_blocksmith_block_height_idx" ON "skipped_blocksmith" ("block_height");
`,
`
CREATE INDEX "published_receipt_block_height_idx" ON "published_receipt" ("block_height")
CREATE INDEX "published_receipt_block_height_idx" ON "published_receipt" ("block_height");
`,
`
ALTER TABLE "transaction"
ADD COLUMN "multisig_child" INTEGER DEFAULT 0;
`,
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion common/transaction/multiSignature.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (tx *MultiSignatureTransaction) Validate(dbTx bool) error {
}
err := tx.Signature.VerifySignature(body.SignatureInfo.TransactionHash, sig, addr)
if err != nil {
signatureType := util.ConvertBytesToUint32(sig[:])
signatureType := util.ConvertBytesToUint32(sig)
if model.SignatureType(signatureType) != model.SignatureType_MultisigSignature {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion resource/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ smithing=true
proofOfOwnershipReqTimeoutSec = 2
# Log Levels
# Available log level: info, warn, error, fatal, panic
logLevels=["fatal", "error", "panic"]
logLevels=["fatal", "error", "panic","info"]