-
Notifications
You must be signed in to change notification settings - Fork 329
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
Add GMP precompile killswitch #2292
Conversation
context.polkadotApi.tx.system.setStorage([ | ||
[ | ||
ENABLED_FLAG_STORAGE_ADDRESS, | ||
context.polkadotApi.registry.createType("Option<bool>", true).toHex() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on https://docs.substrate.io/reference/scale-codec/, I think 0x0101
should be the same thing (Some(true)
)
Coverage generated "Fri May 19 21:40:40 UTC 2023": Master coverage: 72.42% |
Sorry it's taken me so long to take a look at this. |
I added such a test in c9635d0, but it really needs to check the output because there are plenty of other reasons it could revert. Do we have anything like |
if you have the txn hash you can just call |
@@ -209,6 +210,21 @@ describeDevMoonbeam(`Test local Wormhole`, (context) => { | |||
.signAndSend(alith); | |||
await context.createBlock(); | |||
|
|||
// we also need to disable the killswitch by setting the 'enabled' flag to Some(true) | |||
const ENABLED_FLAG_STORAGE_ADDRESS = | |||
"0xb7f047395bba5df0367b45771c00de502551bba17abb82ef3498bab688e470b8"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to be tedious but can you derive this instead, so that it's clear what this is?
This is to help future generations having to work out where that key is from (and it's a pain to work backwards from a hash).
const enabledFlagKey = u8aToHex(
u8aConcat(xxhashAsU8a("gmp", 128), xxhashAsU8a("PrecompileEnabled", 128))
);
ℹ️ both functions are available in the
@polkadot/util
repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Added in 751af83. I also left the keys themselves for future generations 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 👍
* Add GMP precompile killswitch * Test revert values * Don't decode revert message * Properly encode revert string * Test against encoded output * Disable killswitch in wormhole test * prettier * Add basic TS test covering killswitch default * Expect revert reason to match killswitch * Don't share test suite with killswitch test * Derive magic storage keys
What does it do?
Adds an explicit killswitch to the GMP precompile. This defaults to enabled, so the precompile will not work without it being disabled first.
TODO:
wormhole_transfer_erc20
in tests to make sure it properly failsexecute_reverts_no_decode()
messset_storage
to show that this technique works to manage the killswitchset_storage
call is made to enable it.