-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dev_newBlock): Adds option to override relaychain state (#824)
* feat(dev_newBlock): Adds option to override relaychain state * fix comment * test: only test relayChainStateOverrides on parachains * apply suggestions from review
- Loading branch information
Showing
5 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { describe, expect, it } from 'vitest' | ||
|
||
import { TypeRegistry } from '@polkadot/types' | ||
import { decodeProof } from '@acala-network/chopsticks-core' | ||
import { upgradeRestrictionSignal } from '@acala-network/chopsticks-core/utils/proof.js' | ||
import networks from './networks.js' | ||
|
||
describe('override-relay-state-proof', async () => { | ||
it('build block using relayChainStateOverrides', async () => { | ||
const { ws, api, teardown } = await networks.acala() | ||
const registry = new TypeRegistry() | ||
const paraId = registry.createType('u32', 1000) | ||
|
||
const keyToOverride = upgradeRestrictionSignal(paraId) | ||
const value = '0x00' | ||
const relayChainStateOverrides = [[keyToOverride, value]] | ||
|
||
await ws.send('dev_newBlock', [{ relayChainStateOverrides }]) | ||
const block = await api.rpc.chain.getBlock() | ||
const setValidationData = block.block.extrinsics | ||
.find(({ method }) => method.method == 'setValidationData') | ||
?.method.toJSON().args.data | ||
|
||
const relayParentStorageRoot = setValidationData.validationData.relayParentStorageRoot | ||
const trieNodes = setValidationData.relayChainState.trieNodes | ||
|
||
const relayChainState = await decodeProof(relayParentStorageRoot, trieNodes) | ||
|
||
expect(relayChainState[keyToOverride]).to.be.eq(value) | ||
|
||
await teardown() | ||
}) | ||
}) |