Skip to content

Commit 21800de

Browse files
committed
feat: add ORA_SINGLE mainnet verifier
1 parent 8d03d1b commit 21800de

File tree

6 files changed

+45
-14
lines changed

6 files changed

+45
-14
lines changed

src/api/verify.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AggregatorVerifierABI, AggregatorVerifierAddress, PROVER_RPC_CONSTANTS
55
import { ProveTaskNotReady } from '../common/error'
66
import type { BatchOption, ProofParams, ProofParams as VerifyProofParams } from '../types'
77
import { BatchStyle } from '../types'
8+
import { getNetworkNameByChainID } from '../common/utils'
89
import { waitProve } from './prove'
910
// import { VerifyProofParams } from '@ora-io/zkwasm-service-helper'
1011

@@ -37,11 +38,15 @@ export async function verifyOnchain(
3738
if (isZKVerifier === false)
3839
throw new Error('isZKVerifier==false is reserved, not supported yet')
3940
const { provider } = options
40-
const network = (await provider.getNetwork()).name
41+
42+
const chainId = (await provider.getNetwork()).chainId
43+
const network = getNetworkNameByChainID(chainId).toLowerCase()
4144
const defaultVerifierAddress
42-
= batchStyle === BatchStyle.ORA
43-
? AggregatorVerifierAddress.ORA[network]
44-
: AggregatorVerifierAddress.ZKWASMHUB[network]
45+
= batchStyle === BatchStyle.ZKWASMHUB
46+
? AggregatorVerifierAddress.ZKWASMHUB[network]
47+
: batchStyle === BatchStyle.ORA_SINGLE
48+
? AggregatorVerifierAddress.ORA_SINGLE[network]
49+
: AggregatorVerifierAddress.ORA[network]
4550

4651
const { verifierAddress = defaultVerifierAddress } = options
4752

src/common/constants.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ export const networks = [
55
name: 'Sepolia',
66
label: 'Sepolia',
77
value: 11155111,
8+
chainId: 11155111,
89
expectedEth: 0.002,
910
hex: '0xaa36a7',
1011
},
1112
{
1213
name: 'Goerli',
1314
label: 'Goerli',
1415
value: 5,
16+
chainId: 5,
1517
expectedEth: 0.5,
1618
hex: '0x5',
1719
},
1820
{
1921
name: 'Mainnet',
2022
label: 'Mainnet',
2123
value: 1,
24+
chainId: 1,
2225
},
2326
]
2427

@@ -88,6 +91,11 @@ export const AggregatorVerifierAddress: { [key: string]: { [key: string]: string
8891
sepolia: '0xfD74dce645Eb5EB65D818aeC544C72Ba325D93B0',
8992
goerli: '0xbEF9572648284CB63a0DA32a89D3b4F2BeD65a89',
9093
},
94+
ORA_SINGLE: {
95+
mainnet: '0x9B13520f499e95f7e94E8346Ed8F52D2F830d955',
96+
sepolia: 'not support yet',
97+
goerli: 'not support yet',
98+
},
9199
ORA: {
92100
mainnet: 'not support yet',
93101
sepolia: '0xf48dC1e1AaA6bB8cA43b03Ca0695973a2F440090',

src/common/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ export function getTargetNetwork(inputtedNetworkName: string) {
155155
return targetNetwork
156156
}
157157

158+
export function getNetworkNameByChainID(chainId: number) {
159+
const netname = networks.find(
160+
net => net.chainId === chainId,
161+
)?.name
162+
if (netname === undefined)
163+
throw new Error('Unsupported network id')
164+
return netname
165+
}
166+
158167
/**
159168
* normalize DSP params
160169
* @param paramNames

src/requests/ora_prove.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function ora_prove(
3232

3333
// zkwasmhub doesn't accept aux_params
3434

35-
if (batchStyle === BatchStyle.ORA) {
35+
if (batchStyle === BatchStyle.ORA || batchStyle === BatchStyle.ORA_SINGLE) {
3636
if (proverUrl.startsWith(DEFAULT_URL.ZKWASMHUB))
3737
throw new BatchStyleUnsupport('zkwasmhub doesn\'t support ORA batch style, use ProverType.ZKWASMHUB instead.')
3838

src/types/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface ProofParams {
1818

1919
export enum BatchStyle {
2020
ORA,
21+
ORA_SINGLE,
2122
ZKWASMHUB,
2223
}
2324
export interface BatchOption {

tests/verify.test.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { config } from './config'
1010
(global as any).__BROWSER__ = false
1111

1212
const yamlPath = fixtures['dsp/ethereum(event)'].yamlPath
13-
// const proveTaskId = 'QS2lHw1j6ZyxE2NSkwjt58kX' // ora prover proof
13+
// const proveTaskId = 'v4YpdX4UufG89z2CwA26m0OS' // ora prover proof
1414
const proveTaskId = '65dd7dad235cd47b5193efce' // zkwasmhub proof
1515

1616
describe('test verify', () => {
@@ -35,20 +35,28 @@ describe('test verify', () => {
3535
it.only('test verify proof params', async () => {
3636
const proofParams = await cleapi.getVerifyProofParamsByTaskID(config.ZkwasmProviderUrl, proveTaskId)
3737
const network = 'sepolia'
38-
// const sepolia_verifier = '0xDf0946992839A1f2B5aD09D001adF6C0332B1263' // ora verifier
39-
const sepolia_verifier = '0xfD74dce645Eb5EB65D818aeC544C72Ba325D93B0' // zkwasmhub verifier
38+
// const verifierAddress = '0x9B13520f499e95f7e94E8346Ed8F52D2F830d955' // ora verifier
39+
// const verifierAddress = '0xfD74dce645Eb5EB65D818aeC544C72Ba325D93B0' // zkwasmhub verifier
4040

4141
expect(await cleapi.verifyProof(
4242
proofParams,
43-
{ verifierAddress: sepolia_verifier, provider: new ethers.providers.JsonRpcProvider(config.JsonRpcProviderUrl[network]) },
43+
{
44+
// verifierAddress,
45+
provider: new ethers.providers.JsonRpcProvider(config.JsonRpcProviderUrl[network]),
46+
// batchStyle: cleapi.BatchStyle.ORA_SINGLE
47+
},
4448
)).toBeTruthy()
4549

4650
/// / make a wrong proof for test
47-
// proofParams.aggregate_proof[0] = 0x12
48-
// expect(await cleapi.verifyProof(
49-
// proofParams,
50-
// { verifierAddress: sepolia_verifier, provider: new ethers.providers.JsonRpcProvider(rpcUrl) },
51-
// )).toBeFalsy()
51+
proofParams.aggregate_proof[0] = 0x12
52+
expect(await cleapi.verifyProof(
53+
proofParams,
54+
{
55+
// verifierAddress,
56+
provider: new ethers.providers.JsonRpcProvider(config.JsonRpcProviderUrl[network]),
57+
// batchStyle: cleapi.BatchStyle.ORA_SINGLE
58+
},
59+
)).toBeFalsy()
5260
}, {
5361
timeout: 1000000,
5462
})

0 commit comments

Comments
 (0)