Skip to content

Commit

Permalink
feat(explorer): only enable certificate verification cache in unstabl…
Browse files Browse the repository at this point in the history
…e builds
  • Loading branch information
Alenar committed Dec 19, 2024
1 parent 51b3641 commit 3ff980c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function CertificateVerifier({
certificate,
hideSpinner = false,
showCertificateLinks = false,
certificateChainVerificationCacheEnabled = true,
isCacheEnabled = false,
onStepChange = (step) => {},
onChainValidationError = (error) => {},
onCertificateClick = (hash) => {},
Expand Down Expand Up @@ -217,15 +217,14 @@ export default function CertificateVerifier({
.map((evt) => (
<div key={evt.id}>{evt.message}</div>
))}
{certificateChainVerificationCacheEnabled &&
currentStep === certificateValidationSteps.done && (
<>
Cache enabled:{" "}
<a href="#" onClick={onCacheResetClick}>
reset cache
</a>
</>
)}
{isCacheEnabled && currentStep === certificateValidationSteps.done && (
<>
Cache enabled:{" "}
<a href="#" onClick={onCacheResetClick}>
reset cache
</a>
</>
)}
{validationError !== undefined && (
<Alert variant="danger" className="mt-2">
<Alert.Heading>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function VerifyCertificateModal({ show, onClose, certificateHash
const [showLoadingWarning, setShowLoadingWarning] = useState(false);
const [client, setClient] = useState(undefined);
const [certificate, setCertificate] = useState(undefined);
const enableCertificateChainVerificationCache = true;
const [isCacheEnabled, setIsCacheEnabled] = useState(false);

useEffect(() => {
if (show) {
Expand All @@ -31,14 +31,19 @@ export default function VerifyCertificateModal({ show, onClose, certificateHash

async function init(aggregator, certificateHash) {
const genesisVerificationKey = await fetchGenesisVerificationKey(aggregator);
const client = new MithrilClient(aggregator, genesisVerificationKey, {
unstable: true,
enable_certificate_chain_verification_cache: enableCertificateChainVerificationCache,
});
const isCacheEnabled = process.env.UNSTABLE === true;
const client_options = process.env.UNSTABLE
? {
unstable: true,
enable_certificate_chain_verification_cache: isCacheEnabled,
}
: {};
const client = new MithrilClient(aggregator, genesisVerificationKey, client_options);
const certificate = await client.get_mithril_certificate(certificateHash);

setClient(client);
setCertificate(certificate);
setIsCacheEnabled(isCacheEnabled);
}

function handleModalClose() {
Expand Down Expand Up @@ -73,7 +78,7 @@ export default function VerifyCertificateModal({ show, onClose, certificateHash
<CertificateVerifier
client={client}
certificate={certificate}
certificateChainVerificationCacheEnabled={enableCertificateChainVerificationCache}
isCacheEnabled={isCacheEnabled}
onStepChange={(step) =>
setLoading(step === certificateValidationSteps.validationInProgress)
}
Expand Down

0 comments on commit 3ff980c

Please sign in to comment.