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(engine): Hashchain integration #831

Merged
merged 2 commits into from
Sep 1, 2023

Conversation

birchmd
Copy link
Member

@birchmd birchmd commented Aug 30, 2023

Description

This PR integrates the hashchain feature into the Aurora Engine contract (see aurora-is-near/AIPs#8). This change is fully backwards compatible because by default there is no hashchain present in the contract state and therefore no hashchain computation is done.

The method to activate the hashchain is start_hashchain requires the contract to be paused and can only be called by a privileged account (I chose to use the key manager instead of introducing a new role). These restrictions are necessary because the hashchain is initialized with a value based on the Engine's transaction history (to enable validating Aurora blocks starting from the deployment of the contract).

Performance / NEAR gas cost considerations

After activating the hashchain there will be a small increase in gas usage because of the hashchain computation. It's not very much for most transactions (as seen in the performance regression tests), but the amount of gas is proportional to the size of the input + output of the transaction (because we compute a hash from this data).

Testing

The tests have been changed to enable the hashchain by default. Therefore all existing tests are running the hashchain code and testing that the Wasm and Standalone results match (this is important because the Refiner will be computing hashchain values off-chain using the Standalone Engine). An additional test has been added for the hashchain feature itself.

Additional information

Note: the diff in contract_methods is relatively large, but the code changes are minimal. All that happened is the existing function bodies were wrapped in with_hashchain, which changed the indentation. Viewing the PR with whitespace changes ignored may make this section easier to review.

@birchmd birchmd added C-enhancement Category: New feature or request A-standalone Area: the standalone engine EVM A-engine Area: purely engine EVM related labels Aug 30, 2023
@aleksuss aleksuss requested a review from mrLSD August 31, 2023 11:59
Copy link
Member

@aleksuss aleksuss left a comment

Choose a reason for hiding this comment

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

Amazing work 👍🏻

Copy link
Member

@mrLSD mrLSD left a comment

Choose a reason for hiding this comment

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

LGTM!

@birchmd birchmd added this pull request to the merge queue Sep 1, 2023
Merged via the queue into develop with commit 71980db Sep 1, 2023
20 checks passed
@birchmd birchmd deleted the feat/birchmd/hashchain-integration branch September 1, 2023 17:35
@birchmd birchmd mentioned this pull request Sep 1, 2023
aleksuss pushed a commit that referenced this pull request Sep 25, 2023
## Description

This PR integrates the hashchain feature into the Aurora Engine contract
(see aurora-is-near/AIPs#8). This change is
fully backwards compatible because by default there is no hashchain
present in the contract state and therefore no hashchain computation is
done.

The method to activate the hashchain is `start_hashchain` requires the
contract to be paused and can only be called by a privileged account (I
chose to use the key manager instead of introducing a new role). These
restrictions are necessary because the hashchain is initialized with a
value based on the Engine's transaction history (to enable validating
Aurora blocks starting from the deployment of the contract).

## Performance / NEAR gas cost considerations

After activating the hashchain there will be a small increase in gas
usage because of the hashchain computation. It's not very much for most
transactions (as seen in the performance regression tests), but the
amount of gas is proportional to the size of the input + output of the
transaction (because we compute a hash from this data).

## Testing

The tests have been changed to enable the hashchain by default.
Therefore all existing tests are running the hashchain code and testing
that the Wasm and Standalone results match (this is important because
the Refiner will be computing hashchain values off-chain using the
Standalone Engine). An additional test has been added for the hashchain
feature itself.

## Additional information

Note: the diff in `contract_methods` is relatively large, but the code
changes are minimal. All that happened is the existing function bodies
were wrapped in `with_hashchain`, which changed the indentation. Viewing
the PR with whitespace changes ignored may make this section easier to
review.
@aleksuss aleksuss mentioned this pull request Sep 25, 2023
aleksuss added a commit that referenced this pull request Sep 25, 2023
- Added the possibility to use native NEAR instead of wNEAR on Aurora by
[@karim-en]. ([#750])

- Added hashchain integration by [@birchmd]. ([#831])

- Added functions for setting and getting metadata of ERC-20 contracts
deployed with `deploy_erc20_token` transaction
  by [@aleksuss]. ([#837])

---------

Co-authored-by: Michael Birch <michael.birch@aurora.dev>
Co-authored-by: Evgeny Ukhanov <evgeny@aurora.dev>
Co-authored-by: Karim <karim@aurora.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-engine Area: purely engine EVM related A-standalone Area: the standalone engine EVM C-enhancement Category: New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants