Skip to content

Commit 05d3646

Browse files
committed
Merge branch 'v155'
2 parents d3e12f3 + feceac1 commit 05d3646

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = class Data1781633867200 {
2+
name = 'Data1781633867200'
3+
4+
async up(db) {
5+
// In-place upgrade of the live v155 database (continues the existing DB, no re-sync):
6+
// add the per-asset `outstanding_assets` array (in-flight protocol redemptions, aligned
7+
// to Arm.assets) and backfill it from existing data. Adding a NOT NULL column to a
8+
// populated table requires a temporary default; we backfill, then drop the default so the
9+
// schema matches main's squashed migration (where the column is created NOT NULL, no default).
10+
await db.query(`ALTER TABLE "arm_state" ADD COLUMN "outstanding_assets" text array NOT NULL DEFAULT '{}'`)
11+
await db.query(`ALTER TABLE "arm_daily_stat" ADD COLUMN "outstanding_assets" text array NOT NULL DEFAULT '{}'`)
12+
// Every ARM is still pre-upgrade (single base asset, upgradeBlock=null), so
13+
// outstanding_assets = [0, outstandingAssets1]: [0] = liquidity asset (never redeems into
14+
// itself), [1] = the existing outstanding_assets1 scalar. outstanding_assets1 is a numeric
15+
// BigInt; cast to plain-integer text to match the entity's decimal-string array format.
16+
await db.query(`UPDATE "arm_state" SET "outstanding_assets" = ARRAY['0', "outstanding_assets1"::text]`)
17+
await db.query(`UPDATE "arm_daily_stat" SET "outstanding_assets" = ARRAY['0', "outstanding_assets1"::text]`)
18+
await db.query(`ALTER TABLE "arm_state" ALTER COLUMN "outstanding_assets" DROP DEFAULT`)
19+
await db.query(`ALTER TABLE "arm_daily_stat" ALTER COLUMN "outstanding_assets" DROP DEFAULT`)
20+
}
21+
22+
async down(db) {
23+
await db.query(`ALTER TABLE "arm_state" DROP COLUMN "outstanding_assets"`)
24+
await db.query(`ALTER TABLE "arm_daily_stat" DROP COLUMN "outstanding_assets"`)
25+
}
26+
}

src/templates/origin-arm/origin-arm.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,12 @@ export const createOriginARMProcessors = ({
292292
return armStateEntity
293293
}
294294
const previousState = await getPreviousState(block)
295-
const upgraded = armEntity.upgradeBlock != null && block.header.height >= armEntity.upgradeBlock
295+
// An upgrade transaction can emit state-triggering events before BaseAssetAdded.
296+
// eth_call sees the upgraded implementation for the entire block, so consider
297+
// the ARM upgraded when BaseAssetAdded appears anywhere in the current block.
298+
const upgraded =
299+
(armEntity.upgradeBlock != null && block.header.height >= armEntity.upgradeBlock) ||
300+
block.logs.some((log) => baseAssetAddedFilter.matches(log))
296301
const armContract = new originOsArmAbi.Contract(ctx, block.header, armAddress)
297302
const lidoArmContract = new originLidoArmAbi.Contract(ctx, block.header, armAddress)
298303
const ethenaArmContract = new originEthenaArmAbi.Contract(ctx, block.header, armAddress)

0 commit comments

Comments
 (0)