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(website): Optimizations to prevent CPU spikes #1509

Merged
merged 11 commits into from
Nov 4, 2024
Merged
537 changes: 293 additions & 244 deletions packages/website/src/features/Deploy/QueueFromGitOpsPage.tsx

Large diffs are not rendered by default.

28 changes: 25 additions & 3 deletions packages/website/src/features/Deploy/TransactionDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import { SimulateTransactionButton } from './SimulateTransactionButton';
import { TransactionDisplay } from './TransactionDisplay';
import { TransactionStepper } from './TransactionStepper';
import 'react-diff-view/style/index.css';
import { ChainDefinition } from '@usecannon/builder';
import { getChainDefinitionFromWorker } from '@/helpers/chain-definition';

const AdditionalSignaturesText = ({ amount }: { amount: number }) => (
<Text fontWeight="bold" mt="3">
Expand Down Expand Up @@ -94,6 +96,7 @@ function TransactionDetailsPage() {
const [expandDiff, setExpandDiff] = useState<boolean>(false);
const [executionTxnHash, setExecutionTxnHash] = useState<Hash | null>(null);
const accountAlreadyConnected = useRef(account.isConnected);
const [chainDefinition, setChainDefinition] = useState<ChainDefinition>();

const safe: SafeDefinition = useMemo(
() => ({
Expand Down Expand Up @@ -230,18 +233,37 @@ function TransactionDetailsPage() {
gitFile ?? ''
);

useEffect(() => {
const getChainDef = async () => {
if (!cannonDefInfo.def) return;

const chainDefition = await getChainDefinitionFromWorker(
cannonDefInfo.def
);
setChainDefinition(chainDefition);
};

void getChainDef();
}, [cannonDefInfo.def]);

const buildInfo = useCannonBuild(
safe,
cannonDefInfo.def,
prevCannonDeployInfo.pkg
chainDefinition,
prevCannonDeployInfo.ipfsQuery.data?.deployInfo
);

useEffect(() => {
if (!safe || !cannonDefInfo.def || !prevCannonDeployInfo.pkg) return;
if (
!safe ||
!chainDefinition ||
!prevCannonDeployInfo.ipfsQuery.data?.deployInfo
)
return;
buildInfo.doBuild();
}, [
!isTransactionExecuted &&
(!prevDeployGitHash || prevCannonDeployInfo.ipfsQuery.isFetched),
chainDefinition,
]);

// compare proposed build info with expected transaction batch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const CannonfileExplorer: FC<{
flex="1"
direction="column"
>
<CannonfileGraph deploymentInfo={deploymentInfo} />
<CannonfileGraph deploymentDefinition={deploymentInfo.def} />
</Flex>
<Container
maxW="container.lg"
Expand Down
Loading
Loading