-
Notifications
You must be signed in to change notification settings - Fork 88
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
Cache contract inputs in the VM #770
Conversation
panic_context, | ||
} | ||
} | ||
|
||
/// Checks that the contract is declared in the transaction inputs. | ||
pub fn check(&mut self, contract: &ContractId) -> SimpleResult<()> { | ||
if !self.tx_input_contracts.any(|input| input == contract) { | ||
if !self.input_contracts.contains(contract) { |
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.
Essentially, the idea of this PR is making this lookup more performant? Is that right?
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.
Yep
@@ -41,6 +45,33 @@ where | |||
) -> Result<(), RuntimeError<S::DataError>> { | |||
tx.prepare_init_execute(); | |||
self.tx = tx; | |||
self.input_contracts = self |
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.
So we might be taking a bit of a hit on performance because of this, but at least its constant time and not an attack vector?
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.
Yes, we calculate it each time now during initialization and later all related operations will be fast
#1973) Covers new behavior from FuelLabs/fuel-vm#770 ### Before requesting review - [x] I have reviewed the code myself
Closes #761
Updated benchmark to cover worst case FuelLabs/fuel-core#1973
Checklist
Before requesting review