Skip to content

Commit

Permalink
Add support of the new message prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
AllFi committed Dec 11, 2023
1 parent e603e42 commit 52fe878
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions zp-relayer/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const constants = {
randomize: true,
},
MESSAGE_PREFIX_COMMON_V1: '0000',
MESSAGE_PREFIX_COMMON_V2: '0100',
HEADER_TRACE_ID: 'zkbob-support-id' as const,
HEADER_LIBJS: 'zkbob-libjs-version' as const,
LIBJS_MIN_VERSION: '2.0.0',
Expand Down
4 changes: 2 additions & 2 deletions zp-relayer/validation/tx/validateTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { Limits, Pool } from '@/pool'
import type { NullifierSet } from '@/state/nullifierSet'
import { web3 } from '@/services/web3'
import { applyDenominator, contractCallRetry, numToHex, truncateMemoTxPrefix, unpackSignature } from '@/utils/helpers'
import { ZERO_ADDRESS, MESSAGE_PREFIX_COMMON_V1, MOCK_CALLDATA } from '@/utils/constants'
import { ZERO_ADDRESS, MESSAGE_PREFIX_COMMON_V1, MESSAGE_PREFIX_COMMON_V2, MOCK_CALLDATA } from '@/utils/constants'
import { getTxProofField, parseDelta } from '@/utils/proofInputs'
import type { TxPayload } from '@/queue/poolTxQueue'
import type { PoolState } from '@/state/PoolState'
Expand Down Expand Up @@ -189,7 +189,7 @@ function checkPoolId(deltaPoolId: BN, contractPoolId: BN) {

function checkMemoPrefix(memo: string, txType: TxType) {
const numItemsSuffix = truncateMemoTxPrefix(memo, txType).substring(4, 8)
if (numItemsSuffix === MESSAGE_PREFIX_COMMON_V1) {
if (numItemsSuffix === MESSAGE_PREFIX_COMMON_V1 || numItemsSuffix === MESSAGE_PREFIX_COMMON_V2) {
return null
}
return new TxValidationError(`Memo prefix is incorrect: ${numItemsSuffix}`)
Expand Down

0 comments on commit 52fe878

Please sign in to comment.