test: uni-v2 pair #47
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this PR aimed to showcase the impl of a slightly more advanced set of contracts like uniswap-v2 (both pair + factory).
however, it made me realize several limitations of the compilation pipeline, such as the fact that the initial impl was limited to 1 contract per crate. Despite this limitation still holds -we can only have 1 entry point per binary + their bytecode should be independent to reduce contract size and cyclical dependency loops-, i propose a PoC for a more versatile (and complex) compilation process.
r55-compile
revamped so that users can define several contracts (in separate mods) which share a common project. See
uniswap-v2/pair.rsanduniswap-v2/factory.rs.the pipeline identifies all the necessary dependencies, including common mods like
uniswap-v2/math.rs(for the time being, any module imported onlib.rswhich doesn't have a contract is considered common. If we like the PoC, we would enhance AST analysis to only inject the necessary non-contracts mods for each contract). Then it generates an isolates a flattened version of each crate undertarget/r55-generated/--> note that right now i only keep them for debugging purposes, but once the output bytecode is generated, they could be auto-cleared by the script itself.the pipeline still accounts for compilation order based on contract dependencies, and still generates the deployable impls. However, i added more fine-grained control over contract deps based their intended usecase:
interface-only: informed as a regular dep, with its feature flag --> imports the interface to interact with the contractdeployable: since deployable impl will be generated after the temp crate (with flattening) creation, users will have to add metadata to theCargo.tomlto inform the module/crate that should be deployable.for instance, this toml will crate
target/r55-generated/uniswap-v2/factory/deployable.rswith the bytecode oftarget/r55-generated/uniswap-v2/pair/lib.rs. It will also makeerc20::IERC20available to both binaries.Built-in reentrancy guard
Lockwhich implements a built-in reentrancy guard, UX is quite cool imo, as users only ned to:Lockautomatically writes back to storage when dropped, releasing the guardLeverage rust docs for better dev-ex
enhanced contract macro to support private fns
Address opcode
address(this)in solidity.extend MappingGuard
AddAssignto have better mapping UX:Pending TODOs:
to be tackled in other PRs
U8as it doesn't seem to implSolValue: https://github.com/alloy-rs/core/blob/cd4b8d5e77e38d71534742fa4fb0505505b2ca2d/crates/sol-types/src/types/value.rs#L221