Skip to content

Commit

Permalink
Zilliqa: Consensus data on Block view and Raw Input default format fo…
Browse files Browse the repository at this point in the history
…r Scilla contract txn (#2375)

* ENV preset for zilliqa

* add zilliqa fields to block view

* [skip ci] fix typo

* fix accordion styles

* [skip ci] make signers required again

* change default format of Raw Input for Scilla contract to UTF-8

* add default type option to log item data
  • Loading branch information
tom2drum authored Nov 25, 2024
1 parent d667de4 commit bb745fe
Show file tree
Hide file tree
Showing 23 changed files with 387 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/deploy-review-l2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ on:
- rootstock
- shibarium
- stability
- zkevm
- zkevm
- zilliqa_prototestnet
- zksync
- zora

jobs:
make_slug:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ on:
- shibarium
- stability
- zkevm
- zilliqa_prototestnet
- zksync
- zora

jobs:
make_slug:
Expand Down
2 changes: 2 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@
"shibarium",
"stability_testnet",
"zkevm",
"zilliqa_prototestnet",
"zksync",
"zora",
],
"default": "main"
},
Expand Down
41 changes: 41 additions & 0 deletions configs/envs/.env.zilliqa_prototestnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Set of ENVs for Zilliqa EVM proto-testnet network explorer
# https://zilliqa-prototestnet.blockscout.com
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=zilliqa_prototestnet"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
NEXT_PUBLIC_APP_HOST=localhost
NEXT_PUBLIC_APP_PORT=3000
NEXT_PUBLIC_APP_ENV=development
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws

NEXT_PUBLIC_VIEWS_ADDRESS_FORMAT=['bech32','base16']
NEXT_PUBLIC_VIEWS_ADDRESS_BECH_32_PREFIX=zil
NEXT_PUBLIC_VIEWS_BLOCK_HIDDEN_FIELDS=['base_fee']

# Instance ENVs
NEXT_PUBLIC_API_BASE_PATH=/
NEXT_PUBLIC_API_HOST=zilliqa-prototestnet.blockscout.com
NEXT_PUBLIC_API_SPEC_URL=https://raw.githubusercontent.com/blockscout/blockscout-api-v2-swagger/main/swagger.yaml
NEXT_PUBLIC_CONTRACT_CODE_IDES=[{'title':'Remix IDE','url':'https://remix.ethereum.org/?address={hash}&blockscout={domain}','icon_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/ide-icons/remix.png'}]
NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0x3d1ded3a7924cd3256a4b1a447c9bfb194f54b9a8ceb441edb8bb01563b516db
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs']
NEXT_PUBLIC_HOMEPAGE_HERO_BANNER_CONFIG={'background':['linear-gradient(90deg, rgba(52,103, 109, 1) 0.06%, rgba(105, 181, 172, 1) 99.97%)'],'text_color':['rgba(255, 255, 255, 1)']}
NEXT_PUBLIC_IS_TESTNET=true
NEXT_PUBLIC_METADATA_SERVICE_API_HOST=https://metadata.services.blockscout.com
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=ZIL
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=ZIL
NEXT_PUBLIC_NETWORK_ICON=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/zilliqa.svg
NEXT_PUBLIC_NETWORK_ICON_DARK=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/zilliqa-dark.svg
NEXT_PUBLIC_NETWORK_ID=33103
NEXT_PUBLIC_NETWORK_LOGO=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-logos/zilliqa.svg
NEXT_PUBLIC_NETWORK_LOGO_DARK=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-logos/zilliqa-dark.svg
NEXT_PUBLIC_NETWORK_NAME=Zilliqa EVM proto-testnet
NEXT_PUBLIC_NETWORK_RPC_URL=https://api.zq2-prototestnet.zilliqa.com
NEXT_PUBLIC_NETWORK_SHORT_NAME=Zilliqa EVM proto-testnet
NEXT_PUBLIC_OG_ENHANCED_DATA_ENABLED=true
NEXT_PUBLIC_OG_IMAGE_URL=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/og-images/zilliqa.png
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY=6Ld0iT8aAAAAAJdju0CmAwGjW7JTDvIw-Q5pwt5T
NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER=blockscout
NEXT_PUBLIC_VISUALIZE_API_HOST=https://visualizer.services.blockscout.com
41 changes: 40 additions & 1 deletion mocks/blocks/block.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-len */
import type { RpcBlock } from 'viem';

import type { Block, BlocksResponse } from 'types/api/block';
import type { Block, BlocksResponse, ZilliqaBlockData } from 'types/api/block';

import { ZERO_ADDRESS } from 'lib/consts';

Expand Down Expand Up @@ -170,6 +170,45 @@ export const celo: Block = {
},
};

