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

validate that the node is rented if gpu is enabled #3954

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export default {
const nodeInputValidateTask = useAsync<boolean, string, [NodeInfo | undefined]>(
async node => {
const nodeCapacityValid = await checkNodeCapacityPool(gridStore, node, props.filters);
const rentContractValid = await validateRentContract(gridStore, node);
const rentContractValid = await validateRentContract(gridStore, node, props.filters.hasGPU);

if (node && !isNodeValid(props.getFarm, node!, props.selectedMachines, filters.value)) {
throw `Node (${node.nodeId}) is not valid.`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,7 @@ export default {
case props.filters.dedicated && !node.dedicated:
throw `Node ${nodeId} is not dedicated`;

case props.filters.dedicated && node.rentedByTwinId === 0:
throw `Node ${nodeId} is not rented`;

case props.filters.dedicated && node.rentedByTwinId !== gridStore.client.twinId:
case props.filters.dedicated && node.rentedByTwinId && node.rentedByTwinId !== gridStore.client.twinId:
throw `Node ${nodeId} is Dedicated, but rented by someone else`;

case node.rentedByTwinId !== 0 && node.rentedByTwinId !== gridStore.client.twinId:
Expand Down Expand Up @@ -223,7 +220,7 @@ export default {
throw `Node ${nodeId} doesn't have enough Storage`;
}

await validateRentContract(gridStore, node);
await validateRentContract(gridStore, node, props.filters.hasGPU);
await checkNodeCapacityPool(gridStore, node, props.filters);

if (props.filters.ipv4) {
Expand Down
6 changes: 5 additions & 1 deletion packages/playground/src/utils/nodeSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,20 @@ export function loadNodes(gridStore: ReturnType<typeof useGrid>, filters: Filter
export async function validateRentContract(
gridStore: ReturnType<typeof useGrid>,
node: NodeInfo | undefined | null,
hasGpu?: boolean | undefined,
): Promise<true> | never {
if (!node || !node.nodeId) {
throw "Node ID is required.";
}
if (node.dedicated && node.rentedByTwinId === 0 && !node.inDedicatedFarm) return true;
if (node.dedicated && node.rentedByTwinId === 0 && !node.inDedicatedFarm && !hasGpu) return true;

try {
if (node.dedicated && node.rentedByTwinId === 0 && node.inDedicatedFarm) {
throw `Node ${node.nodeId} is not rented`;
}
if (node.dedicated && node.rentedByTwinId === 0 && hasGpu) {
throw `You have to rent node ${node.nodeId} before you can use its GPU capabilities`;
}
if (node.rentContractId !== 0) {
const { state } = await gridStore.grid.contracts.get({
id: node.rentContractId,
Expand Down
Loading