diff --git a/common/database/migration.go b/common/database/migration.go index cabf6af21..549b630d7 100644 --- a/common/database/migration.go +++ b/common/database/migration.go @@ -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, @@ -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, @@ -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, @@ -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, @@ -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), @@ -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, @@ -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, @@ -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, @@ -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, @@ -226,6 +263,8 @@ 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, @@ -233,8 +272,14 @@ func (m *Migration) Init() error { "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, @@ -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" ( @@ -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" ( @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/common/transaction/multiSignature.go b/common/transaction/multiSignature.go index 8c2479ef3..d896ce4d7 100644 --- a/common/transaction/multiSignature.go +++ b/common/transaction/multiSignature.go @@ -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 } diff --git a/resource/config.toml b/resource/config.toml index 70d8a63e1..bae61d14c 100644 --- a/resource/config.toml +++ b/resource/config.toml @@ -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"]