Skip to content
Merged
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
37 changes: 0 additions & 37 deletions definitions/migrations/2.0.0/README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,5 @@
# ECA 2.0.0 — AtomicAssets v2 migration notes

## `holder` backfill (release blocker, run out-of-band)

`2.0.0/atomicassets.sql` adds `atomicassets_assets.holder` as a nullable column
(instant, metadata-only). Existing rows have `holder = NULL` until backfilled to
equal `owner`. Do **not** run a single full-table `UPDATE` — on WAX mainnet
`atomicassets_assets` is ~475M rows / ~211 GB and one statement would rewrite the
whole table inside a transaction and bust the cluster `statement_timeout`.

Run a batched backfill out-of-band (filler paused or during a low-traffic
window), e.g.:

```sql
-- repeat until 0 rows affected; tune the batch size to keep each statement well
-- under statement_timeout. Run as the atomicassets app user (owner), not postgres.
DO $$
DECLARE
affected integer;
BEGIN
LOOP
UPDATE atomicassets_assets a
SET holder = owner
WHERE ctid IN (
SELECT ctid FROM atomicassets_assets
WHERE holder IS NULL AND owner IS NOT NULL
LIMIT 50000
);
GET DIAGNOSTICS affected = ROW_COUNT;
RAISE NOTICE 'backfilled % rows', affected;
EXIT WHEN affected = 0;
COMMIT;
END LOOP;
END $$;
```

Smaller chains (testnet, small mainnets) can run the simple
`UPDATE atomicassets_assets SET holder = owner WHERE holder IS NULL;` directly.

## Deferred from the upstream OIG PR (handled separately / flagged for audit)

- `update_atomicmarket_sales_filters` `nx`/`nb` (non-transferable / non-burnable)
Expand Down
11 changes: 0 additions & 11 deletions definitions/migrations/2.0.0/atomicassets-deferred.sql

This file was deleted.

40 changes: 0 additions & 40 deletions definitions/migrations/2.0.0/atomicassets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@
-- DROP ... CASCADE of dependent atomicmarket views.
-- ============================================================================

-- Dual ownership (renting): `holder` = current possessor, `owner` = real owner.
-- New rows are populated by the filler (logmint/logtransfer/logmove). Existing
-- rows must be backfilled `holder = owner` ONCE, OUT-OF-BAND and BATCHED — a
-- single `UPDATE atomicassets_assets SET holder = owner` here would rewrite the
-- whole table inside the migration transaction and bust statement_timeout on
-- WAX. See 2.0.0/README.md for the batched backfill. (Release blocker — tracked
-- in the v2 audit.)
ALTER TABLE atomicassets_assets ADD COLUMN IF NOT EXISTS holder character varying(12);

-- Collection author swaps (pending acceptance): the proposed new author + the
-- acceptance date, surfaced until accept/reject clears them.
ALTER TABLE atomicassets_collections ADD COLUMN IF NOT EXISTS new_author_name character varying(12);
Expand All @@ -31,34 +22,3 @@ ALTER TABLE atomicassets_schemas ADD COLUMN IF NOT EXISTS types jsonb[] NOT NULL
ALTER TABLE atomicassets_templates ADD COLUMN IF NOT EXISTS mutable_data jsonb;
ALTER TABLE atomicassets_templates ADD COLUMN IF NOT EXISTS deleted_at_block bigint;
ALTER TABLE atomicassets_templates ADD COLUMN IF NOT EXISTS deleted_at_time bigint;

-- Asset moves (rental holder changes via the `move` / `logmove` action).
CREATE TABLE IF NOT EXISTS atomicassets_moves (
move_id bigint NOT NULL,
contract character varying(12) NOT NULL,
"sender" character varying(12) NOT NULL,
"recipient" character varying(12) NOT NULL,
memo character varying(256) NOT NULL,
txid bytea NOT NULL,
created_at_block bigint NOT NULL,
created_at_time bigint NOT NULL,
CONSTRAINT atomicassets_moves_pkey PRIMARY KEY (contract, move_id)
);

CREATE TABLE IF NOT EXISTS atomicassets_moves_assets (
move_id bigint NOT NULL,
contract character varying(12) NOT NULL,
"index" integer NOT NULL,
asset_id bigint NOT NULL,
CONSTRAINT atomicassets_moves_assets_pkey PRIMARY KEY (move_id, contract, asset_id)
);

