Skip to content

Commit

Permalink
Migrate from address maps to address lookup tables
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Dec 8, 2021
1 parent 0224a8b commit 5c96e59
Show file tree
Hide file tree
Showing 11 changed files with 605 additions and 609 deletions.
17 changes: 9 additions & 8 deletions accountsdb-plugin-postgres/scripts/create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,28 @@ CREATE TYPE "TransactionMessage" AS (
instructions "CompiledInstruction"[]
);

CREATE TYPE "AddressMapIndexes" AS (
writable SMALLINT[],
readonly SMALLINT[]
CREATE TYPE "TransactionMessageAddressTableLookup" AS (
account_key: BYTEA[],
writable_indexes SMALLINT[],
readonly_indexes SMALLINT[]
);

CREATE TYPE "TransactionMessageV0" AS (
header "TransactionMessageHeader",
account_keys BYTEA[],
recent_blockhash BYTEA,
instructions "CompiledInstruction"[],
address_map_indexes "AddressMapIndexes"[]
address_table_lookups "TransactionMessageAddressTableLookup"[]
);

CREATE TYPE "MappedAddresses" AS (
CREATE TYPE "LoadedAddresses" AS (
writable BYTEA[],
readonly BYTEA[]
);

CREATE TYPE "MappedMessage" AS (
CREATE TYPE "LoadedMessageV0" AS (
message "TransactionMessageV0",
mapped_addresses "MappedAddresses"
loaded_addresses "LoadedAddresses"
);

-- The table storing transactions
Expand All @@ -143,7 +144,7 @@ CREATE TABLE transaction (
is_vote BOOL NOT NULL,
message_type SMALLINT, -- 0: legacy, 1: v0 message
legacy_message "TransactionMessage",
v0_mapped_message "MappedMessage",
v0_loaded_message "LoadedMessageV0",
signatures BYTEA[],
message_hash BYTEA,
meta "TransactionStatusMeta",
Expand Down
6 changes: 3 additions & 3 deletions accountsdb-plugin-postgres/scripts/drop_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ DROP TABLE transaction;

DROP TYPE "TransactionError" CASCADE;
DROP TYPE "TransactionErrorCode" CASCADE;
DROP TYPE "MappedMessage" CASCADE;
DROP TYPE "MappedAddresses" CASCADE;
DROP TYPE "LoadedMessageV0" CASCADE;
DROP TYPE "LoadedAddresses" CASCADE;
DROP TYPE "TransactionMessageV0" CASCADE;
DROP TYPE "AddressMapIndexes" CASCADE;
DROP TYPE "TransactionMessage" CASCADE;
DROP TYPE "TransactionMessageHeader" CASCADE;
DROP TYPE "TransactionMessageAddressTableLookup" CASCADE;
DROP TYPE "TransactionStatusMeta" CASCADE;
DROP TYPE "RewardType" CASCADE;
DROP TYPE "Reward" CASCADE;
Expand Down
Loading

0 comments on commit 5c96e59

Please sign in to comment.