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

features/mainnet-6-web #6

Merged
merged 4 commits into from
Aug 31, 2023
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
2 changes: 1 addition & 1 deletion api/src/providers/apiNodeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export async function getDeployment(owner: string, dseq: string) {
status: x.lease.state,
denom: deploymentDenom,
monthlyCostAKT: round(monthlyUAKT / 1_000_000, 2),
// TODO Improve
// TODO Improve: Add USDC into calculation
monthlyCostUSD: deploymentDenom === "uakt" ? (aktPrice ? round((monthlyUAKT / 1_000_000) * aktPrice, 2) : round(monthlyUAKT / 1_000_000, 2)) : null,
cpuUnits: group.group_spec.resources.map((r) => parseInt(r.resources.cpu.units.val) * r.count).reduce((a, b) => a + b, 0),
gpuUnits: group.group_spec.resources.map((r) => parseInt(r.resources.gpu?.units?.val) * r.count || 0).reduce((a, b) => a + b, 0),
Expand Down
63 changes: 29 additions & 34 deletions deploy-web/src/components/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { uaktToAKT } from "@src/utils/priceUtils";
import { BlockRow } from "../blockchain/BlockRow";
import { TransactionRow } from "../blockchain/TransactionRow";
import { useSelectedNetwork } from "@src/utils/networks";
import { testnetId } from "@src/utils/constants";

interface IDashboardProps {
dashboardData: DashboardData;
Expand Down Expand Up @@ -87,7 +86,7 @@ export const Dashboard: React.FunctionComponent<IDashboardProps> = ({ dashboardD
const capacityMemoryDiff = bytesToShrink(dashboardData.networkCapacityStats.now.memory - dashboardData.networkCapacityStats.compare.memory);
const capacityStorageDiff = bytesToShrink(dashboardData.networkCapacityStats.now.storage - dashboardData.networkCapacityStats.compare.storage);
const selectedNetwork = useSelectedNetwork();
const statsGridWidth = selectedNetwork.id === testnetId ? 2.4 : 3;
const statsGridWidth = 2.4;

return (
<>
Expand Down Expand Up @@ -212,22 +211,20 @@ export const Dashboard: React.FunctionComponent<IDashboardProps> = ({ dashboardD
/>
</Grid>

{selectedNetwork.id === testnetId && (
<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
number={
<>
<FormattedNumber value={dashboardData.now.activeGPU} maximumFractionDigits={2} />
<small style={{ paddingLeft: "5px", fontWeight: "bold", fontSize: 16 }}>GPU</small>
</>
}
text="Graphics"
graphPath={UrlService.graph(SnapshotsUrlParam.graphics)}
diffNumber={dashboardData.now.activeGPU - dashboardData.compare.activeGPU}
diffPercent={percIncrease(dashboardData.compare.activeGPU, dashboardData.now.activeGPU)}
/>
</Grid>
)}
<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
number={
<>
<FormattedNumber value={dashboardData.now.activeGPU} maximumFractionDigits={2} />
<small style={{ paddingLeft: "5px", fontWeight: "bold", fontSize: 16 }}>GPU</small>
</>
}
text="Graphics"
graphPath={UrlService.graph(SnapshotsUrlParam.graphics)}
diffNumber={dashboardData.now.activeGPU - dashboardData.compare.activeGPU}
diffPercent={percIncrease(dashboardData.compare.activeGPU, dashboardData.now.activeGPU)}
/>
</Grid>

<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
Expand Down Expand Up @@ -286,22 +283,20 @@ export const Dashboard: React.FunctionComponent<IDashboardProps> = ({ dashboardD
/>
</Grid>

{selectedNetwork.id === testnetId && (
<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
number={
<>
<FormattedNumber value={dashboardData.networkCapacity.totalGPU} maximumFractionDigits={0} />
<small style={{ paddingLeft: ".25rem", fontWeight: "bold", fontSize: 16 }}>GPU</small>
</>
}
text="Graphics"
graphPath={UrlService.providerGraph(ProviderSnapshotsUrlParam.gpu)}
diffNumber={dashboardData.networkCapacityStats.now.gpu - dashboardData.networkCapacityStats.compare.gpu}
diffPercent={percIncrease(dashboardData.networkCapacityStats.compare.gpu, dashboardData.networkCapacityStats.now.gpu)}
/>
</Grid>
)}
<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
number={
<>
<FormattedNumber value={dashboardData.networkCapacity.totalGPU} maximumFractionDigits={0} />
<small style={{ paddingLeft: ".25rem", fontWeight: "bold", fontSize: 16 }}>GPU</small>
</>
}
text="Graphics"
graphPath={UrlService.providerGraph(ProviderSnapshotsUrlParam.gpu)}
diffNumber={dashboardData.networkCapacityStats.now.gpu - dashboardData.networkCapacityStats.compare.gpu}
diffPercent={percIncrease(dashboardData.networkCapacityStats.compare.gpu, dashboardData.networkCapacityStats.now.gpu)}
/>
</Grid>

<Grid item xs={12} lg={statsGridWidth}>
<StatsCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function ManifestUpdate({ deployment, leases, closeManifestEditor }) {
const mani = deploymentData.getManifest(doc, true);

// If it's actual update, send a transaction, else just send the manifest
if (dd.version !== deployment.version) {
if (Buffer.from(dd.version).toString("base64") !== deployment.version) {
const message = TransactionMessageData.getUpdateDeploymentMsg(dd);
response = await signAndBroadcastTx([message]);
} else {
Expand Down
62 changes: 29 additions & 33 deletions deploy-web/src/components/providers/NetworkCapacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { bytesToShrink } from "@src/utils/unitUtils";
import { roundDecimal } from "@src/utils/mathHelpers";
import { useRouter } from "next/router";
import { useSelectedNetwork } from "@src/utils/networks";
import { mainnetId, testnetId } from "@src/utils/constants";

type Props = {
activeCPU: number;
Expand Down Expand Up @@ -52,8 +51,7 @@ const NetworkCapacity: React.FunctionComponent<Props> = ({
const memoryData = useData(activeMemoryBytes, availableMemoryBytes);
const storageData = useData(activeStorageBytes, availableStorageBytes);
const pieTheme = usePieTheme();
const selectedNetwork = useSelectedNetwork();
const flexBasis = selectedNetwork.id === mainnetId ? "33.3333%" : "25%";
const flexBasis = "25%";

const _getColor = bar => getColor(bar.id);

Expand Down Expand Up @@ -97,36 +95,34 @@ const NetworkCapacity: React.FunctionComponent<Props> = ({
</Box>
</Box>

{selectedNetwork.id === testnetId && (
<Box sx={{ flexBasis: flexBasis }}>
<Typography variant="body1" sx={{ lineHeight: "1rem" }}>
GPU
</Typography>
<Typography variant="caption" color="textSecondary">
{Math.round(activeGPU + pendingGPU)}&nbsp;GPU&nbsp;/&nbsp;{Math.round(totalGPU)}&nbsp;GPU
</Typography>
<Box sx={{ height: "200px", width: "200px", display: "flex", alignItems: "center", justifyContent: "center" }}>
<ResponsivePie
data={gpuData}
margin={{ top: 15, right: 15, bottom: 15, left: 0 }}
innerRadius={0.3}
padAngle={2}
cornerRadius={4}
activeOuterRadiusOffset={8}
colors={_getColor}
borderWidth={0}
borderColor={{
from: "color",
modifiers: [["darker", 0.2]]
}}
valueFormat={value => `${roundDecimal(value, 2)} GPU`}
enableArcLinkLabels={false}
arcLabelsSkipAngle={10}
theme={pieTheme}
/>
</Box>
<Box sx={{ flexBasis: flexBasis }}>
<Typography variant="body1" sx={{ lineHeight: "1rem" }}>
GPU
</Typography>
<Typography variant="caption" color="textSecondary">
{Math.round(activeGPU + pendingGPU)}&nbsp;GPU&nbsp;/&nbsp;{Math.round(totalGPU)}&nbsp;GPU
</Typography>
<Box sx={{ height: "200px", width: "200px", display: "flex", alignItems: "center", justifyContent: "center" }}>
<ResponsivePie
data={gpuData}
margin={{ top: 15, right: 15, bottom: 15, left: 0 }}
innerRadius={0.3}
padAngle={2}
cornerRadius={4}
activeOuterRadiusOffset={8}
colors={_getColor}
borderWidth={0}
borderColor={{
from: "color",
modifiers: [["darker", 0.2]]
}}
valueFormat={value => `${roundDecimal(value, 2)} GPU`}
enableArcLinkLabels={false}
arcLabelsSkipAngle={10}
theme={pieTheme}
/>
</Box>
)}
</Box>

<Box sx={{ flexBasis: flexBasis }}>
<Typography variant="body1" sx={{ lineHeight: "1rem" }}>
Expand Down Expand Up @@ -166,7 +162,7 @@ const NetworkCapacity: React.FunctionComponent<Props> = ({
Storage
</Typography>
<Typography variant="caption" color="textSecondary">
{`${roundDecimal(_activeStorage.value, 2)} ${_activeStorage.unit}`}&nbsp;/&nbsp;{`${roundDecimal(_totalStorage.value, 2)} ${_activeStorage.unit}`}
{`${roundDecimal(_activeStorage.value, 2)} ${_activeStorage.unit}`}&nbsp;/&nbsp;{`${roundDecimal(_totalStorage.value, 2)} ${_totalStorage.unit}`}
</Typography>
<Box sx={{ height: "200px", width: "200px", display: "flex", alignItems: "center", justifyContent: "center" }}>
<ResponsivePie
Expand Down
9 changes: 3 additions & 6 deletions deploy-web/src/components/providers/ProviderList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { MergedProvider } from "@src/types/provider";
import { CustomTableHeader } from "../shared/CustomTable";
import { ProviderListRow } from "./ProviderListRow";
import { useSelectedNetwork } from "@src/utils/networks";
import { testnetId } from "@src/utils/constants";

const useStyles = makeStyles()(theme => ({}));

Expand Down Expand Up @@ -36,11 +35,9 @@ export const ProviderList: React.FunctionComponent<Props> = ({ providers }) => {
<TableCell align="center" width="10%">
CPU
</TableCell>
{selectedNetwork.id === testnetId && (
<TableCell align="center" width="10%">
GPU
</TableCell>
)}
<TableCell align="center" width="10%">
GPU
</TableCell>
<TableCell align="center" width="10%">
Memory
</TableCell>
Expand Down
49 changes: 22 additions & 27 deletions deploy-web/src/components/providers/ProviderListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { UrlService } from "@src/utils/urlUtils";
import { FormattedNumber } from "react-intl";
import { Uptime } from "./Uptime";
import { useSelectedNetwork } from "@src/utils/networks";
import { testnetId } from "@src/utils/constants";

const useStyles = makeStyles()(theme => ({
root: {
Expand All @@ -38,16 +37,14 @@ export const ProviderListRow: React.FunctionComponent<Props> = ({ provider }) =>
const { classes } = useStyles();
const theme = useTheme();
const router = useRouter();
const selectedNetwork = useSelectedNetwork();
const { favoriteProviders, updateFavoriteProviders } = useLocalNotes();
const isFavorite = favoriteProviders.some(x => provider.owner === x);
const activeCPU = provider.isActive ? provider.activeStats.cpu / 1000 : 0;
const pendingCPU = provider.isActive ? provider.pendingStats.cpu / 1000 : 0;
const totalCPU = provider.isActive ? (provider.availableStats.cpu + provider.pendingStats.cpu + provider.activeStats.cpu) / 1000 : 0;
const activeGPU = provider.isActive && selectedNetwork.id === testnetId ? provider.activeStats.gpu : 0;
const pendingGPU = provider.isActive && selectedNetwork.id === testnetId ? provider.pendingStats.gpu : 0;
const totalGPU =
provider.isActive && selectedNetwork.id === testnetId ? provider.availableStats.gpu + provider.pendingStats.gpu + provider.activeStats.gpu : 0;
const activeGPU = provider.isActive && provider.activeStats.gpu;
const pendingGPU = provider.isActive && provider.pendingStats.gpu;
const totalGPU = provider.isActive && provider.availableStats.gpu + provider.pendingStats.gpu + provider.activeStats.gpu;
const _activeMemory = provider.isActive ? bytesToShrink(provider.activeStats.memory + provider.pendingStats.memory) : null;
const _totalMemory = provider.isActive ? bytesToShrink(provider.availableStats.memory + provider.pendingStats.memory + provider.activeStats.memory) : null;
const _activeStorage = provider.isActive ? bytesToShrink(provider.activeStats.storage + provider.pendingStats.storage) : null;
Expand Down Expand Up @@ -133,28 +130,26 @@ export const ProviderListRow: React.FunctionComponent<Props> = ({ provider }) =>
)}
</TableCell>

{selectedNetwork.id === testnetId && (
<TableCell align="center">
{provider.isActive && (
<CustomTooltip
title={
<Typography fontSize=".7rem" variant="caption">
{Math.round(activeGPU + pendingGPU)}&nbsp;/&nbsp;{Math.round(totalGPU)}&nbsp;GPU
<TableCell align="center">
{provider.isActive && (
<CustomTooltip
title={
<Typography fontSize=".7rem" variant="caption">
{Math.round(activeGPU + pendingGPU)}&nbsp;/&nbsp;{Math.round(totalGPU)}&nbsp;GPU
</Typography>
}
>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CapacityIcon value={(activeGPU + pendingGPU) / totalGPU} />
{totalGPU > 0 && (
<Typography variant="caption" color="textSecondary">
<FormattedNumber style="percent" maximumFractionDigits={2} value={roundDecimal((activeGPU + pendingGPU) / totalGPU, 2)} />
</Typography>
}
>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CapacityIcon value={(activeGPU + pendingGPU) / totalGPU} />
{totalGPU > 0 && (
<Typography variant="caption" color="textSecondary">
<FormattedNumber style="percent" maximumFractionDigits={2} value={roundDecimal((activeGPU + pendingGPU) / totalGPU, 2)} />
</Typography>
)}
</Box>
</CustomTooltip>
)}
</TableCell>
)}
)}
</Box>
</CustomTooltip>
)}
</TableCell>

<TableCell align="center">
{provider.isActive && (
Expand Down
5 changes: 3 additions & 2 deletions deploy-web/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const auth0TokenNamespace = "https://cloudmos.io";
export const uAktDenom = "uakt";
// TODO Handle denom for mainnet/testnet/sandbox
export const usdcIbcDenom = "ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84";
export const mainnetUsdcIdbDenom = "ibc/F8D2BEE806C3F969B256416B37FF6E7E0B927F372993114B8E0B9E57DC8CD327";

// Cloudmos fee
export const feePercent = 3;
Expand Down Expand Up @@ -113,7 +114,7 @@ export function setNetworkVersion() {

switch (_selectedNetworkId) {
case mainnetId:
networkVersion = "v1beta2";
networkVersion = "v1beta3";
selectedNetworkId = mainnetId;
break;
case testnetId:
Expand All @@ -126,7 +127,7 @@ export function setNetworkVersion() {
break;

default:
networkVersion = "v1beta2";
networkVersion = "v1beta3";
selectedNetworkId = mainnetId;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions deploy-web/src/utils/deploymentData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function initDeploymentData() {

switch (selectedNetworkId) {
case mainnetId:
deploymentData = v1beta2;
deploymentData = v1beta3;
break;
case testnetId:
deploymentData = v1beta3;
Expand All @@ -21,7 +21,7 @@ export function initDeploymentData() {
break;

default:
deploymentData = v1beta2;
deploymentData = v1beta3;
break;
}
}
4 changes: 2 additions & 2 deletions deploy-web/src/utils/proto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function initProtoTypes() {

switch (selectedNetworkId) {
case mainnetId:
protoTypes = v1beta2;
protoTypes = v1beta3;
break;
case testnetId:
protoTypes = v1beta3;
Expand All @@ -19,7 +19,7 @@ export function initProtoTypes() {
break;

default:
protoTypes = v1beta2;
protoTypes = v1beta3;
break;
}
}