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

Metapool contract update needed due to increased deployment cost #21

Closed
jakmeier opened this issue Mar 9, 2022 · 8 comments
Closed
Assignees

Comments

@jakmeier
Copy link

jakmeier commented Mar 9, 2022

Deployment costs per byte of code are going to be increased by a factor of ~5 with this change to NEAR protocol: near/nearcore#6397

Probably this will happen with protocol version 53, which would be released on testnet by March 23 and on mainnet by April 20.

I listed all the indirect deployments from the past that would fail with the new cost. Deployments of meta-pool.near have showed up 10 times in this list, for example this transaction. Meaning that your current setup for redeploying might break with the planned increase of deployment cost.

It looks like migration currently reserves exactly 20Tgas, as defined here.

const GAS_FOR_UPGRADE: u64 = 20 * TGAS; //gas occupied by this fn

Now, I don't know how large your contract is exactly, which is the key factor. 20Tgas is only enough to cover deployment of a 274kB contract under the new costs. And not all 20Tgas is actually available, some will be used for executing the function. So the real maximum contract size will be smaller.

Please check if my understanding is correct that this will break you remote-update mechanism and if you can update your deployed contract before the protocol version 53 is released. I am not familiar with all the details of your contract but I am happy to assist in solving any problems caused by this. I am also available to answer any questions you might have, for example on Zulip

@jakmeier jakmeier changed the title Metapool contract update needed due to increased deployment Metapool contract update needed due to increased deployment cost Mar 9, 2022
@fercargo
Copy link
Contributor

fercargo commented Apr 13, 2022

We checked and the WASM size is 530,958
@jakmeier is this documentation correct? https://docs.near.org/docs/concepts/gas#deploying-contracts
I guess it is not updated? because it looks like the new deploy_contract_cost_per_byte.execution is 64572944
anyhow, with that number, I don't get to the same number as you:
You said that 20TGAS is enough for 274000 bytes, but
(2 * 184765750000 + 2 * 274000 * 64572944 + 2 * 108059500000)/1e12 = 35.97 TGAS, not 20

@fercargo
Copy link
Contributor

@jakmeier can you tell me if this change will fix the problem? ca80ca6

@fercargo
Copy link
Contributor

fercargo commented Apr 13, 2022

ok, looks like the new deploy_contract_cost_per_byte.execution is 64572944 ?
We tested an upgrade on testnet, the contract size is 143843,
(2 * 184765750000 + 2 * 143843 * 64572944 + 2 * 108059500000)/1e12 = 19.16 TGAS
but the upgrade call in testnet burned only 7 TGAS
https://explorer.testnet.near.org/transactions/8WcuHvehUjQautMGUthBNXoDDfKJiNK3BN1Cce4gfFrD#6yW7EYuY3uvsS1desq8RqiXVRbVjTPdRbTsg7qPbgk9i

@jakmeier
Copy link
Author

Let me add the missing information.

  1. Our releases have been rescheduled, this change is not on testnet, yet. Protocol version 53 will be in release 1.26.0 which is released on April 20. The source of truth for this is the NEAR Community Calendar.
  2. Documentation on docs.near.org is still in the state of current mainnet. It needs to be updated. (Thanks for pointing it out!)
  3. The exact new cost is defined in 53.json. The base is unchanged. The cost per byte is 6_812_999 gas for sending and 64_572_944 gas for executing. Only the last number is new.

Taking this information that you didn't have before into account, the formula is
(2 * 184765750000 + contract_size * (6812999 + 64572944) + 2 * 108059500000)
Thus, with 274kB: (2 * 184765750000 + 274000 * (6812999 + 64572944) + 2 * 108059500000)/1e12 = 20.14 Tgas
And with 530,958B: (2 * 184765750000 + 530958 * (6812999 + 64572944) + 2 * 108059500000)/1e12 = 38.49 Tgas

Regarding your WIP fix, I believe this should work but please test again after April 20.

@fercargo
Copy link
Contributor

Thanks!

@fercargo fercargo self-assigned this Apr 13, 2022
@The-Preem-Palver
Copy link
Contributor

@jakmeier can you tell us when Protocol version 53 will be deployed in mainnet?

@jakmeier
Copy link
Author

Sure! It is part of release 1.26, which is scheduled for Wednesday, May 18.
I do not foresee any changes to that schedule but generally speaking, the living source of truth for releases is the NEAR Community Calendar.

Note that this is the date when validators start to upgrade their clients. It will take a couple more days until enough of them vote to actually used the new version for new blocks. When exactly that happens I cannot say, it's up to the validators.

@The-Preem-Palver
Copy link
Contributor

ok, thanks, we will upgrade the contract with the fixes today

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

No branches or pull requests

3 participants