Skip to content

Commit

Permalink
handling incomplete channel
Browse files Browse the repository at this point in the history
  • Loading branch information
luke7211 committed Jan 13, 2024
1 parent 9db933f commit dcbb2af
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/optimism-decoder/src/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,26 @@ export async function decodeOpStackSequencerBatch(
console.log('ChannelId:', channelId)
const frame_number = reader.readU16BE()
console.log('Frame Number:', frame_number)
if (frame_number !== 0) {
console.log(
"This is not a first frame, I won't be able to decompress this, exiting...",
)
return
}
const frame_data_length = reader.readU32BE()
console.log('Frame Data Length:', frame_data_length)
// console.log(reader.left())
const bytes = reader.readBytes(frame_data_length)
const is_last = reader.readBytes(1).toString('hex')
assert(is_last === '01' || is_last === '00')
console.log('Is Last:', is_last === '01')
if (is_last === '00') {
console.log(
"This is not a last frame, I won't be able to decompress this, exiting...",
)
return
}

const inflated = zlib.inflateSync(bytes)

// ----- reading decompressed data -----
Expand Down

0 comments on commit dcbb2af

Please sign in to comment.