diff --git a/packages/params/src/index.ts b/packages/params/src/index.ts index 09cb4d24f772..9298fed97a8d 100644 --- a/packages/params/src/index.ts +++ b/packages/params/src/index.ts @@ -118,7 +118,17 @@ export const DOMAIN_SYNC_COMMITTEE = Uint8Array.from([7, 0, 0, 0]); export const DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF = Uint8Array.from([8, 0, 0, 0]); export const DOMAIN_CONTRIBUTION_AND_PROOF = Uint8Array.from([9, 0, 0, 0]); +// Application specfic domains + +/** + * `DOMAIN_APPLICATION_MASK` reserves the rest of the bitspace in `DomainType` for application + * usage. This means for some `DomainType` `DOMAIN_SOME_APPLICATION`, `DOMAIN_SOME_APPLICATION + * & DOMAIN_APPLICATION_MASK` **MUST** be non-zero. This expression for any other `DomainType` + * in the consensus specs **MUST** be zero. + */ +export const DOMAIN_APPLICATION_MASK = Uint8Array.from([0, 0, 0, 1]); export const DOMAIN_APPLICATION_BUILDER = Uint8Array.from([0, 0, 0, 1]); + // Participation flag indices export const TIMELY_SOURCE_FLAG_INDEX = 0; diff --git a/packages/params/test/unit/applicationDomains.test.ts b/packages/params/test/unit/applicationDomains.test.ts new file mode 100644 index 000000000000..5ccc4177bd59 --- /dev/null +++ b/packages/params/test/unit/applicationDomains.test.ts @@ -0,0 +1,14 @@ +import {expect} from "chai"; +import {DOMAIN_APPLICATION_MASK, DOMAIN_APPLICATION_BUILDER} from "../../src/index.js"; + +describe("validate application domains", async () => { + [{name: "builder domain", domain: DOMAIN_APPLICATION_BUILDER}].map(({name, domain}) => { + it(name, () => { + let r = 0; + for (let i = 0; i < DOMAIN_APPLICATION_MASK.length; i++) { + r += DOMAIN_APPLICATION_MASK[i] & domain[i]; + } + expect(r > 0).to.equal(true, `${name} mask application should be valid`); + }); + }); +});