export const zilliqaWithAggregateQuorumCertificate: Block = {
...base,
zilliqa: {
view: 1137735,
aggregate_quorum_certificate: {
signature: '0x82d29e8f06adc890f6574c3d0ae0c811de1db695b05ed2755ef384fe21bc44f6505b99e201f6000a65f38ff6a13e286306d0e380ef1b43a273eb9947b3f11f852e14b93c258c32b516f89696fcb1190b147364b789572ebdf85d79c4cf3cbbbb',
view: 1137735,
signers: [ 1, 2, 3, 8 ],
nested_quorum_certificates: [
{
signature: '0xaeb3567577f9db68565c6f97c158b17522620a9684c6f6beaa78920951ad4cae0f287b630bdd034c4a4f89ada42e3dbe012985e976a6f64057d735a4531a26b4e46c182414eabbe625e5b15e6645be5b6522bdec113df408874f6d1e0d894dca',
view: 1137732,
proposed_by_validator_index: 1,
signers: [ 3, 8 ],
},
{
signature: '0xaeb3567577f9db68565c6f97c158b17522620a9684c6f6beaa78920951ad4cae0f287b630bdd034c4a4f89ada42e3dbe012985e976a6f64057d735a4531a26b4e46c182414eabbe625e5b15e6645be5b6522bdec113df408874f6d1e0d894dca',
view: 1137732,
proposed_by_validator_index: 2,
signers: [ 0, 2 ],
},
],
},
quorum_certificate: {
signature: '0xaeb3567577f9db68565c6f97c158b17522620a9684c6f6beaa78920951ad4cae0f287b630bdd034c4a4f89ada42e3dbe012985e976a6f64057d735a4531a26b4e46c182414eabbe625e5b15e6645be5b6522bdec113df408874f6d1e0d894dca',
view: 1137732,
signers: [ 0, 2, 3, 8 ],
},
},
};

export const zilliqaWithoutAggregateQuorumCertificate: Block = {
...base,
zilliqa: {
...zilliqaWithAggregateQuorumCertificate.zilliqa,
aggregate_quorum_certificate: null,
} as ZilliqaBlockData,
};

