Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/params/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions packages/params/test/unit/applicationDomains.test.ts
Original file line number Diff line number Diff line change
@@ -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`);
});
});
});