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

feat: add precompiles #21

Merged
merged 31 commits into from
Apr 27, 2021
Merged

feat: add precompiles #21

merged 31 commits into from
Apr 27, 2021

Conversation

joshuajbouw
Copy link
Contributor

@joshuajbouw joshuajbouw commented Apr 5, 2021

Adds precompiles to the aurora engine.

  • identity
  • sha256
  • ripemd
  • modexp
  • alt_bn128_add
  • alt_bn128_mul
  • alt_bn128_pair
  • blake2f

@joshuajbouw joshuajbouw self-assigned this Apr 5, 2021
@joshuajbouw joshuajbouw requested a review from artob as a code owner April 5, 2021 09:01
@joshuajbouw joshuajbouw linked an issue Apr 5, 2021 that may be closed by this pull request
@joshuajbouw joshuajbouw marked this pull request as draft April 5, 2021 09:02
@joshuajbouw
Copy link
Contributor Author

joshuajbouw commented Apr 5, 2021

I had changed the inputs but kept the same output for the blake2f function @artob. Would you like me to revert it back? According to the implementation on go ETH client, this is the same inputs, but the output is different. As in, normally it just returns the bytes. Anyways, let me know what I should do there.

EDIT: Disregard this message, it now takes in the full input bytes and takes each part and feeds it.

@joshuajbouw joshuajbouw changed the title add blake2f compression add precompiles Apr 5, 2021
@joshuajbouw
Copy link
Contributor Author

Shouldn't there be checks for gas spent in something like blake2f or is that checked elsewhere?

@joshuajbouw joshuajbouw changed the title add precompiles feat: add precompiles Apr 7, 2021
@artob artob added the C-enhancement Category: New feature or request label Apr 12, 2021
@joshuajbouw joshuajbouw force-pushed the precompiles branch 3 times, most recently from 2f5a9ae to d31ee45 Compare April 20, 2021 12:49
@joshuajbouw
Copy link
Contributor Author

All precompiles are in now. I just need to find actual inputs with expected results. All the failures as per spec are caught.

@artob
Copy link
Contributor

artob commented Apr 20, 2021

All precompiles are in now. I just need to find actual inputs with expected results. All the failures as per spec are caught.

@joshuajbouw We have test cases for every Istanbul HF precompile here:

https://github.com/near/nearcore/blob/master/runtime/near-evm-runner/tests/contracts/StandardPrecompiles.sol

@joshuajbouw joshuajbouw force-pushed the precompiles branch 3 times, most recently from 9f09002 to c46bca4 Compare April 21, 2021 11:12
@joshuajbouw joshuajbouw marked this pull request as ready for review April 21, 2021 14:16
@joshuajbouw
Copy link
Contributor Author

Ok, good for review. Ther is an issue with one of the dependencies I think with the bn lib prevent it from compiling it on our test target. The code otherwise is good for review.

I put all the costs at the top of each file so that it is easier to grab and put into a config later down the line.

@artob
Copy link
Contributor

artob commented Apr 21, 2021

[There] is an issue with one of the dependencies I think with the bn lib prevent it from compiling it on our test target.

When would you expect to be able to fix that? I'd like to merge soonest, but wouldn't want to break the test target and CI.

@joshuajbouw
Copy link
Contributor Author

First thing that I'm doing tomorrow.

Copy link
Contributor

@artob artob left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Good job!

