-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expose validation specific host function. #2366
Conversation
// Locking as read only to allow access to code memory from | ||
// host validation extension. | ||
// Note that this only work if two process are communicating only. | ||
// Would be racy otherwhise. |
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.
I am unsure of this assertion: I did switch the lock to read to be able to acces the wasm slice directly, but this would be racy if the shared memory is consumed by multiple client.
CC\ @arkpar
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.
I don't understand why you are doing all this, when we read the code anyway.
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.
The code is passed as a slice and the validation host function uses an extension which require 'static lifetime, so I cannot use a slice in it.
(I could have put it behind an Arc but would be a clone)
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.
I think it is better to clone than doing the magic here.
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.
I can also try to access it with 'let validation_code = runtime_api_request( ctx, descriptor.relay_parent, RuntimeApiRequest::ValidationCode( descriptor.para_id, assumption, code_tx, ), code_rx, ).await?;', not sure it if it is accessible.
Edit: does not make sense, will just clone for now.
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.
Multiple parallel validation are supported, but each process is run in a separate instance of ValidationHost
. So aliasing code memory slice should be safe.
Closing, I am reverting cumulus PR to only compact proof (I remove the value skip to keep thing simple, so no need for this pr). |
This branch and cumulus pre refactor https://github.com/paritytech/cumulus/tree/d300493f36150011437fe4e65b5eb25453eb6d85 and trie paritytech/trie#126 . Here the point was to avoid the runtime code in pov, which was done by removing from proof and allowing access from validation function (current). |
This PR is required for paritytech/cumulus#295
It exposes a runtime interface 'Validation'. It only contains a function 'validation_code' that return the wasm code use in a validation context.
This is use in paritytech/cumulus#295 to insert the validation code in place of the runtime code in proof (note that this only work with cumulus because currently cumulus uses the same wasm for validation and runtime).