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

Increase NEAR Gas for ft_on_transfer #389

Merged
merged 15 commits into from
Dec 10, 2021
Merged

Conversation

mrLSD
Copy link
Member

@mrLSD mrLSD commented Dec 9, 2021

PR related to the issue: #381

Increased NEAR Gas:

  • deposit to 80 Tgas
  • ft_on_transfer 30 TGas

Solution

The main solution is not to fix the amount of gas for promise call ft_on_transfer. For this, a formula is introduced according to which we can use more gas, depending on how much gas was initially released.

GAS_FOR_FT_ON_TRANSFER = prepaid_gas - GAS_FOR_FT_TRANSFER_CALL - GAS_FOR_RESOLVE_TRASNFER

  • added new Sdk and Env method - prepaid_gas
  • introduced a new constant GAS_FOR_FT_TRANSFER_CALL = 35 TGas. This constant indicates how much gas is allocated to make a call ft_transfer_call.
  • To invoke a ft_on_transferpromise, a formula for gas counting has been introduced:GAS_FOR_FT_ON_TRANSFER = prepaid_gas - GAS_FOR_FT_TRANSFER_CALL - GAS_FOR_RESOLVE_TRASNFER`

This will allow the use of dedicated gas for this method.

@mrLSD mrLSD added the C-enhancement Category: New feature or request label Dec 9, 2021
@mrLSD mrLSD self-assigned this Dec 9, 2021
@mrLSD mrLSD changed the base branch from master to develop December 9, 2021 14:38
@mrLSD mrLSD requested a review from birchmd December 9, 2021 14:40
engine/src/fungible_token.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@joshuajbouw joshuajbouw left a comment

Choose a reason for hiding this comment

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

This isn't the solution that was shown.

@joshuajbouw
Copy link
Contributor

Please also describe the rational and the solution to the issue outlined in #381.

Copy link
Member

@birchmd birchmd 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 pretty good to me. I think we should use a more descriptive variable name than simply gas and I think we should have a constant for the default prepaid gas value (mostly used in the standalone engine), and after that it should be good to go

engine-sdk/src/near_runtime.rs Outdated Show resolved Hide resolved
engine-standalone-storage/src/relayer_db/mod.rs Outdated Show resolved Hide resolved
engine-standalone-storage/src/sync/mod.rs Outdated Show resolved Hide resolved
engine-tests/src/test_utils/standalone/mocks/mod.rs Outdated Show resolved Hide resolved
engine-tests/src/tests/standalone/sanity.rs Outdated Show resolved Hide resolved
engine/src/connector.rs Outdated Show resolved Hide resolved
engine/src/connector.rs Outdated Show resolved Hide resolved
engine/src/fungible_token.rs Outdated Show resolved Hide resolved
engine/src/fungible_token.rs Outdated Show resolved Hide resolved
mrLSD and others added 8 commits December 9, 2021 23:05
Co-authored-by: Michael Birch <birchmd8@gmail.com>
Co-authored-by: Michael Birch <birchmd8@gmail.com>
Co-authored-by: Michael Birch <birchmd8@gmail.com>
Co-authored-by: Michael Birch <birchmd8@gmail.com>
Co-authored-by: Michael Birch <birchmd8@gmail.com>
…is-near/aurora-engine into feat/ft-on-trasnfer-increase-gas
Copy link
Member

@birchmd birchmd left a comment

Choose a reason for hiding this comment

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

Almost there!

engine-standalone-storage/src/relayer_db/mod.rs Outdated Show resolved Hide resolved
engine/src/connector.rs Outdated Show resolved Hide resolved
engine/src/fungible_token.rs Outdated Show resolved Hide resolved
mrLSD and others added 4 commits December 9, 2021 23:40
@mrLSD
Copy link
Member Author

mrLSD commented Dec 9, 2021

And you're confident it is enough to cover all mainnet use cases? Did you include some extra just to be on the safe side?
@birchmd

I changed to 35 TGas. So we can guaranty the same workflow with gas, as in the current contract.
But from Evgeny Kuzyakiv sample code, that constant is 25 TGas.

We should decide carefully that value.

Copy link
Member

@birchmd birchmd left a comment

Choose a reason for hiding this comment

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

LGTM
Nice work

Copy link
Contributor

@joshuajbouw joshuajbouw left a comment

Choose a reason for hiding this comment

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

Looks good to me here.

@joshuajbouw
Copy link
Contributor

Please squash & rebase so that I can merge. Thanks.

@mrLSD mrLSD merged commit a103714 into develop Dec 10, 2021
@mrLSD mrLSD deleted the feat/ft-on-trasnfer-increase-gas branch December 10, 2021 07:16
@joshuajbouw joshuajbouw mentioned this pull request Dec 10, 2021
artob pushed a commit that referenced this pull request Dec 10, 2021
* Feat(engine): London hard fork support (#244)
* Fix(exit precompile): Address to refund in case of error is an argument (#311)
* Feat(engine): Make engine parametric in storage access (#314)
* Test verifying the EVM log returns the correct address (#341)
* Remove sdk::current_account_id usage from engine-precompiles (#346)
* Remove Default trait bound from engine IO (#342)
* Remove some sdk usage from core logic (#347)
* Factor out blockchain environment variable access as a trait (#349)
* Factor out NEAR promise host functions into a trait (#353)
* Borsh deserialized value field for call args (#351)
* Refactor(eth-connector): Use Result return values instead of panicking (#355)
* Gate all NEAR host functions behind the contract feature (#356)
* Bump @openzeppelin/contracts from 4.3.2 to 4.3.3 in /etc/eth-contracts
* Chore: Newtypes for gas (#344)
* Feat(standalone): Standalone (#345)
* Minor fixes to sdk refactor (#359)
* Refactor(engine): Move submit logic into engine module (#366)
* Feat(standalone): Storage backend (#375)
* NEAR random numbers from solidity contract (#368)
* Feat(standalone): EVM tracing via SputnikVM (#383)
* Feat(standalone): Bootstrap storage from relayer and state snapshots (#379)
* Feat(standalone): Structures and logic for keeping storage in sync with the blockchain (#382)
* Feat(standalone): Capture geth-like tracing from SputnikVM events (#384)
* Connector cleanup (#374)
* Remove betanet
* Fix(engine): original_storage bug fix; more tracing tests (#390)
* Increase NEAR Gas for ft_on_transfer (#389)

Co-authored-by: Andrew Bednoff <andrew.bednoff@aurora.dev>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Evgeny Ukhanov <evgeny.ukhanov@aurora.dev>
Co-authored-by: Marcelo Fornet <marcelo.fornet@aurora.dev>
Co-authored-by: Michael Birch <michael.birch@aurora.dev>
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.

None yet

3 participants