-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Improve getAttestationDeltas using Number #2092
Conversation
Code Climate has analyzed commit 70d9295 and detected 0 issues on this pull request. View more on Code Climate. |
This pull request introduces 1 alert when merging c135a80 into d3fadca - view on LGTM.com new alerts:
|
packages/lodestar-beacon-state-transition/src/phase0/fast/epoch/getAttestationDeltas.ts
Show resolved
Hide resolved
not able to pass spec tests using Number. Also |
What's the specific test breaking and the error message? |
This pull request introduces 1 alert when merging 3a280da into 8066c40 - view on LGTM.com new alerts:
|
nvm, it works now. Thanks @wemeetagain for the great suggestion of using |
@@ -18,14 +18,14 @@ export function processRewardsAndPenalties( | |||
const newBalances = readOnlyMap(state.balances, (balance) => balance); |
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.
As an additional optimization, you might try to apply the rewards and penalties at the same time.
eg:
const newBalances = readOnlyMap(state.balances, (balance, i) => {
const newBalance = balance + BigInt(rewards[i] - penalties[i]);
return newBalance < 0 ? BigInt(0) : newBalance;
});
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.
@wemeetagain this helps reduce the time in processRewardsAndPenalties.test.ts
~5%
439ecbc
to
dcc3574
Compare
This pull request introduces 1 alert when merging dcc3574 into 423124c - view on LGTM.com new alerts:
|
dcc3574
to
0a70311
Compare
This pull request introduces 1 alert when merging 0a70311 into 423124c - view on LGTM.com new alerts:
|
@@ -27,7 +27,7 @@ describe("Process Slots Performance Test", function () { | |||
const start = Date.now(); | |||
phase0.fast.processSlots(epochCtx, state, state.slot + numSlot); | |||
logger.profile(`Process ${numSlot} slots`); | |||
expect(Date.now() - start).lt(1100); | |||
expect(Date.now() - start).lt(570); |
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.
with new ssz + this PR, the new epoch transition takes 500ms - 600ms in average instead of ~1100ms as previously
part of #2046 #2049
getAttestationDeltas
getAttestationDeltas
was reduced from 130 to 79