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

Optimise gas usage during the upgrade process #147

Merged
merged 12 commits into from
Apr 5, 2022

Conversation

ctindogaru
Copy link
Collaborator

This PR is trying to address #135.

@@ -7,13 +7,13 @@ use near_sdk::serde_json;
use near_sdk::{env, sys, AccountId, Balance, CryptoHash, Gas};

/// Gas spent on the call & account creation.
const CREATE_CALL_GAS: Gas = Gas(75_000_000_000_000);
const CREATE_CALL_GAS: Gas = Gas(50_000_000_000_000);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this can be decreased even further. Could probably go for 30-40.

Copy link
Contributor

Choose a reason for hiding this comment

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

Im not sure i 100% agree here. Since the protocol refunds overspend on gas, its safer to attach more, in this case we dont know 100% of times will work given large policy from start.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are you not happy with 50 or with a value lower than 50?

I'm not sure if a larger policy would consume more gas? It makes sense to consume more storage, but is the gas affected as well? Shouldn't be and if it is, I think the impact is pretty low...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not 100% sure here either, you made a valid point

Copy link
Contributor

Choose a reason for hiding this comment

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

Been having a solid think on this:
As I have deployed DAOs from other DAOs and within other batch calls, even the previous 75Tgas was plenty to get through. Even at 75Tgas, i have seen an avg of 5-25Tgas based on the policy tests i've done. This is not the maximum size a policy can be however - so maybe a little R&D is needed to find the absolute policy size at creation.
Here's what I'd like to see:
Can you create a test case with a large amount of groups AND/OR a large amount of council accounts?
That should give us a clear indication of how big the gas needs to be.

Copy link
Contributor

Choose a reason for hiding this comment

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

I say all this, assuming your estimations on gas all relate to default policy

Copy link
Collaborator Author

@ctindogaru ctindogaru Mar 30, 2022

Choose a reason for hiding this comment

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

We can increase the Tgas to 30-40. It's still low enough to cover the new deployment costs and big enough to cover most of the policies. If a policy consumes more than 30-40, the DAO creator can create the policy slimmer at first and then add new roles after the DAO is created. How does that sound to you?

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds fair. Can you add a test that incorporates a large policy and update the gas to 40?

@@ -7,13 +7,13 @@ use near_sdk::serde_json;
use near_sdk::{env, sys, AccountId, Balance, CryptoHash, Gas};

/// Gas spent on the call & account creation.
const CREATE_CALL_GAS: Gas = Gas(75_000_000_000_000);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was absurd. A simple new call to create a DAO does not require more than 5_000_000_000_000 gas. However, I've doubled it to 10_000_000_000_000 just to be safe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to 40TGas to cover large policies.

@TrevorJTClarke
Copy link
Contributor

Thank you for this!!

@TrevorJTClarke TrevorJTClarke merged commit 32ca00a into near-daos:main Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready For QA
Development

Successfully merging this pull request may close these issues.

2 participants