-
Notifications
You must be signed in to change notification settings - Fork 46
Update indices of functions in name section while injecting gas function #146
Conversation
I am curious, why do you need this? |
Ref to use-ink/cargo-contract#131, paritytech/parity-wasm#300 and wasmi-labs/wasmi@master...patractlabs:v0.6.2
We have implemented wasm backtrace for contracts in @patractlabs/europa, for example, panic in the
And there will be more backtraces if we enable the |
Just to err on the safe side, do you think it's possible to demarcate the execution for debugging and on-chain use-cases? FWIW, I am not so keen to see a complete reallocation and rebuilding of the name section during (already heavy-ish) contract preparation step Also, @athei what do you think about this? Does this concern Seal? Do name sections ever pass thru the preparation/put code stage, and does gas injection observe it? |
There is no exhaustive matching on the sections. Any unknown section will just pass through to gas injection and hence will be affected by this code. Maybe we should change that to deny deployment if any unknown section (like name section) is encountered. |
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.
We can't add more allocations to on-chain critical pathes.
It would be nice to add a field in the runtime |
It is just a security precaution to not have sections in wasm-blobs on-chain which we do not make use of. So why should we allow deploying this section when it is currently unused? |
I would be fine with merging if you add a enum ProcessNames {
No,
UnsafeYes,
} |
…njecting gas counter
@athei @pepyakin though And on the other hand, By the way, currently, we implement this in our forked |
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 inject_gas_counter
never calls parse_names
. This means the name section is not there unless the caller did call this function. That should be at least documented with a big note.
The tests must be extended to include a name section. This new functionality is completely untested as it stands. This should be easily achieve by adding a name section to the fixtures.
/// If process name section while injecting gas counter | ||
pub enum ProcessNames { | ||
No, | ||
UnsafeYes, | ||
} | ||
|
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.
Would be nice to have some more comprehensive documentation for the enum variants. This was the whole point for having it.
@@ -601,7 +629,7 @@ mod tests { | |||
.build() | |||
.build(); | |||
|
|||
let injected_module = inject_gas_counter(module, &rules::Set::default(), "env").unwrap(); | |||
let injected_module = inject_gas_counter(module, &rules::Set::default(), "env", ProcessNames::No).unwrap(); |
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.
Why disable? Overlong line.
@@ -652,7 +680,7 @@ mod tests { | |||
.build() | |||
.build(); | |||
|
|||
let injected_module = inject_gas_counter(module, &rules::Set::default(), "env").unwrap(); | |||
let injected_module = inject_gas_counter(module, &rules::Set::default(), "env", ProcessNames::No).unwrap(); |
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.
Overlong line.
@@ -721,7 +749,7 @@ mod tests { | |||
let input_module = parse_wat($input); | |||
let expected_module = parse_wat($expected); | |||
|
|||
let injected_module = inject_gas_counter(input_module, &rules::Set::default(), "env") | |||
let injected_module = inject_gas_counter(input_module, &rules::Set::default(), "env", ProcessNames::No) |
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.
Overlong line.
@@ -110,7 +110,7 @@ mod gas { | |||
let rules = utils::rules::Set::default(); | |||
|
|||
let module = elements::deserialize_buffer(input).expect("Failed to deserialize"); | |||
let instrumented = utils::inject_gas_counter(module, &rules, "env") | |||
let instrumented = utils::inject_gas_counter(module, &rules, "env", utils::ProcessNames::No) |
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.
You should add a function name to the fixtures and enable it here. Also you may need to call parse_names
on the module.
Closed for lack of activity. |
Desc
Here we forgetting to update the indices in the name section