@artob artob merged commit 1993166 into master Apr 27, 2021
@artob artob deleted the precompiles branch April 27, 2021 12:12
mrLSD pushed a commit that referenced this pull request May 5, 2021
* Link to docs in the README. (#18)

* Change deprecated `u64::max_value` to `u64::MAX`. (#38)

* Support custom error messages. (#40)

* Implement `begin_chain` for evm-bully. (#30)

* Implement a faucet method. (#39)

* Implement all Istanbul HF precompiles. (#21)

* Check and increment nonces. (#42)

* Fix the RIPEMD160 and ModExp precompiles. (#44)

* Implement a first draft of `COINBASE` and `GASLIMIT`. (#47)

* Refactor and improve error handling. (#49)

* Replace `raw_call` with the new `submit` API. (#48)

The `raw_call` method is hereby removed in favor of the new `submit` method
that has an extended ABI capable of returning a transaction's revert status
and logged events.

Co-authored-by: Michael Birch <[email protected]>
Co-authored-by: Arto Bendiken <[email protected]>

* Add benchmarks for common EVM operations. (#41)

* Merge branch 'master' into improved-evm-token-logic

* Update error handling to `master`

* fix missing import

* cargo fmt

* Ensure ETH transfers return an execution result. (#48)

* Update to `master`

* fix str types

Co-authored-by: Frank Braun <[email protected]>
Co-authored-by: Michael Birch <[email protected]>
Co-authored-by: Arto Bendiken <[email protected]>
mrLSD added a commit that referenced this pull request May 5, 2021
* Added prover & extended types

* Mode Borsh args from types to parameters

* Added fungible tokens

* Added eth-connector

* Modify assert for fee

* Fix formatting

* Extend eth-conenctor with EVM token logic

* Changed eth-connector deposit logic

* Added changes for ETH deposit/withdraw and Engine changes

* Mint ETH-tokens

* Added: transfer_eth

* ETH withdraw basic method

* eth-withdraw validation structure & modified Deposit-eth fields

* eth transfer and withdraw logic

* eip712 message verifier - started encoding

* added encode-packed

* virefy EIP712 message for withdraw

* Changed EIP712 message fields

* Modify logs for EIP712 messages

* Test EIP712

* Tests EIP712

* Integration tests for encode_withdraw_eip712

* Integration tests for encode_withdraw_eip712

* EIP712-Withdraw: improvements and fixes.

* EIP712-Withdraw: fixed encoding rules and order.
* EIP712-Withdraw: `verify_withdraw_eip712` returns `true` only if the
  sender address equals to the address of message signer.
* EIP712-Withdraw: update tests.
* EIP712-Withdraw: refactoring.
* ethabit::encode_token_packed: use right-padded encoding for `Address`.
* WithdrawFromEthCallArgs: fixed `amount` type conversion.

* Extend tests for eth-connector

* eth-connector test deposit & balance & total_supply

* Imporved tests

* FT tests

* Fixed verify_transfer_eip712

* Change test_withdraw_near

* Tests for: ft_transfer, ft_transfer_call

* test_eth_deposit_balance_total_supply

* test and ifx: deposit_eth, withdraw_near

* References in fungible token (#29)

* Use references in fungible_token to avoid cloning

* cargo fmt

* Fix: hide logging behind feature flag

* Remove eth-conenctor transfer methods and deposit for new design

* Completed Deposit logic

* Fix clippy; added comments; improved ft_transfer_call

* Extend external functions for eth-connector

* Added deploy_evm_token

* Added ft_on_transfer logic

* Changed ft_on_transfer & remove json depends

* Changed deposit logic and fixed transfers

* Added register relayer

* Added message coder for ft_transfer_call

* ft_on_transfer - added logic for erc20

* Impoved ft_on_transfer

* ft_on_transfer: call erc20 contract adn send fee to Relayer. Added logs

* eth-connector: Removed unsued methods

* tests: deposit & fixed init test

* tests: depoist, withdraw

* tests: fix test_withdraw_near

* Eth-connector: never skip bridge call.

* Tests: fix ft_transfer_call

* ft_transfer_call - changed gas amountr

* Fixed: test_eth_deposit_balance_total_supply, test_ft_transfer

* Added: test_ft_transfer_call_near_eth

* Clippy fix

* Added test_ft_transfer_call_erc20

* Added test_ft_transfer_call_erc20

* tests: ft_transfer_call for ERC20 changes

* Fix finish_deposit - promise flow when failed for ft_transfer_call

* added: test_deposit_with_same_proof

* Improved EVM token master branch update (#50)

* Link to docs in the README. (#18)

* Change deprecated `u64::max_value` to `u64::MAX`. (#38)

* Support custom error messages. (#40)

* Implement `begin_chain` for evm-bully. (#30)

* Implement a faucet method. (#39)

* Implement all Istanbul HF precompiles. (#21)

* Check and increment nonces. (#42)

* Fix the RIPEMD160 and ModExp precompiles. (#44)

* Implement a first draft of `COINBASE` and `GASLIMIT`. (#47)

* Refactor and improve error handling. (#49)

* Replace `raw_call` with the new `submit` API. (#48)

The `raw_call` method is hereby removed in favor of the new `submit` method
that has an extended ABI capable of returning a transaction's revert status
and logged events.

Co-authored-by: Michael Birch <[email protected]>
Co-authored-by: Arto Bendiken <[email protected]>

* Add benchmarks for common EVM operations. (#41)

* Merge branch 'master' into improved-evm-token-logic

* Update error handling to `master`

* fix missing import

* cargo fmt

* Ensure ETH transfers return an execution result. (#48)

* Update to `master`

* fix str types

Co-authored-by: Frank Braun <[email protected]>
Co-authored-by: Michael Birch <[email protected]>
Co-authored-by: Arto Bendiken <[email protected]>

* Update src/connector.rs misspel

Co-authored-by: Joshua J. Bouw <[email protected]>

* Update src/connector.rs change constants error

Co-authored-by: Joshua J. Bouw <[email protected]>

Co-authored-by: Septen <[email protected]>
Co-authored-by: Michael Birch <[email protected]>
Co-authored-by: Joshua J. Bouw <[email protected]>
Co-authored-by: Frank Braun <[email protected]>
Co-authored-by: Arto Bendiken <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement precompiles
3 participants