-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Conversation
There was a problem hiding this 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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
fc58f0a
to
c24142d
Compare
c24142d
to
2572424
Compare
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.