-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync: fresh and existing wallets skip trial decryption (#1707)
* skip trial decryption for fresh wallets * add skip_trial_decrypt * skip trial decryption until wallet creation height * linting * remove log * gabe's suggestions * change block height field to number * changeset * [pairing] review comments --------- Co-authored-by: Gabe Rodriguez <[email protected]>
- Loading branch information
Showing
7 changed files
with
128 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@penumbra-zone/query': major | ||
'@penumbra-zone/types': major | ||
'@penumbra-zone/wasm': major | ||
--- | ||
|
||
fresh and existing wallets skip trial decryption |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { shouldSkipTrialDecrypt } from './skip-trial-decrypt.js'; | ||
|
||
describe('skipTrialDecrypt()', () => { | ||
it('should not skip trial decryption if walletCreationBlockHeight is undefined', () => { | ||
const currentHeight = 0n; | ||
const walletCreationBlockHeight = undefined; | ||
|
||
const skipTrialDecrypt = shouldSkipTrialDecrypt(walletCreationBlockHeight, currentHeight); | ||
|
||
expect(skipTrialDecrypt).toBe(false); | ||
}); | ||
it('should not skip trial decryption for genesis block when wallet creation block height is zero', () => { | ||
const currentHeight = 0n; | ||
const walletCreationBlockHeight = 0; | ||
|
||
const skipTrialDecrypt = shouldSkipTrialDecrypt(walletCreationBlockHeight, currentHeight); | ||
|
||
expect(skipTrialDecrypt).toBe(false); | ||
}); | ||
it('should skip trial decryption for genesis block when wallet creation block height is not zero', () => { | ||
const currentHeight = 0n; | ||
const walletCreationBlockHeight = 100; | ||
|
||
const skipTrialDecrypt = shouldSkipTrialDecrypt(walletCreationBlockHeight, currentHeight); | ||
|
||
expect(skipTrialDecrypt).toBe(true); | ||
}); | ||
it('should skip trial decryption for other blocks when wallet creation block height is not zero', () => { | ||
const currentHeight = 1n; | ||
const walletCreationBlockHeight = 100; | ||
|
||
const skipTrialDecrypt = shouldSkipTrialDecrypt(walletCreationBlockHeight, currentHeight); | ||
|
||
expect(skipTrialDecrypt).toBe(true); | ||
}); | ||
it('should not skip trial decryption when wallet creation block height equals current height', () => { | ||
const currentHeight = 100n; | ||
const walletCreationBlockHeight = 100; | ||
|
||
const skipTrialDecrypt = shouldSkipTrialDecrypt(walletCreationBlockHeight, currentHeight); | ||
|
||
expect(skipTrialDecrypt).toBe(false); | ||
}); | ||
it('should not skip trial decryption when wallet creation block height is greater than current height', () => { | ||
const currentHeight = 200n; | ||
const walletCreationBlockHeight = 100; | ||
|
||
const skipTrialDecrypt = shouldSkipTrialDecrypt(walletCreationBlockHeight, currentHeight); | ||
|
||
expect(skipTrialDecrypt).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Used to determine whether trial decryption should be skipped for this block | ||
export const shouldSkipTrialDecrypt = ( | ||
creationHeight: number | undefined, | ||
currentHeight: bigint, | ||
) => { | ||
if (creationHeight === undefined || creationHeight === 0) { | ||
return false; | ||
} | ||
|
||
return currentHeight < BigInt(creationHeight); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters