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

Check transfer gas cost upfront #912

Merged
merged 1 commit into from
Mar 18, 2022
Merged

Check transfer gas cost upfront #912

merged 1 commit into from
Mar 18, 2022

Conversation

lxfind
Copy link
Contributor

@lxfind lxfind commented Mar 17, 2022

In the current implementation, during handle_transaction, we only check that the gas object has some minimum amount of balance, and if in the end it's not enough to pay for the transfer, we fail at the confirmation step.
This is unnecessary. Object transfer has deterministic cost that we can determine upfront.
This PR changes the check of gas requirement for Transfer to compute the Transfer cost directly and check it against the balance. This requires accessing the transfer object, so the code is moved around to make this possible.

Copy link
Collaborator

@gdanezis gdanezis left a comment

Choose a reason for hiding this comment

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

See broader question about the gas check.

@@ -204,6 +198,25 @@ impl AuthorityState {
Ok(())
}

fn check_gas_requirement(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a question: are we not eventually have each transaction specify what is the maximum upper gas limit, and check that the gas object meets this limit (and also a conversion rate to SUI). This is what I assumed we would be doing. This means that we always know ahead of time what to check (ie. has the gas object at least this upper limit) and then later we can check if that limit is somehow exceeded.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@sblackshear probably has a view on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Transfer transaction currently doesn't have a gas budget. But it seems reasonable to add it.

Copy link
Collaborator

@gdanezis gdanezis Mar 18, 2022

Choose a reason for hiding this comment

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

That is probably the one for which this is a trivial constant? As you leverage in the PR I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am pretty sure this is bad/wrong: today the gas cost of a transfer is proportional to the size of the object :p

@lxfind lxfind force-pushed the check-transfer-gas-upfront branch 2 times, most recently from fc58f0a to c24142d Compare March 18, 2022 17:19
@lxfind lxfind force-pushed the check-transfer-gas-upfront branch from c24142d to 2572424 Compare March 18, 2022 17:32
@lxfind lxfind merged commit 704e9ab into main Mar 18, 2022
@lxfind lxfind deleted the check-transfer-gas-upfront branch March 18, 2022 17:54
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

Successfully merging this pull request may close these issues.

2 participants