Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uniswap demo #179

Merged
merged 1 commit into from
Mar 3, 2021
Merged

Uniswap demo #179

merged 1 commit into from
Mar 3, 2021

Conversation

g-r-a-n-t
Copy link
Member

@g-r-a-n-t g-r-a-n-t commented Jan 12, 2021

What was wrong?

We need some contracts for the Uniswap demo.

How was it fixed?

  • copied the Solidity implementation and translated the contracts to Fe
  • added testing
  • documented remaining features needed for full support

To-Do

  • OPTIONAL: Update Spec if applicable

  • Add entry to the release notes (may forgo for trivial changes)

  • Clean up commit history

@g-r-a-n-t g-r-a-n-t marked this pull request as draft January 12, 2021 00:12
@codecov-io
Copy link

codecov-io commented Jan 12, 2021

Codecov Report

Merging #179 (9bc1ae0) into master (d300570) will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #179      +/-   ##
==========================================
+ Coverage   77.93%   77.96%   +0.03%     
==========================================
  Files          45       45              
  Lines        3300     3300              
==========================================
+ Hits         2572     2573       +1     
+ Misses        728      727       -1     
Impacted Files Coverage Δ
compiler/src/abi/elements.rs 74.64% <0.00%> (+1.40%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d300570...9bc1ae0. Read the comment docs.

@g-r-a-n-t g-r-a-n-t force-pushed the uniswap-contracts branch 2 times, most recently from 04051cd to 9bc1ae0 Compare January 15, 2021 01:58
@g-r-a-n-t g-r-a-n-t marked this pull request as ready for review January 15, 2021 02:55
@g-r-a-n-t
Copy link
Member Author

Still a few small things I want to clean up and features that need to be documented, but I thought it would be nice to get some feedback before the weekend.

pairs: map<address, map<address, address>>

# todo: discuss unbounded storage arrays
all_pairs: address[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I've been thinking about this every now and then

Copy link
Collaborator

@cburgdorf cburgdorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Looks like we aren't too far off from getting it compiled. Also 👍 on moving these things into /demo/.

compiler/tests/fixtures/demos/uniswap.fe Outdated Show resolved Hide resolved

# update reserves and, on the first call per block, price accumulators
def _update(balance0: u256, balance1: u256, reserve0: u112, reserve1: u112):
assert balance0 <= u112(-1) and balance1 <= u112(-1), "UniswapV2: OVERFLOW"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we want to get max values using u112(-1)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good point. It feels hacky to me that some languages even allow this. We already have a check in place that something like u8(-1) doesn't compile (nothing of type uxxx allows passing -1). I think we want something like u8.max(), u8.min() to expose these.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I like the idea of having uxxx.max() & uxxx.min().

@g-r-a-n-t g-r-a-n-t force-pushed the uniswap-contracts branch 5 times, most recently from 204b072 to 1d2d476 Compare March 3, 2021 00:13
@g-r-a-n-t
Copy link
Member Author

@cburgdorf , core functionality seems to work. There are a few more things that we should try to get done before April, tho. These things are documented in TODO comments that link to issues.

Copy link
Collaborator

@cburgdorf cburgdorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really really cool! I left a few comments regarding things that I consider worth to create issues for and link to them in the example. I also think we should put the testing code into a separate file because our all-tests-in-one-file approach is starting to look unsustainable 😅

Other than that, looks amazing 👍

compiler/tests/evm_contracts.rs Outdated Show resolved Hide resolved
compiler/tests/fixtures/demos/uniswap.fe Show resolved Hide resolved
compiler/tests/fixtures/demos/uniswap.fe Outdated Show resolved Hide resolved
compiler/tests/fixtures/demos/uniswap.fe Show resolved Hide resolved
compiler/tests/fixtures/demos/uniswap.fe Show resolved Hide resolved
compiler/tests/fixtures/demos/uniswap.fe Show resolved Hide resolved
@g-r-a-n-t g-r-a-n-t merged commit b8fe0ec into ethereum:master Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants