AmbireTech / adex-protocol-eth

Ethereum implementation of the Ambire Protocol: Ambire Wallet contracts and AdEx payment channels
https://www.ambire.com
MIT License
49 stars 24 forks source link

Ethereal Hackathon Bounty: AdEx: generate identity proxy bytecode without solc #62

Closed Ivshti closed 5 years ago

Ivshti commented 5 years ago

IdentityDeployProxy.js: look into ways of generating bytecode w/o solc

Challenge description:

We use an Identity contract that reprensets each user (similar to multisig contracts, e.g. Gnosis safe); to save gas when deploying an identity for each user, we use delegatecall-based proxies.

The proxy contract bytecode is generated by the following JS: https://github.com/AdExNetwork/adex-protocol-eth/blob/master/js/IdentityProxyDeploy.js, for each user

There are comprehensive tests in test/TestIdentity that show how that API is supposed to be used.

However, this JS library uses the full solc, which has some issues:

So, the challenge is to rewrite that JS to generate bytecode that does the same, but without having to ship solc (potentially by using a lighter weight EVM assember)

Submission requirements:

Submission deadline:

Judging criteria:

Judging date:

Bounty:

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 1500.0 DAI (1500.0 USD @ $1.0/DAI) attached to it as part of the AdExNetwork fund.

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 3 weeks, 3 days from now. Please review their action plans below:

1) smitrajput has started work.

Will try to integrate a lighter weight EVM assembler

Learn more on the Gitcoin Issue Details page.

rmshea commented 5 years ago

hey @smitrajput, how's it coming on this one?

smitrajput commented 5 years ago

@ryan-shea not that easy to be honest. I do have a solution in mind, but not sure if that would fit in well, given the trade-off between gas-optimization and runtime overhead

cryptomental commented 5 years ago

Hi I did not pick it up since I joined the hackathon too late and the challenge seems complex, but the problem itself is quite interesting. If I understood correctly you are trying to generate parametrized bytecode based on several inputs and would like to avoid fetching and triggering Solidity compiler due to crashes and runtime overhead for loading solc. I have had two, perhaps stupid (or not) ideas, first would be to use an external, let's call it a microservice, that would run with solc installed and accept the input parameters, return the bytecode. Still has an overhead but you would avoid loading solc and executing it client-side. Second idea (a bit hacky though) would be to compile identity proxy bytecode based on a few configurations, dissasemble the output, and try to implement injector that would simply inject needed opcodes and data into a identity proxy bytecode template. I am not sure if that is the way to go though -)

fergarrui commented 5 years ago

Hi,

I wanted to start working at this. First, I want to run the tests to see that what I'm changing, works.

I did:

npm install
npx truffle compile
npx truffle test

I get all tests passing, except:

  16 passing (20s)
  3 failing

  1) Contract: Identity
       relay a tx:

      error message is incorrect
      + expected - actual

      -VM Exception while processing transaction: out of gas
      +VM Exception while processing transaction: revert ONLY_IDENTITY_CAN_CALL

      at expectEVMError (test/index.js:11:10)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  2) Contract: Identity
       execute by sender:

      error message is incorrect
      + expected - actual

      -VM Exception while processing transaction: revert
      +VM Exception while processing transaction: revert PRIVILEGE_NOT_DOWNGRADED

      at expectEVMError (test/index.js:11:10)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

  3) Contract: Identity
       channelOpen and channelWithdrawExpired, via routines:

      error message is incorrect
      + expected - actual

      -VM Exception while processing transaction: revert
      +VM Exception while processing transaction: revert NOT_EXPIRED

      at expectEVMError (test/index.js:11:10)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

Anythng else I have to do?

Thanks

Ivshti commented 5 years ago

the tests are failing cause ganache is not reporting the proper err message I have no idea why this happens but it doesn't happen on our CI (travis)

You should do a clean npm install and try again

On Sun, 26 May 2019 at 14:36, Fernando Garcia notifications@github.com wrote:

Hi,

I wanted to start working at this. First, I want to run the tests to see that what I'm changing, works.

I did:

npm install

npx truffle compile npx truffle test

I get all tests passing, except:

16 passing (20s) 3 failing

1) Contract: Identity relay a tx:

  error message is incorrect
  + expected - actual

  -VM Exception while processing transaction: out of gas
  +VM Exception while processing transaction: revert ONLY_IDENTITY_CAN_CALL

  at expectEVMError (test/index.js:11:10)
  at <anonymous>
  at process._tickCallback (internal/process/next_tick.js:188:7)

2) Contract: Identity execute by sender:

  error message is incorrect
  + expected - actual

  -VM Exception while processing transaction: revert
  +VM Exception while processing transaction: revert PRIVILEGE_NOT_DOWNGRADED

  at expectEVMError (test/index.js:11:10)
  at <anonymous>
  at process._tickCallback (internal/process/next_tick.js:188:7)

3) Contract: Identity channelOpen and channelWithdrawExpired, via routines:

  error message is incorrect
  + expected - actual

  -VM Exception while processing transaction: revert
  +VM Exception while processing transaction: revert NOT_EXPIRED

  at expectEVMError (test/index.js:11:10)
  at <anonymous>
  at process._tickCallback (internal/process/next_tick.js:188:7)

Anythng else I have to do?

Thanks

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AdExNetwork/adex-protocol-eth/issues/62?email_source=notifications&email_token=AAJQTDINX35X7GDJLS5VTF3PXJY5LA5CNFSM4HEB5EKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWID44Y#issuecomment-495992435, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJQTDPY23Z66YQ56GZJYB3PXJY5LANCNFSM4HEB5EKA .

--

[image: photo] Ivo Georgiev Founder & CEO, Stremio

https://www.stremio.com http://www.stremio.com

GPG: AC692BE9EB6E024B5C58A8EAC1E94996BC56BACE http://www.stremio.com http://www.facebook.com/stremio/ http://twitter.com/stremio http://www.instagram.com/stremioofficial/ http://www.reddit.com/r/Stremio/ http://blog.stremio.com/

https://play.google.com/store/apps/details?id=com.stremio.beta https://itunes.apple.com/us/app/stremio/id987232010?mt=8

fergarrui commented 5 years ago

It reports correctly for some other Tests @Ivshti I'll try that, thanks

mul1sh commented 5 years ago

@Ivshti any chance this issue is still open? thanks

Ivshti commented 5 years ago

No, this bounty is closed, sorry

On Wed, 26 Jun 2019 at 01:22, Mulili Nzuki notifications@github.com wrote:

@Ivshti https://github.com/Ivshti any chance this issue is still open? thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AdExNetwork/adex-protocol-eth/issues/62?email_source=notifications&email_token=AAJQTDODZDPBT2JBOK7VBU3P4KLBLA5CNFSM4HEB5EKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYRYOVY#issuecomment-505644887, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJQTDKCIUV5KIJBKIN3CBTP4KLBLANCNFSM4HEB5EKA .

--

[image: photo] Ivo Georgiev Founder & CEO, Stremio

https://www.stremio.com http://www.stremio.com

GPG: AC692BE9EB6E024B5C58A8EAC1E94996BC56BACE http://www.stremio.com http://www.facebook.com/stremio/ http://twitter.com/stremio http://www.instagram.com/stremioofficial/ http://www.reddit.com/r/Stremio/ http://blog.stremio.com/

https://play.google.com/store/apps/details?id=com.stremio.beta https://itunes.apple.com/us/app/stremio/id987232010?mt=8

mul1sh commented 5 years ago

@Ivshti ok thanks for your feedback, appreciate it

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Cancelled


The funding of 1500.0 DAI (1500.0 USD @ $1.0/DAI) attached to this issue has been cancelled by the bounty submitter