Alexander Theißen
57da96fb50
Consider activation frame for stack height metering ( #2 )
...
* Charge a base cost for calling a function
* Added regression test for empty functions
* Satisfy clippy
2022-01-18 18:04:17 +01:00
Alexander Theißen
e882111f92
Remove everything not needed by substrate
...
Also rename to wasm-instrument
2022-01-11 17:50:24 +02:00
Leonardo Yvens
b22696aaa5
sign_ext feature flag ( #174 )
...
* sign_ext feature flag
* Derive default to fix clippy warning
2021-12-21 15:23:16 +01:00
Keith Yeung
1d62dc1270
cargo fmt
2021-11-13 19:05:45 -08:00
Alexander Theißen
2293760964
Use linear time algorithm to inject stack height metering ( #170 )
2021-09-07 17:42:03 +02:00
Alexander Theißen
2f88f49ef6
Add test for empty loops ( #169 )
2021-09-06 16:25:50 +02:00
Chevdor
b8b18be419
Fix linting related issues ( #164 )
2021-07-27 16:14:14 +02:00
Alexander Theißen
72626a566a
Add a clippy job to the CI ( #163 )
...
* Add clippy CI check
* Fix remaining clippy lints
* Cargo fmt
2021-07-27 15:50:50 +02:00
Chevdor
cb023973e8
Cleanup ( #162 )
...
* Remove unnecessary references
* Shorten expressions
* Remove unnecessary reference
* Simplify expression
* Fix formatting
2021-07-27 15:14:55 +02:00
Alexander Theißen
a0b548b37d
Add rustfmt.toml from substrate repo ( #161 )
...
* Add rustfmt.toml from substrate repo
* Apply rustfmt to code base
* Fix formatting
* Move rustfmt job to the top
2021-07-27 14:46:28 +02:00
Nikolay Volf
1ef05d71ed
Strip custom sections in wasm-prune ( #150 )
...
* strip custom sections
* line width
2021-06-10 14:29:59 +03:00
Sergey Shulepov
19760b5835
Fix counting of the local variables
...
The code assumed that the number of `Local` and number of locals is the
same thing. In reality though it is not. `Local` actually represents a
group of locals with the same type. The group can declare more than one
variable and the number of them is returned by `Local::count`.
In this PR we acknowledge this fact. Along the way we add a checked
arithmetic for locals_count and max_stack_height summation.
2021-06-09 19:22:40 +02:00
Alexander Theißen
95a711bc33
Re-export the whole parity_wasm crate
2021-05-26 15:10:15 +02:00
Alexander Theißen
1b0ed1b383
Transition to Rust 2018 style imports
2021-05-26 14:59:04 +02:00
Alexander Theißen
2d1f4daed7
Update dependencies
2021-04-22 09:08:41 +02:00
Alexander Theißen
b2272f39bc
stack_height: if instruction should pop one value from the stack ( #147 )
...
* stack_height: 'if' instruction should pop one value from the stack
* Fix indentation
2021-04-21 14:08:50 +02:00
Alexander Theißen
1131240d39
Export parity_wasm::Instruction
...
We should export it because it is used in a public interface.
Otherwise every crate that depends on this needs to also
directly depend on parity_wasm.
2020-12-12 17:59:47 +01:00
Michael Mueller
9a0f992cb3
Use results length as arity
2020-12-08 17:24:59 +01:00
Michael Mueller
d6127afd1d
Upgrade to parity-wasm v0.42.1
2020-12-08 16:51:55 +01:00
Alexander Theißen
aebfc0fbd7
Fixes necessary for having no_std imports work with edition2018
2020-10-22 12:26:24 +02:00
Alexander Theißen
f05f43b883
Unify pwasm-utils and pwasm-utils-cli packet
2020-10-21 20:24:49 +02:00
Alexander Theißen
e0dbaef676
Wrapped overlong line
2020-10-14 14:17:12 +02:00
Alexander Theißen
880d273861
Make the rules passed to gas metering injection generic
2020-10-14 13:26:48 +02:00
Alexander Theißen
c09a924a81
Address all clippy lints
...
These changes do not change the behaviour of the
code and should be non-controversial.
2020-10-13 15:42:01 +02:00
Alexander Theißen
1f8e6dd5b2
Don't generate duplicate thunks
...
Previously, functions that appear in multiple places
(exported, start function, table) would generate a thunk
for each place they appear in. Those additional thunks are
identical and only only one of them would be referenced.
Main offender are tables with redundant entries.
This commit eliminates those duplicate thunks without adding
any additional overhead.
2020-10-13 11:43:59 +02:00
Alexander Theißen
5e3b06de05
Fix Instruction::CallIndirect stack height metering
...
The stack height metering for functions containing
CallIndirect was wrong. The code did not take into
consideration that is pops one value from the stack.
The effect was that the stack height of functions
using this instruction was higher than its real height.
2020-10-13 11:43:59 +02:00
Alexander Theißen
409ced002a
Allow specifying the module of the imported 'gas' function ( #140 )
...
* No need for mem::replace when doing a simple assignment
* Allow specifying the module of the imported 'gas' function
This allows users to place the imported function inside a custom
module instead of the generic 'env' module.
2020-08-04 13:53:53 +03:00
Nikolay Volf
e026abe166
Export internal globals instrumentation ( #138 )
...
* export internal globals
* add test
* Update src/export_globals.rs
Co-authored-by: Sergei Shulepov <sergei@parity.io >
* address review
Co-authored-by: Sergei Shulepov <sergei@parity.io >
2020-08-03 14:58:24 +03:00
Nikolay Volf
dcf189b822
Merge pull request #135 from osolmaz/correct-spelling
...
Corrected spelling error
2020-07-29 16:05:53 +03:00
Onur Solmaz
1e8953a9cb
Corrected InstructionType's for GetGlobal and SetGlobal
2020-07-27 13:56:53 +02:00
Onur Solmaz
377684f9c7
Corrected spelling error
2020-07-23 20:08:03 +02:00
Andrew Dirksen
a881cf12bb
Bump 'parity-wasm' version to enable no_std builds on stable.
...
Bump own version in preparation for cargo publish.
Bump cli verion to match.
2019-10-31 15:52:09 -07:00
Thomas Scholtes
b4f9be733d
Preserve "deploy" when optimizing pwasm ctor module
...
When optimizing the constructor module for a PWasm contract the "deploy" symbol is preserved instead of the "call"
symbol. Before this change `build` would error for PWasm contracts because `pack_instance` would not find the "deploy"
symbol in the optimized contract.
Fixes #128
2019-08-29 16:27:48 +02:00
Sergey Pepyakin
a774a2cb29
Update parity-wasm to 0.39
2019-07-30 16:44:05 +02:00
Jim Posen
5792da28d5
Fix typo
...
Co-Authored-By: Sergei Pepyakin <s.pepyakin@gmail.com >
2019-07-25 12:37:57 +02:00
Jim Posen
f8673d5b87
Fix dev dependency crate imports.
2019-07-25 11:05:25 +02:00
Jim Posen
5180d694ce
Validate the gas metering algorithm using fuzzer.
2019-07-19 11:25:54 +02:00
NikVolf
026b0502bb
fix warnings
2019-07-17 17:01:15 +03:00
Jim Posen
82bd972333
!fixup lowest_forward_br rename and field docs.
2019-07-12 10:45:01 +02:00
Jim Posen
93abbcfe56
Add gas injection unit test for correct else behavior.
2019-07-12 10:30:11 +02:00
Jim Posen
ed7f31ec20
Use macro + WAT to make gas injection unit tests more readable.
2019-07-12 10:15:37 +02:00
Jim Posen
b5472bcd8f
!fixup Address review comments.
2019-07-11 16:45:46 +02:00
Jim Posen
0cf7daa9e5
Update high level inject_gas_counter function documentation.
2019-07-04 17:57:40 +02:00
Jim Posen
24924f59ec
Change gas metering injection code to handle branches properly.
2019-07-04 17:57:40 +02:00
Jim Posen
de60f491b4
Fix ordering of actual and expected arguments in assert_eq!.
2019-07-04 17:57:40 +02:00
Jim Posen
4c0f42c6fc
Perform gas metering injection step in linear time.
...
Previously the code was quadratic in the worst case as inserting into
the middle of a vector is a linear-time operation.
2019-07-04 17:57:40 +02:00
Jim Posen
89e13ee901
Cleanup stack height Context.
...
Removes unnecessary Options and fixes typos.
2019-06-26 12:48:51 +02:00
Jim Posen
929e0ec2c0
Documentation of gas metering instrumentation process.
2019-06-26 12:47:30 +02:00
NikVolf
0d40703c6e
fix identation
2019-04-09 19:02:07 +03:00
NikVolf
38e0f254b0
use indoc!
2019-01-27 12:15:38 +03:00