Skip to content
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

fix: remove protocol version validation from config #1106

Merged
merged 2 commits into from
Feb 6, 2025
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
28 changes: 0 additions & 28 deletions packages/cli/package/src/lib/chain/chainValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,3 @@ export async function getProtocolVersions() {

return protocolVersions;
}

export async function validateProtocolVersion(
protocolVersion: number,
): Promise<ValidationResult> {
const { minProtocolVersion, maxProtocolVersion } =
await getProtocolVersions();

if (
protocolVersion < minProtocolVersion ||
protocolVersion > maxProtocolVersion
) {
const minProtocolVersionStr = bigintToStr(minProtocolVersion);

if (minProtocolVersion === maxProtocolVersion) {
return `Protocol version must be equal to ${color.yellow(
minProtocolVersionStr,
)}. Got: ${color.yellow(protocolVersion)}`;
}

return `Protocol version must be ${color.yellow(
`>=${minProtocolVersionStr}`,
)} and ${color.yellow(`<=${minProtocolVersionStr}`)}. Got: ${color.yellow(
protocolVersion,
)}`;
}

return true;
}
58 changes: 0 additions & 58 deletions packages/cli/package/src/lib/configs/project/provider/provider3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import type { JSONSchemaType } from "ajv";
import isEmpty from "lodash-es/isEmpty.js";
import mapValues from "lodash-es/mapValues.js";

import { versions } from "../../../../versions.js";
import {
ccDurationValidator,
validateAddress,
validateProtocolVersion,
} from "../../../chain/chainValidators.js";
import {
PROVIDER_CONFIG_FULL_FILE_NAME,
Expand Down Expand Up @@ -172,66 +170,10 @@ export default {
validateCC(config),
validateMissingComputePeers(config),
validateNoDuplicateNoxNamesInOffers(config),
validateProtocolVersions(config),
);
},
} satisfies ConfigOptions<PrevConfig, Config>;

async function validateProtocolVersions(providerConfig: Config) {
const errors = (
await Promise.all(
Object.entries(providerConfig.offers).flatMap(
([
offer,
{
maxProtocolVersion = versions.protocolVersion,
minProtocolVersion = versions.protocolVersion,
},
]) => {
return [
Promise.resolve({
offer,
property: "minProtocolVersion or maxProtocolVersion",
validity:
minProtocolVersion > maxProtocolVersion
? `minProtocolVersion must be less than or equal to maxProtocolVersion. Got: minProtocolVersion=${color.yellow(
minProtocolVersion,
)} maxProtocolVersion=${color.yellow(maxProtocolVersion)}`
: true,
}),
...(
[
["minProtocolVersion", minProtocolVersion],
["maxProtocolVersion", maxProtocolVersion],
] as const
).map(async ([property, v]) => {
return {
offer,
property,
validity: await validateProtocolVersion(v),
};
}),
];
},
),
)
).filter((a): a is typeof a & { validity: string } => {
return a.validity !== true;
});

if (errors.length > 0) {
return errors
.map(({ offer, property, validity }) => {
return `Offer ${color.yellow(offer)} has invalid ${color.yellow(
property,
)} property: ${validity}`;
})
.join("\n");
}

return true;
}

function validateNoDuplicateNoxNamesInOffers(config: Config): ValidationResult {
const noxNamesInOffers: Record<string, string[]> = {};

Expand Down
Loading