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

feat: optimize gas usage #39

Merged
merged 16 commits into from
Aug 22, 2023
Merged

Conversation

zsystm
Copy link

@zsystm zsystm commented Aug 21, 2023

Description


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • included the necessary unit and integration tests
  • reviewed "Files changed" and left comments if necessary

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@zsystm zsystm self-assigned this Aug 21, 2023
@zsystm zsystm marked this pull request as ready for review August 21, 2023 08:17
@zsystm zsystm requested a review from dongsam August 21, 2023 08:17
Comment on lines 58 to 59
iValidator := validatorMap[iInsurance.GetValidator().String()]
jValidator := validatorMap[jInsurance.GetValidator().String()]
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why you had to change it like this?

Copy link
Author

@zsystm zsystm Aug 21, 2023

Choose a reason for hiding this comment

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

@dongsam

No special reason for this.
I just thought GetValidator().String() is more uniform than insurance.ValidatorAddress because when create validatorMap in GetNetAmountStateEssentials, it uses GetValidator().String() as a key.

But, I saw that both GetValidator().String() and insurance.ValidatorAddress are used in liquidstaking module's code.
Both values are same, so it would be great to unify that usage in code base for readability.

Copy link
Member

Choose a reason for hiding this comment

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

GetValidator() eventually computes using insurance.ValidatorAddress, and already has the resulting string in the insurance.ValidatorAddress, it doesn't seem necessary to compute it again

Copy link
Author

@zsystm zsystm Aug 21, 2023

Choose a reason for hiding this comment

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

@dongsam
Oh.. I see why u comment for it.
I got it! Thanks for the detail.

I'll check other GetValidator usages too and fix that(=duplicated computation). Thanks!

Copy link
Author

@zsystm zsystm Aug 21, 2023

Choose a reason for hiding this comment

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

@dongsam
updated it! 8b66c5c

the reason why tests failed yesterday is that I changed the line to !=. It must be equal, so the logic was broken. But now it is fixed (using ==).

GetValidator().String is a redundant computation. We can just use ValidatorAddress field.
@zsystm zsystm requested a review from dongsam August 22, 2023 00:26
@zsystm zsystm merged commit 8bcc92c into liquidstaking-module Aug 22, 2023
9 checks passed
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.

feat: gas optimization
2 participants