mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
Accept BIP320 version rolling in SV2 shares
This commit is contained in:
@@ -991,7 +991,7 @@ describe('StratumV2Client extended channels', () => {
|
|||||||
.toBe(parseInt(activation.bits, 16));
|
.toBe(parseInt(activation.bits, 16));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates fixed/rolling versions, required bits, and the advertised minimum nTime', async () => {
|
it('validates BIP320 version rolling, required bits, and the advertised minimum nTime', async () => {
|
||||||
const { client } = await createClient();
|
const { client } = await createClient();
|
||||||
const now = process.hrtime.bigint();
|
const now = process.hrtime.bigint();
|
||||||
const context = {
|
const context = {
|
||||||
@@ -1007,11 +1007,12 @@ describe('StratumV2Client extended channels', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
expect((client as any).isSubmissionHeaderValid(context, 0x20000004, 100)).toBe(true);
|
expect((client as any).isSubmissionHeaderValid(context, 0x20000004, 100)).toBe(true);
|
||||||
expect((client as any).isSubmissionHeaderValid(context, 0x20002004, 100)).toBe(false);
|
expect((client as any).isSubmissionHeaderValid(context, 0x20002004, 100)).toBe(true);
|
||||||
expect((client as any).isSubmissionHeaderValid(context, 0x20000004, 99)).toBe(false);
|
expect((client as any).isSubmissionHeaderValid(context, 0x20000004, 99)).toBe(false);
|
||||||
expect((client as any).isSubmissionHeaderValid(context, 0x20000004, 101)).toBe(true);
|
expect((client as any).isSubmissionHeaderValid(context, 0x20000004, 101)).toBe(true);
|
||||||
expect((client as any).isSubmissionHeaderValid(context, 0x20000004, 0xffffffff)).toBe(true);
|
expect((client as any).isSubmissionHeaderValid(context, 0x20000004, 0xffffffff)).toBe(true);
|
||||||
expect((client as any).isSubmissionHeaderValid(context, 0x20000004, 0x1_0000_0000)).toBe(false);
|
expect((client as any).isSubmissionHeaderValid(context, 0x20000004, 0x1_0000_0000)).toBe(false);
|
||||||
|
expect((client as any).isSubmissionHeaderValid(context, 0x00000004, 100)).toBe(false);
|
||||||
|
|
||||||
(client as any).versionRollingEnabled = true;
|
(client as any).versionRollingEnabled = true;
|
||||||
expect((client as any).isSubmissionHeaderValid(context, 0x20002004, 100)).toBe(true);
|
expect((client as any).isSubmissionHeaderValid(context, 0x20002004, 100)).toBe(true);
|
||||||
|
|||||||
@@ -2088,11 +2088,11 @@ export class StratumV2Client {
|
|||||||
): boolean {
|
): boolean {
|
||||||
const submitted = submittedVersion >>> 0;
|
const submitted = submittedVersion >>> 0;
|
||||||
const base = headerContext.baseVersion >>> 0;
|
const base = headerContext.baseVersion >>> 0;
|
||||||
if (this.versionRollingEnabled) {
|
// Some SV2 clients roll BIP320 general-purpose version bits even when
|
||||||
if (((submitted ^ base) & BIP320_CONSENSUS_VERSION_MASK) !== 0) {
|
// they did not explicitly require version rolling during setup. Those
|
||||||
return false;
|
// bits are non-consensus signalling space; reject only changes outside
|
||||||
}
|
// that mask and continue enforcing required bits below.
|
||||||
} else if (submitted !== base) {
|
if (((submitted ^ base) & BIP320_CONSENSUS_VERSION_MASK) !== 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((submitted & headerContext.requiredVersionBits) !== headerContext.requiredVersionBits) {
|
if ((submitted & headerContext.requiredVersionBits) !== headerContext.requiredVersionBits) {
|
||||||
|
|||||||
Reference in New Issue
Block a user