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

Optimize & cleanup #427

Merged
merged 9 commits into from
Nov 28, 2023
Merged

Conversation

siddharthteli12
Copy link
Contributor

One more pr in reference to #421

@imstar15
Copy link
Member

Looks good to me!

@@ -306,8 +306,8 @@ benchmarks! {
let collator: T::AccountId = account("collator", 0, SEED);
let account_minimum = T::Currency::minimum_balance().saturating_mul(ED_MULTIPLIER.into());

T::Currency::deposit_creating(&delegator, (10_000_000_000_000_000 as u128).saturated_into());
T::Currency::deposit_creating(&collator, (100_000_000_000_000_000 as u128).saturated_into());
T::Currency::deposit_creating(&delegator, (10_000_000_000_000_000_u128).saturated_into());
Copy link
Member

Choose a reason for hiding this comment

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

since you're here, we can take this change to move these value into const

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean, We should declare 10_000_000_000_000_000_u128 as const?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's more for code readable. such as on line 307, the code looks very nice.

T::Currency::minimum_balance().saturating_mul(ED_MULTIPLIER.into())

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 value is used only once. Declaring it as a const would just increase the overhead in my opinion.

Copy link
Member

@v9n v9n left a comment

Choose a reason for hiding this comment

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

looks good general.

I suggest to not use macro unless it makes our code way more clean and easy to read.
there is some minor optimize i think we can also take in this PR.

},
_ => (),
};
if let Action::XCMP { execution_fee, instruction_sequence, .. } = action.clone() {
Copy link
Member

Choose a reason for hiding this comment

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

because we're moving into if, can you see if we can switch to early return instead to avoid one more nested for the happy path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like it's not possible, at least without functional changes I believe.

pallets/automation-time/src/mock.rs Outdated Show resolved Hide resolved
pallets/automation-time/src/tests.rs Outdated Show resolved Hide resolved
@@ -249,8 +249,6 @@ impl<AccountId: Clone, Balance> Task<AccountId, Balance> {
instruction_sequence: InstructionSequence,
abort_errors: Vec<Vec<u8>>,
) -> Result<Self, DispatchError> {
let destination =
MultiLocation::try_from(destination).map_err(|_| Error::<T>::BadVersion)?;
Copy link
Member

Choose a reason for hiding this comment

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

I think this is necessary? cc @imstar15 for extra 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@v9n, Not in this case I believe. But yeah, it was necessary when destination's type was VersionedMultiLocation. For eg - https://github.com/OAK-Foundation/OAK-blockchain/blob/cf4a6eadc6a12fa02153434f71d34bf3e6bf9ac0/pallets/automation-time/src/lib.rs#L387-L388

runtime/neumann/src/lib.rs Outdated Show resolved Hide resolved
runtime/neumann/src/lib.rs Outdated Show resolved Hide resolved
runtime/oak/src/lib.rs Outdated Show resolved Hide resolved
@v9n
Copy link
Member

v9n commented Sep 22, 2023

@siddharthteli12 we're working on some other stuff and prefer to wait for this a bit. will get to your PR eventually. thanks for your contribution

@siddharthteli12
Copy link
Contributor Author

@v9n @imstar15 , Its ready for review. I believe we can merge this pr now as it's been pending for a while now.

@v9n
Copy link
Member

v9n commented Nov 20, 2023

Hi @siddharthteli12 sorry for delay. I'm doing a final check now then will let you know. Can you check the new conflict? I will review asap and get this PR merged after that

@siddharthteli12
Copy link
Contributor Author

@v9n , Resolved the conflict.

Copy link
Member

@v9n v9n left a comment

Choose a reason for hiding this comment

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

looks good. thank @siddharthteli12

@chrisli30
Copy link
Member

Thank you both. The PR is sync’ed with main so I’m merging it.

@chrisli30 chrisli30 merged commit 12c9953 into AvaProtocol:master Nov 28, 2023
2 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.

4 participants