Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support proxy.killPure #439

Merged
merged 8 commits into from
Nov 22, 2023
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
76 changes: 38 additions & 38 deletions packages/ui/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,152 +39,152 @@ export const networkList = {
chainId: 'polkadot',
explorerNetworkName: 'polkadot',
rpcUrl: 'wss://rpc.polkadot.io',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: chainsPolkadotCircleSVG
} as NetworkInfo,
kusama: {
chainId: 'kusama',
explorerNetworkName: 'kusama',
rpcUrl: 'wss://kusama-rpc.polkadot.io',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: chainsKusamaSVG
} as NetworkInfo,
'asset-hub-dot': {
chainId: 'asset-hub-polkadot',
explorerNetworkName: 'asset-hub-polkadot',
rpcUrl: 'wss://polkadot-asset-hub-rpc.polkadot.io',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: nodesAssetHubSVG
} as NetworkInfo,
'asset-hub-ksm': {
chainId: 'asset-hub-kusama',
explorerNetworkName: 'asset-hub-kusama',
rpcUrl: 'wss://kusama-asset-hub-rpc.polkadot.io',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: nodesAssetHubSVG
} as NetworkInfo,
acala: {
chainId: 'acala',
explorerNetworkName: 'acala',
rpcUrl: 'wss://acala-rpc-3.aca-api.network/ws',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: chainsAcalaSVG
} as NetworkInfo,
// amplitude: {
// chainId: 'amplitude',
// explorerNetworkName: 'amplitude',
// rpcUrl: 'wss://rpc-amplitude.pendulumchain.tech',
// wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
// httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
// wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
// httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
// logo: chainsAmplitudeSVG
// } as NetworkInfo,
astar: {
chainId: 'astar',
explorerNetworkName: 'astar',
rpcUrl: 'wss://rpc.astar.network',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: nodesAstarPNG
} as NetworkInfo,
'bifrost-dot': {
chainId: 'bifrost-polkadot',
explorerNetworkName: 'bifrost',
rpcUrl: 'wss://eu.bifrost-polkadot-rpc.liebi.com/ws',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: nodesBifrostSVG
} as NetworkInfo,
hydradx: {
chainId: 'hydradx',
explorerNetworkName: 'hydradx',
rpcUrl: 'wss://hydradx-rpc.dwellir.com',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: hydradxSVG
} as NetworkInfo,
interlay: {
chainId: 'interlay',
explorerNetworkName: 'interlay',
rpcUrl: 'wss://interlay-rpc.dwellir.com',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: nodesInterlaySVG
} as NetworkInfo,
khala: {
chainId: 'khala',
explorerNetworkName: 'khala',
rpcUrl: 'wss://khala-api.phala.network/ws',
wsGraphqlUrl: 'wss:///squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https:///squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss:///squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https:///squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: nodesKhalaSVG
} as NetworkInfo,
// pendulum: {
// chainId: 'pendulum',
// explorerNetworkName: 'pendulum',
// rpcUrl: 'wss://rpc-pendulum.prd.pendulumchain.tech',
// wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
// httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
// wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
// httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
// logo: chainsPendulumSVG
// } as NetworkInfo,
moonbeam: {
chainId: 'moonbeam',
explorerNetworkName: 'moonbeam',
rpcUrl: 'wss://moonbeam-rpc.dwellir.com',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: nodesMoonbeamSVG
} as NetworkInfo,
moonriver: {
chainId: 'moonriver',
explorerNetworkName: 'moonriver',
rpcUrl: 'wss://moonriver-rpc.dwellir.com',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: nodesMoonriverSVG
} as NetworkInfo,
phala: {
chainId: 'phala',
explorerNetworkName: 'phala',
rpcUrl: 'wss://api.phala.network/ws',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: phalaSVG
} as NetworkInfo,
'rhala testnet': {
chainId: 'rhala',
explorerNetworkName: '',
rpcUrl: 'wss://subbridge-test.phala.network/rhala/ws',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: nodesKhalaSVG
} as NetworkInfo,
rococo: {
chainId: 'rococo',
explorerNetworkName: 'rococo',
rpcUrl: 'wss://rococo-rpc.polkadot.io',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: chainsRococoSVG
} as NetworkInfo,
// westend: {
// chainId: 'westend',
// explorerNetworkName: 'westend',
// rpcUrl: 'wss://westend-rpc.polkadot.io',
// wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
// httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
// wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
// httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
// logo: nodesWestendColourSVG
// } as NetworkInfo,
joystream: {
chainId: 'joystream',
explorerNetworkName: 'joystream',
rpcUrl: 'wss://rpc.joystream.org',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v1/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v1/graphql',
wsGraphqlUrl: 'wss://squid.subsquid.io/multix-arrow/v/v2/graphql',
httpGraphqlUrl: 'https://squid.subsquid.io/multix-arrow/v/v2/graphql',
logo: nodesJoystreamSVG
},
local: {
Expand Down
5 changes: 5 additions & 0 deletions squid/commands.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"$schema": "https://cdn.subsquid.io/schemas/commands.json",
"commands": {
"migration:apply": {
"description": "Apply the DB migrations",
"cmd": ["squid-typeorm-migration", "apply"]
},
"start-rococo": {
"deps": ["migration:apply"],
"description": "starts the indexer with rococo",
"cmd": [
"node",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = class Data1688401458874 {
name = 'Data1688401458874'
module.exports = class Data1700495579146 {
name = 'Data1700495579146'

async up(db) {
await db.query(`CREATE TABLE "account_multisig" ("id" character varying NOT NULL, "multisig_id" character varying, "signatory_id" character varying, CONSTRAINT "PK_9c47c4be06a450da56b95bf3e06" PRIMARY KEY ("id"))`)
await db.query(`CREATE INDEX "IDX_373149008deefb43018021ac00" ON "account_multisig" ("multisig_id") `)
await db.query(`CREATE INDEX "IDX_b9094826e16b3725b5bcb814b1" ON "account_multisig" ("signatory_id") `)
await db.query(`CREATE TABLE "proxy_account" ("id" character varying NOT NULL, "type" character varying(17) NOT NULL, "delay" integer NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "delegator_id" character varying, "delegatee_id" character varying, CONSTRAINT "PK_ec6559af2b2f1e64069037b7eef" PRIMARY KEY ("id"))`)
await db.query(`CREATE TABLE "proxy_account" ("id" character varying NOT NULL, "type" character varying(17) NOT NULL, "delay" integer NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "extrinsic_index" integer, "creation_block_number" integer, "delegator_id" character varying, "delegatee_id" character varying, CONSTRAINT "PK_ec6559af2b2f1e64069037b7eef" PRIMARY KEY ("id"))`)
await db.query(`CREATE INDEX "IDX_f88663d41538b675ba6787b168" ON "proxy_account" ("delegator_id") `)
await db.query(`CREATE INDEX "IDX_bd9bcaf30e85ab22af2710b822" ON "proxy_account" ("delegatee_id") `)
await db.query(`CREATE TABLE "multisig_call" ("id" character varying NOT NULL, "block_hash" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "call_index" integer NOT NULL, "multisig_id" character varying, CONSTRAINT "PK_fa22322b62825a7b48838d98e17" PRIMARY KEY ("id"))`)
Expand Down
2 changes: 2 additions & 0 deletions squid/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type ProxyAccount @entity {
type: ProxyType!
delay: Int!
createdAt: DateTime!
extrinsicIndex: Int # only useful for pure proxies
creationBlockNumber: Int # only useful for pure proxies
}

# from https://github.com/paritytech/polkadot/blob/476d3ddddf7a8f7361edac92228d0200abac0895/runtime/polkadot/src/lib.rs#L918
Expand Down
2 changes: 1 addition & 1 deletion squid/squid-manifests/large-squid.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
manifestVersion: subsquid.io/v0.1
name: multix-arrow
version: 1
version: 2
description: |-
Arrow Squid for Multix

Expand Down
41 changes: 31 additions & 10 deletions squid/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
import { Env } from './util/Env'
import { getAccountId } from './util/getAccountId'
import { getProxyAccountIByDelegatorIds } from './util/getProxyAccountIByDelegatorIds'
import { KillPureCallInfo, getProxyKillPureArgs } from './util/getProxyKillPureArgs'
import { handleProxyKillPure } from './processorHandlers/handleProxyKillPure'

const supportedMultisigCalls = [
'Multisig.as_multi',
Expand All @@ -31,7 +33,8 @@ const supportedMultisigCalls = [
'Multisig.as_multi_threshold_1'
]

const supportedCalls = ['Proxy.proxy', 'Proxy.remove_proxies', ...supportedMultisigCalls]
const supportedProxyCalls = ['Proxy.proxy', 'Proxy.remove_proxies', 'Proxy.kill_pure']
const supportedCalls = [...supportedProxyCalls, ...supportedMultisigCalls]

const supportedEvents = [
'Proxy.PureCreated',
Expand Down Expand Up @@ -88,19 +91,21 @@ processor.run(
const newProxies: Map<string, NewProxy> = new Map()
const proxyRemovalIds: Set<string> = new Set()
const delegatorToRemoveIds: Set<string> = new Set()
const pureToKill: KillPureCallInfo[] = []

for (const block of ctx.blocks) {
const { calls, events, header } = block
const blockNumber = block.header.height

const timestamp = new Date(header.timestamp || 0)
for (const call of calls) {
if (supportedMultisigCalls.includes(call.name)) {
if (!call.success || !call.origin) continue
// we only care about the successful actions and the ones signed
if (!call.success || !call.origin) continue

if (supportedMultisigCalls.includes(call.name)) {
const signer = getOriginAccount(call.origin)
const callArgs = call.args

const { otherSignatories, threshold } = handleMultisigCall(callArgs)
const { otherSignatories, threshold } = handleMultisigCall(call.args)
const signatories = [signer, ...otherSignatories]

const multisigAddress = getMultisigAddress(signatories, threshold)
Expand All @@ -114,7 +119,6 @@ processor.run(
} as NewMultisigsInfo

newMultisigsInfo.push(newMulti)
const blockNumber = block.header.height
const blockHash = block.header.hash

newMultisigCalls.push({
Expand All @@ -133,9 +137,6 @@ processor.run(
}

if (call.name === 'Proxy.remove_proxies') {
// we only care about the successful actions and the ones signed
if (!call.success || !call.origin) continue

const signer = getOriginAccount(call.origin)
const signerAccountId = getAccountId(signer, chainId)

Expand Down Expand Up @@ -163,6 +164,23 @@ processor.run(
// for any other account, and remove the link
delegatorToRemoveIds.add(signerAccountId)
}

if (call.name === 'Proxy.kill_pure') {
const proxyToKillArgs = getProxyKillPureArgs(call.args)
Array.from(newPureProxies.values()).forEach(
({ creationBlockNumber, extrinsicIndex, who, id }) => {
if (
creationBlockNumber === proxyToKillArgs.blockNumber &&
extrinsicIndex === proxyToKillArgs.extrinsicIndex &&
proxyToKillArgs.spawner === who
) {
newPureProxies.delete(id)
}
}
)

pureToKill.push(proxyToKillArgs)
}
}

for (const event of events) {
Expand All @@ -179,7 +197,9 @@ processor.run(
newPureProxy &&
newPureProxies.set(newPureProxy.id, {
...newPureProxy,
createdAt: timestamp
createdAt: timestamp,
creationBlockNumber: blockNumber,
extrinsicIndex: event.extrinsicIndex
})
}

Expand Down Expand Up @@ -220,6 +240,7 @@ processor.run(
proxyRemovalIds.size && (await handleProxyRemovals(ctx, Array.from(proxyRemovalIds.values())))
newMultisigsInfo.length && (await handleNewMultisigs(ctx, newMultisigsInfo, chainId))
newMultisigCalls.length && (await handleNewMultisigCalls(ctx, newMultisigCalls, chainId))
pureToKill.length && (await handleProxyKillPure(ctx, pureToKill))
newPureProxies.size &&
(await handleNewPureProxies(ctx, Array.from(newPureProxies.values()), chainId))
newProxies.size && (await handleNewProxies(ctx, Array.from(newProxies.values()), chainId))
Expand Down
6 changes: 6 additions & 0 deletions squid/src/model/generated/proxyAccount.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ export class ProxyAccount {

@Column_("timestamp with time zone", {nullable: false})
createdAt!: Date

@Column_("int4", {nullable: true})
extrinsicIndex!: number | undefined | null

@Column_("int4", {nullable: true})
creationBlockNumber!: number | undefined | null
}
3 changes: 2 additions & 1 deletion squid/src/multisigCalls.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Call } from '@subsquid/substrate-processor'
import { encodeId } from './util/accountEncoding'

// "args": {
Expand Down Expand Up @@ -27,7 +28,7 @@ import { encodeId } from './util/accountEncoding'
// "threshold": 2
// },

export const handleMultisigCall = (multisigArgs: any) => {
export const handleMultisigCall = (multisigArgs: Call['args']) => {
const encodedOtherSignatories = multisigArgs['otherSignatories'].map((signatory: string) => {
return encodeId(signatory)
})
Expand Down
4 changes: 3 additions & 1 deletion squid/src/processorHandlers/handleNewProxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export const handleNewProxies = async (ctx: Ctx, newProxies: NewProxy[], chainId
delegatee: delegateeAccount,
type,
delay,
createdAt
createdAt,
creationBlockNumber: null,
extrinsicIndex: null
})
)
}
Expand Down
Loading
Loading