Skip to content

Commit

Permalink
remove unnecessary storage cleanup (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
ermalkaleci authored Feb 28, 2023
1 parent c1d6b7f commit 5814b49
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/chopsticks/src/xcm/downward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const connectDownward = async (relaychain: Blockchain, parachain: Blockch
const value = pairs[0][1]
if (!value) return

const meta = await relaychain.head.meta
const meta = await head.meta
const downwardMessageQueuesKey = compactHex(meta.query.dmp.downwardMessageQueues(paraId))

// clear relaychain message queue
Expand Down
10 changes: 2 additions & 8 deletions packages/chopsticks/src/xcm/horizontal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Blockchain } from '../blockchain'
import { HorizontalMessage } from '../blockchain/txpool'
import { compactHex } from '../utils'
import { logger } from '.'
import { setStorage } from '../utils/set-storage'

export const connectHorizontal = async (parachains: Record<number, Blockchain>) => {
for (const [id, chain] of Object.entries(parachains)) {
Expand All @@ -17,12 +16,7 @@ export const connectHorizontal = async (parachains: Record<number, Blockchain>)
const value = pairs[0][1]
if (!value) return

const meta = await chain.head.meta

const hrmpOutboundMessagesKey = compactHex(meta.query.parachainSystem.hrmpOutboundMessages())

// clear sender message queue
await setStorage(chain, [[hrmpOutboundMessagesKey, null]], head.hash)
const meta = await head.meta

const outboundHrmpMessage = meta.registry
.createType('Vec<PolkadotCorePrimitivesOutboundHrmpMessage>', hexToU8a(value))
Expand All @@ -32,7 +26,7 @@ export const connectHorizontal = async (parachains: Record<number, Blockchain>)

for (const { recipient, data } of outboundHrmpMessage) {
const horizontalMessages: Record<number, HorizontalMessage[]> = {
[Number(id)]: [{ sentAt: chain.head.number, data }],
[Number(id)]: [{ sentAt: head.number, data }],
}
const receiver = parachains[recipient]
if (receiver) {
Expand Down
8 changes: 1 addition & 7 deletions packages/chopsticks/src/xcm/upward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { hexToU8a } from '@polkadot/util'
import { Blockchain } from '../blockchain'
import { compactHex, getParaId } from '../utils'
import { logger } from '.'
import { setStorage } from '../utils/set-storage'

export const connectUpward = async (parachain: Blockchain, relaychain: Blockchain) => {
const meta = await parachain.head.meta
Expand All @@ -14,12 +13,7 @@ export const connectUpward = async (parachain: Blockchain, relaychain: Blockchai
const value = pairs[0][1]
if (!value) return

const parachainMeta = await parachain.head.meta
const upwardMessagesKey = compactHex(parachainMeta.query.parachainSystem.upwardMessages())

// clear parachain message queue
await setStorage(parachain, [[upwardMessagesKey, null]], head.hash)

const parachainMeta = await head.meta
const relaychainMeta = await relaychain.head.meta

const upwardMessages = parachainMeta.registry.createType('Vec<Bytes>', hexToU8a(value))
Expand Down

0 comments on commit 5814b49

Please sign in to comment.