-- Indexes for the NEW (empty) moves tables only — these are instant. The
-- holder index on the existing ~475M-row atomicassets_assets is built
-- CONCURRENTLY in 2.0.0/atomicassets-deferred.sql (a non-CONCURRENTLY build
-- here would lock + bust statement_timeout inside the migration txn and
-- crash-loop the filler).
CREATE INDEX IF NOT EXISTS atomicassets_moves_sender ON atomicassets_moves USING btree (sender);
CREATE INDEX IF NOT EXISTS atomicassets_moves_recipient ON atomicassets_moves USING btree (recipient);
CREATE INDEX IF NOT EXISTS atomicassets_moves_created_at_time ON atomicassets_moves USING btree (created_at_time);
CREATE INDEX IF NOT EXISTS atomicassets_moves_assets_asset_id ON atomicassets_moves_assets USING btree (asset_id);
29 changes: 0 additions & 29 deletions definitions/tables/atomicassets_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ CREATE TABLE IF NOT EXISTS atomicassets_assets (
schema_name character varying(12) NOT NULL,
template_id bigint,
owner character varying(12),
holder character varying(12),
mutable_data jsonb,
immutable_data jsonb,
template_mint INT,
Expand Down Expand Up @@ -154,27 +153,6 @@ CREATE TABLE IF NOT EXISTS atomicassets_transfers_assets (
CONSTRAINT atomicassets_transfers_assets_pkey PRIMARY KEY (transfer_id, contract, asset_id)
);

-- v2: asset moves (rental holder changes via the `move`/`logmove` action) --
CREATE TABLE IF NOT EXISTS atomicassets_moves (
move_id bigint NOT NULL,
contract character varying(12) NOT NULL,
"sender" character varying(12) NOT NULL,
"recipient" character varying(12) NOT NULL,
memo character varying(256) NOT NULL,
txid bytea NOT NULL,
created_at_block bigint NOT NULL,
created_at_time bigint NOT NULL,
CONSTRAINT atomicassets_moves_pkey PRIMARY KEY (contract, move_id)
);

CREATE TABLE IF NOT EXISTS atomicassets_moves_assets (
move_id bigint NOT NULL,
contract character varying(12) NOT NULL,
"index" integer NOT NULL,
asset_id bigint NOT NULL,
CONSTRAINT atomicassets_moves_assets_pkey PRIMARY KEY (move_id, contract, asset_id)
);

-- FOREIGN KEYS --
DO $$
BEGIN
Expand Down Expand Up @@ -270,7 +248,6 @@ CREATE INDEX IF NOT EXISTS atomicassets_assets_collection_name_btree ON atomicas
CREATE INDEX IF NOT EXISTS atomicassets_assets_template_id_asset_id ON atomicassets_assets (template_id, asset_id);
CREATE INDEX IF NOT EXISTS atomicassets_assets_schema_name ON atomicassets_assets USING btree (schema_name);
CREATE INDEX IF NOT EXISTS atomicassets_assets_owner_btree ON atomicassets_assets USING btree (owner);
CREATE INDEX IF NOT EXISTS atomicassets_assets_holder_btree ON atomicassets_assets USING btree (holder);
CREATE INDEX IF NOT EXISTS atomicassets_assets_mutable_data ON atomicassets_assets USING gin (mutable_data);
CREATE INDEX IF NOT EXISTS atomicassets_assets_immutable_data ON atomicassets_assets USING gin (immutable_data);
CREATE INDEX IF NOT EXISTS atomicassets_assets_template_mint ON atomicassets_assets USING btree (template_mint);
Expand Down Expand Up @@ -328,9 +305,3 @@ CREATE INDEX IF NOT EXISTS atomicassets_transfers_recipient ON atomicassets_tran
CREATE INDEX IF NOT EXISTS atomicassets_transfers_created_at_time ON atomicassets_transfers USING btree (created_at_time);

CREATE INDEX IF NOT EXISTS atomicassets_transfers_assets_asset_id ON atomicassets_transfers_assets USING btree (asset_id);

CREATE INDEX IF NOT EXISTS atomicassets_moves_sender ON atomicassets_moves USING btree (sender);
CREATE INDEX IF NOT EXISTS atomicassets_moves_recipient ON atomicassets_moves USING btree (recipient);
CREATE INDEX IF NOT EXISTS atomicassets_moves_created_at_time ON atomicassets_moves USING btree (created_at_time);

CREATE INDEX IF NOT EXISTS atomicassets_moves_assets_asset_id ON atomicassets_moves_assets USING btree (asset_id);
3 changes: 1 addition & 2 deletions definitions/views/atomicassets_assets_master.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ CREATE OR REPLACE VIEW atomicassets_assets_master AS
asset.burned_by_account, asset.burned_at_block, asset.burned_at_time,
asset.updated_at_block, asset.updated_at_time,
asset.transferred_at_block, asset.transferred_at_time,
asset.minted_at_block, asset.minted_at_time,
asset.holder
asset.minted_at_block, asset.minted_at_time
FROM
atomicassets_assets asset
LEFT JOIN atomicassets_templates "template" ON (
Expand Down
12 changes: 0 additions & 12 deletions definitions/views/atomicassets_moves_master.sql

This file was deleted.

18 changes: 0 additions & 18 deletions src/api/namespaces/atomicassets/filler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,3 @@ export async function fillTransfers(
}));
}

export async function fillMoves(
db: DB, contract: string, moves: any[], formatter: (_: any) => any,
view: string, hook?: FillerHook
): Promise<any[]> {
const assetIDs: string[] = [];

for (const move of moves) {
assetIDs.push(...move.assets);
}

const filler = new AssetFiller(db, contract, assetIDs, formatter, view, hook);

return await Promise.all(moves.map(async (move) => {
move.assets = await filler.fill(move.assets);

return move;
}));
}
4 changes: 0 additions & 4 deletions src/api/namespaces/atomicassets/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,3 @@ export function formatOffer(row: any): any {
export function formatTransfer(row: any): any {
return {...row};
}

export function formatMove(row: any): any {
return {...row};
}
Loading