Skip to content

Commit

Permalink
update pvg calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
mouseless0x committed Dec 17, 2024
1 parent 86e1ea7 commit f864a3c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import {
parseGwei,
maxUint256,
toHex,
size
size,
concat,
slice
} from "viem"
import { base, baseGoerli, baseSepolia, lineaSepolia } from "viem/chains"
import { maxBigInt, minBigInt, scaleBigIntByPercent } from "./bigInt"
Expand Down Expand Up @@ -529,13 +531,25 @@ function getOpStackHandleOpsCallData(
) {
// Only randomize signature during estimations.
if (!verify) {
const randomizeBytes = (length: number) => {
return toHex(crypto.randomBytes(length).toString("hex"))
const randomizeBytes = (length: number) =>
toHex(crypto.randomBytes(length).toString("hex"))

const sigLength = size(op.signature)
let newSignature: `0x${string}`

if (sigLength < 32) {
// For short signatures, randomize the entire thing
newSignature = randomizeBytes(sigLength)
} else {
// For longer signatures, only randomize the last 32 bytes
const originalPart = slice(op.signature, 0, sigLength - 32)
const randomPart = randomizeBytes(32)
newSignature = concat([originalPart, randomPart])
}

op = {
...op,
signature: randomizeBytes(size(op.signature))
signature: newSignature
}
}

Expand Down

0 comments on commit f864a3c

Please sign in to comment.