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

chore(smart-contracts): update ABI #47

Merged
merged 11 commits into from
Dec 4, 2023
8 changes: 4 additions & 4 deletions abi/IJobRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const IJobRepositoryAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -297,7 +297,7 @@ export const IJobRepositoryAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -569,7 +569,7 @@ export const IJobRepositoryAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -854,7 +854,7 @@ export const IJobRepositoryAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down
10 changes: 5 additions & 5 deletions abi/JobRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export const JobRepositoryAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -413,7 +413,7 @@ export const JobRepositoryAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -754,7 +754,7 @@ export const JobRepositoryAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -1038,7 +1038,7 @@ export const JobRepositoryAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -1344,7 +1344,7 @@ export const JobRepositoryAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down
4 changes: 2 additions & 2 deletions abi/MetaScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export const MetaSchedulerAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -821,7 +821,7 @@ export const MetaSchedulerAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down
8 changes: 4 additions & 4 deletions abi/Tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const ToolsAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -192,7 +192,7 @@ export const ToolsAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -346,7 +346,7 @@ export const ToolsAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down Expand Up @@ -605,7 +605,7 @@ export const ToolsAbi =
[
{
"internalType": "uint64",
"name": "gpusPerTask",
"name": "gpus",
"type": "uint64"
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@apollo/client": "^3.8.7",
"@apollo/server": "^4.9.5",
"@as-integrations/next": "^3.0.0",
"@deepsquare/deepsquare-client": "^0.15.0",
"@deepsquare/deepsquare-client": "0.16.0",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@hookform/resolvers": "^2.9.11",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/app/blender/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ export default function BlenderPage() {
outputFormat: BlenderOutputFormat.PNG,
renderEngine: BlenderRenderEngine.CYCLES,
nTasks: 1,
cpuPerTask: 8,
cpusPerTask: 8,
memPerCpu: 6000,
gpuPerTask: 1,
gpusPerTask: 1,
},
jobName: `${WorkloadType.BLENDER} - ${generate({ exactly: 3, maxLength: 4 })?.join(' ') ?? ''}`,
},
Expand Down Expand Up @@ -153,7 +153,7 @@ export default function BlenderPage() {
<>
<Grid item xs={1}>
<h4 className="m-0 font-normal">CPU per task</h4>
<NumberField name="details.cpuPerTask" control={control} type="number" defaultValue={4} />
<NumberField name="details.cpusPerTask" control={control} type="number" defaultValue={4} />
</Grid>
<Grid item xs={1}>
<h4 className="m-0 font-normal">Memory per CPU (MB)</h4>
Expand All @@ -178,8 +178,8 @@ export default function BlenderPage() {
</Card>
<CreditSubform
gpuQty={watch('details.nTasks')}
cpuQty={watch('details.nTasks')! * watch('details.cpuPerTask')!}
memQty={watch('details.nTasks')! * watch('details.cpuPerTask')! * watch('details.memPerCpu')!}
cpuQty={watch('details.nTasks')! * watch('details.cpusPerTask')!}
memQty={watch('details.nTasks')! * watch('details.cpusPerTask')! * watch('details.memPerCpu')!}
/>
<SendButton>Render</SendButton>
</div>
Expand Down
6 changes: 1 addition & 5 deletions src/app/sandbox/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,7 @@ const SandboxPage: NextPage = () => {

<CreditSubform
defaultDuration={20}
gpuQty={
json?.resources?.tasks && json?.resources?.gpusPerTask
? json.resources.tasks * json.resources.gpusPerTask
: undefined
}
gpuQty={json?.resources?.gpus}
cpuQty={
json?.resources?.tasks && json?.resources?.cpusPerTask
? json.resources.tasks * json.resources.cpusPerTask
Expand Down
12 changes: 6 additions & 6 deletions src/app/status/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,10 @@ const StatusPage: NextPage = withConnectionRequired(() => {
dayjs(Number(value.time.start * 1000n)),
'minutes',
)}{' '}
min × {value.definition.ntasks.toString()} tasks ×
min × &#91; {value.definition.ntasks.toString()} tasks ×
</div>
<div>
&#40; {value.definition.gpusPerTask.toString()} GPU/task ×{' '}
{formatCredit(value.provider.providerPrices.gpuPricePerMin)} credits/(GPU.min)
</div>
<div>
+ {value.definition.cpusPerTask.toString()} CPU/task ×{' '}
&#40; {value.definition.cpusPerTask.toString()} CPU/task ×{' '}
{formatCredit(value.provider.providerPrices.cpuPricePerMin)} credits/(CPU.min)
</div>
<div>
Expand All @@ -381,6 +377,10 @@ const StatusPage: NextPage = withConnectionRequired(() => {
})}{' '}
credits/(GB.min) &#41;
</div>
<div>
+ {value.definition.gpus.toString()} GPU × {formatCredit(value.provider.providerPrices.gpuPricePerMin)}{' '}
credits/(GPU.min) &#93;
</div>
</div>
</Popover>
)}
Expand Down
8 changes: 4 additions & 4 deletions src/app/texttoimage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ const TextToImagePage: NextPage = () => {
jobName: `${WorkloadType.TEXTTOIMAGE} - ${generate({ exactly: 3, maxLength: 4 })?.join(' ') ?? ''}`,
details: {
nTasks: 4,
gpuPerTask: 1,
cpuPerTask: 8,
gpusPerTask: 1,
cpusPerTask: 8,
memPerCpu: 8000,
ttiModel: TextToImageModel['sd-2-1'],
steps: '150',
Expand Down Expand Up @@ -119,8 +119,8 @@ const TextToImagePage: NextPage = () => {
<CreditSubform
defaultDuration={10}
gpuQty={watch('details.nTasks')}
cpuQty={watch('details.nTasks')! * watch('details.cpuPerTask')!}
memQty={watch('details.nTasks')! * watch('details.cpuPerTask')! * watch('details.memPerCpu')!}
cpuQty={watch('details.nTasks')! * watch('details.cpusPerTask')!}
memQty={watch('details.nTasks')! * watch('details.cpusPerTask')! * watch('details.memPerCpu')!}
/>
<SendButton>Generate</SendButton>
</div>
Expand Down
18 changes: 9 additions & 9 deletions src/app/unity/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const schema = (maxAmount: bigint, minAmount: bigint, ignoreBalance: boolean) =>
archiveLink: y.string().required(),
binaryPath: y.string().required(),
additionalArgs: y.string().notRequired(),
gpuPerTask: y.number().integer().min(0).max(2),
cpuPerTask: y.number().integer().min(0).max(16),
gpusPerTask: y.number().integer().min(0).max(2),
cpusPerTask: y.number().integer().min(0).max(16),
memPerCpu: y
.number()
.integer()
Expand All @@ -82,8 +82,8 @@ const UnityPage: NextPage = () => {
jobName: `${WorkloadType.URS} - ${generate({ exactly: 3, maxLength: 4 })?.join(' ') ?? ''}`,
details: {
nTasks: 1,
gpuPerTask: 1,
cpuPerTask: 4,
gpusPerTask: 1,
cpusPerTask: 4,
memPerCpu: 4096,
binaryPath: '',
archiveLink: '',
Expand Down Expand Up @@ -133,11 +133,11 @@ const UnityPage: NextPage = () => {
<Grid className="pt-5" container spacing={2.5} columns={2}>
<Grid item xs={1}>
<h4 className="m-0 font-normal">GPU(s)</h4>
<NumberField name="details.gpuPerTask" control={control} type="number" min={1} />
<NumberField name="details.gpusPerTask" control={control} type="number" min={1} />
</Grid>
<Grid item xs={1}>
<h4 className="m-0 font-normal">CPU(s)</h4>
<NumberField name="details.cpuPerTask" control={control} type="number" min={1} />
<NumberField name="details.cpusPerTask" control={control} type="number" min={1} />
</Grid>
<Grid item xs={1}>
<h4 className="m-0 font-normal">Memory (MB) per CPU</h4>
Expand All @@ -146,9 +146,9 @@ const UnityPage: NextPage = () => {
</Grid>
</Card>
<CreditSubform
gpuQty={watch('details.gpuPerTask')}
cpuQty={watch('details.cpuPerTask')}
memQty={watch('details.cpuPerTask')! * watch('details.memPerCpu')!}
gpuQty={watch('details.gpusPerTask')}
cpuQty={watch('details.cpusPerTask')}
memQty={watch('details.cpusPerTask')! * watch('details.memPerCpu')!}
/>
<SendButton>Render</SendButton>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/upscaling/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ const NewPage: NextPage = () => {
labels: [],
details: {
nTasks: 1,
gpuPerTask: 1,
cpuPerTask: 8,
gpusPerTask: 1,
cpusPerTask: 8,
memPerCpu: 8000,
isVideo: false,
isAnime: false,
Expand Down
25 changes: 22 additions & 3 deletions src/components/ui/containers/HardwareRecap/HardwareRecap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,28 @@ const HardwareRecap: FC<HardwareRecapProps> = ({ defaultDuration, gpuQty = 0, cp
});
}, [defaultDuration]);

const { data: provider } = useGetProviderPrices('0x75761B17c3088ce5Cd8e02575c6DAa438FFA6e12');
const { data, error } = useGetProviderPrices('0x75761B17c3088ce5Cd8e02575c6DAa438FFA6e12');

// TODO: HACK: Return fake data on error
const provider = useMemo(() => {
if (error || !data) {
return {
cpuPricePerMin: 950000000000000000n,
gpuPricePerMin: 8500000000000000000n,
memPricePerMin: 80000000000000n,
};
}

// Return fake also if everything is zero
if (!data.cpuPricePerMin && !data.gpuPricePerMin && !data.memPricePerMin) {
return {
cpuPricePerMin: 950000000000000000n,
gpuPricePerMin: 8500000000000000000n,
memPricePerMin: 80000000000000n,
};
}
return data;
}, [data, error]);

const { setValue, formState } = useFormContext<CreditSubformData>();

Expand All @@ -60,8 +81,6 @@ const HardwareRecap: FC<HardwareRecapProps> = ({ defaultDuration, gpuQty = 0, cp
setOpen(!!formState.errors.credit);
}, [formState.errors]);

if (!provider) return null;

const rows = [
...(gpuQty !== 0
? [
Expand Down
Loading