The data structure can be used to build the JSON input for `resolc` too.
In that case serializing of provided custom options should not be
dismissed.
Makes the memory settings struct more modular as a drive-by.
---------
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Exposes the following PolkaVM specific options via the standard json
interface:
- Heap size
- Stack size
- Whether to emit source level debug information
Additionally it is now forbidden to specify those as CLI option in
standard JSON mode. They are bytecode altering options and having
multiple ways to specify them creates unnecessary room for confusion:
The standard JSON input description should be sufficient and succint for
reproducible builds.
Closes#290
---------
Signed-off-by: xermicus <bigcyrill@hotmail.com>
So far if no optimization level was specified, optimizations for
execution time were applied. However, we currently are a bit limited on
code size. Add to that, this setting is not available in solc and people
generally ignore the docs, generating a lot of support requests.
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
- Allow configuration of the maximum heap and stack size via CLI flags
and JSON input settings.
- Increase the default value for the stack size to 32kb.
---------
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This PR changes the implementation of the emulated EVM heap memory:
Instead of linking in a C implementation the code is emitted directly
into the contract module. Which allows making it configurable via a
compiler parameter (a follow up PR to this).
---------
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Closes #48
Change the code size test to no longer emit debug info as to get a more
accurate picture.
---------
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
- Lazily load function arguments so that they can be passed as pointers.
- Lazily call the immutable store function to avoid storing zero sized
immutable data.
---------
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Storage keys and values are big endian. Keeping them LE was a pre-mature
optimization because for the contract itself it this is a no-op and thus
not observable. However we should consider the storage layout as part of
the contract ABI. The endianness of transient storage values are still
kept as-is.
---------
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
- Support for passing LLVM command line options via the prcoess input or
providing one or more `--llvm-arg='..'` resolc CLI flag. This allows
more fine-grained control over the LLVM backend configuration.
- Make LLVM initialization idempotent.
---------
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
The differential testing framework will make a second consumer. There
seems to be no re-usable Rust crate for this. But we already have
everything here, just needs a small refactor to make it fully re-usable.
- Mostly decouple the solc JSON-input-output interface types from the
`solidity` frontend crate
- Expose the JSON-input-output interface types in a dedicated crate
---------
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
- remove the __sha3 function symbol: this is provided by the pallet
- remove the storage address spaces: they are not mapped into memory
---------
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
- Add the revive runtime function interface to minimize boiler plate
code.
- Outline heavily repeated code into dedicated functions to bring down
code size.
- The code size tests builds optimized for size.
- Function attributes are passed as slices.
This significantly brings down the code size for all OpenZeppelin wizard
contracts (using all possible features) compiled against OpenZeppelin
`v5.0.0` with size optimizations.
|contract|| `-Oz` main | `-Oz` PR || `-O3` main | `-O3` PR |
|-|-|-|-|-|-|-|
|erc1155.sol||100K|67K||114K|147K|
|erc20.sol||120K|90K||160K|191K|
|erc721.sol||128K|101K||178K|214K|
|governor.sol||226K|165K||293K|349K|
|rwa.sol||116K|85K||154K|185K|
|stable.sol||116K|86K||155K|192K|
On the flip side this introduces a heavy penalty for cycle optimized
builds. Setting the no-inline attributes for cycle optimized builds
helps a lot but heavily penalizes runtime speed (LLVM does not yet
inline everything properly - to be investigated later on).
Next steps:
- Modularize more functions
- Refactor the YUL function arguments to use pointers instead of values
- Afterwards check if LLVM still has trouble inline-ing properly on O3
or set the no-inline attribute if it does not penalize runtime
performance too bad.
- The storage pointer values will no longer be truncated to the register size, allowing for the use of arbitrary storage keys
- Failed storage value reads will now guarantee to return the zero value
- remove unused runtime API imports and constants
- move runtime api symbols into the revive-runtime-api crate
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>