export const withBlobTxs: Block = {
...base,
blob_gas_price: '21518435987',
Expand Down
1 change: 1 addition & 0 deletions tools/preset-sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const PRESETS = {
stability_testnet: 'https://stability-testnet.blockscout.com',
zkevm: 'https://zkevm.blockscout.com',
zksync: 'https://zksync.blockscout.com',
zilliqa_prototestnet: 'https://zilliqa-prototestnet.blockscout.com',
zora: 'https://explorer.zora.energy',
// main === staging
main: 'https://eth-sepolia.k8s-dev.blockscout.com',
Expand Down
5 changes: 5 additions & 0 deletions types/api/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Address extends UserTags {
exchange_rate: string | null;
ens_domain_name: string | null;
filecoin?: AddressFilecoinParams;
zilliqa?: AddressZilliqaParams;
// TODO: if we are happy with tabs-counters method, should we delete has_something fields?
has_beacon_chain_withdrawals?: boolean;
has_decompiled_code: boolean;
Expand All @@ -32,6 +33,10 @@ export interface Address extends UserTags {
watchlist_address_id: number | null;
}

export interface AddressZilliqaParams {
is_scilla_contract: boolean;
}

export interface AddressCounters {
transactions_count: string;
token_transfers_count: string;
Expand Down
20 changes: 20 additions & 0 deletions types/api/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export interface Block {
is_epoch_block: boolean;
base_fee?: BlockBaseFeeCelo;
};
// ZILLIQA FIELDS
zilliqa?: ZilliqaBlockData;
}

type ArbitrumBlockData = {
Expand All @@ -88,6 +90,24 @@ export interface OptimismBlockData {
l1_transaction_hashes: Array<string>;
}

export interface ZilliqaBlockData {
view: number;
quorum_certificate: ZilliqaQuorumCertificate;
aggregate_quorum_certificate: (ZilliqaQuorumCertificate & {
nested_quorum_certificates: Array<ZilliqaNestedQuorumCertificate>;
}) | null;
}

export interface ZilliqaQuorumCertificate {
view: number;
signature: string;
signers: Array<number>;
}

export interface ZilliqaNestedQuorumCertificate extends ZilliqaQuorumCertificate {
proposed_by_validator_index: number;
}

export interface BlocksResponse {
items: Array<Block>;
next_page_params: {
Expand Down
4 changes: 4 additions & 0 deletions types/api/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export type Transaction = {
zksync?: Omit<ZkSyncBatchesItem, 'number' | 'transaction_count' | 'timestamp'> & {
batch_number: number | null;
};
// Zilliqa fields
zilliqa?: {
is_scilla: boolean;
};
// blob tx fields
blob_versioned_hashes?: Array<string>;
blob_gas_used?: string;
Expand Down
13 changes: 12 additions & 1 deletion ui/address/AddressLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Pagination from 'ui/shared/pagination/Pagination';
import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages';

import AddressCsvExportLink from './AddressCsvExportLink';
import useAddressQuery from './utils/useAddressQuery';

type Props = {
scrollRef?: React.RefObject<HTMLDivElement>;
Expand Down Expand Up @@ -39,6 +40,8 @@ const AddressLogs = ({ scrollRef, shouldRender = true, isQueryEnabled = true }:
},
});

const addressQuery = useAddressQuery({ hash });

const actionBar = (
<ActionBar mt={ -6 } showShadow justifyContent={{ base: 'space-between', lg: 'end' }}>
<AddressCsvExportLink
Expand All @@ -54,7 +57,15 @@ const AddressLogs = ({ scrollRef, shouldRender = true, isQueryEnabled = true }:
return null;
}

const content = data?.items ? data.items.map((item, index) => <LogItem key={ index } { ...item } type="address" isLoading={ isPlaceholderData }/>) : null;
const content = data?.items ? data.items.map((item, index) => (
<LogItem
key={ index }
{ ...item }
type="address"
isLoading={ isPlaceholderData }
defaultDataType={ addressQuery.data?.zilliqa?.is_scilla_contract ? 'UTF-8' : undefined }
/>
)) : null;

return (
<DataListDisplay
Expand Down
30 changes: 30 additions & 0 deletions ui/block/BlockDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import ZkSyncL2TxnBatchHashesInfo from 'ui/txnBatches/zkSyncL2/ZkSyncL2TxnBatchH

import BlockDetailsBaseFeeCelo from './details/BlockDetailsBaseFeeCelo';
import BlockDetailsBlobInfo from './details/BlockDetailsBlobInfo';
import BlockDetailsZilliqaQuorumCertificate from './details/BlockDetailsZilliqaQuorumCertificate';
import type { BlockQuery } from './useBlockQuery';

interface Props {
Expand Down Expand Up @@ -416,6 +417,22 @@ const BlockDetails = ({ query }: Props) => {
))
}

{ typeof data.zilliqa?.view === 'number' && (
<>
<DetailsInfoItem.Label
hint="The iteration of the consensus round in which the block was proposed"
isLoading={ isPlaceholderData }
>
View
</DetailsInfoItem.Label>
<DetailsInfoItem.Value>
<Skeleton isLoaded={ !isPlaceholderData }>
{ data.zilliqa.view }
</Skeleton>
</DetailsInfoItem.Value>
</>
) }

<DetailsInfoItemDivider/>

{ data.celo?.base_fee && <BlockDetailsBaseFeeCelo data={ data.celo.base_fee }/> }
Expand Down Expand Up @@ -741,6 +758,19 @@ const BlockDetails = ({ query }: Props) => {
</DetailsInfoItem.Value>
</>
) }

{ data.zilliqa && (
<>
<DetailsInfoItemDivider/>
<BlockDetailsZilliqaQuorumCertificate data={ data.zilliqa?.quorum_certificate }/>
{ data.zilliqa?.aggregate_quorum_certificate && (
<>
<GridItem colSpan={{ base: undefined, lg: 2 }} mt={{ base: 1, lg: 2 }}/>
<BlockDetailsZilliqaQuorumCertificate data={ data.zilliqa?.aggregate_quorum_certificate }/>
</>
) }
</>
) }
</>
) }
</Grid>
Expand Down
41 changes: 41 additions & 0 deletions ui/block/details/BlockDetailsZilliqaQuorumCertificate.pw.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Grid } from '@chakra-ui/react';
import React from 'react';

import type { ZilliqaQuorumCertificate } from 'types/api/block';

import * as blockMock from 'mocks/blocks/block';
import { test, expect } from 'playwright/lib';

import BlockDetailsZilliqaQuorumCertificate from './BlockDetailsZilliqaQuorumCertificate';

test('quorum certificate', async({ render }) => {
const component = await render(
<Grid
columnGap={ 8 }
rowGap={{ base: 3, lg: 3 }}
templateColumns={{ base: 'minmax(0, 1fr)', lg: 'minmax(min-content, 200px) minmax(0, 1fr)' }}
overflow="hidden"
>
<BlockDetailsZilliqaQuorumCertificate data={ blockMock.zilliqaWithAggregateQuorumCertificate.zilliqa?.quorum_certificate as ZilliqaQuorumCertificate }/>
</Grid>,
);
await expect(component).toHaveScreenshot();
});

test('aggregated quorum certificate +@mobile', async({ render }) => {
const component = await render(
<Grid
columnGap={ 8 }
rowGap={{ base: 3, lg: 3 }}
templateColumns={{ base: 'minmax(0, 1fr)', lg: 'minmax(min-content, 200px) minmax(0, 1fr)' }}
overflow="hidden"
>
<BlockDetailsZilliqaQuorumCertificate
data={ blockMock.zilliqaWithAggregateQuorumCertificate.zilliqa?.aggregate_quorum_certificate as ZilliqaQuorumCertificate }
/>
</Grid>,
);
await component.getByRole('button', { name: 'Nested quorum certificates' }).click();

await expect(component).toHaveScreenshot();
});
Loading

0 comments on commit bb745fe

Please sign in to comment.