ssbc / ssb-db

A database of unforgeable append-only feeds, optimized for efficient replication for peer to peer protocols
https://scuttlebot.io/
MIT License
1.17k stars 75 forks source link

should never happen - seq too high #79

Closed pfrazee closed 9 years ago

pfrazee commented 9 years ago

a user installed latest without clearing their .ssb, then used a grimwire invite. now, during gossip, my client crashes with

/Users/paulfrazee/secure-scuttlebutt/validation.js:217
        throw new Error('should never happen - seq too high')
              ^
Error: should never happen - seq too high
    at validate (/Users/paulfrazee/secure-scuttlebutt/validation.js:217:15)
    at /Users/paulfrazee/secure-scuttlebutt/validation.js:227:7
    at Object.v.validate (/Users/paulfrazee/secure-scuttlebutt/validation.js:241:14)
    at EventEmitter.db.add (/Users/paulfrazee/secure-scuttlebutt/index.js:152:16)
    at /Users/paulfrazee/secure-scuttlebutt/index.js:235:12
    at /Users/paulfrazee/secure-scuttlebutt/node_modules/pull-paramap/index.js:41:11
    at check (/Users/paulfrazee/scuttlebot/node_modules/pull-many/index.js:71:16)
    at next (/Users/paulfrazee/scuttlebot/node_modules/pull-many/index.js:101:21)
    at Object.weird.read (/Users/paulfrazee/scuttlebot/node_modules/muxrpc/pull-weird.js:24:7)
    at onStream (/Users/paulfrazee/scuttlebot/node_modules/muxrpc/node_modules/packet-stream/index.js:90:14)
pfrazee commented 9 years ago

this is from the feed with oversized messages (<1024 bytes). the oversized message is rejected now, and that should halt further replication with the feed. instead, there's a gap in the feed and that's making it panic

the prev and next that show the gap:

{ previous: 'em5PN9gXPu79aMuaVSoec7B4eVFw5Rdfm7x5fbrMPfI=.blake2s',
  author: 'r+MiCfhoSQm10BfneXkmtG/H5sioWZW0yrPOkXr5i94=.blake2s',
  sequence: 117,
  timestamp: 1419896017580,
  hash: 'blake2s',
  content: 
   { type: 'follow',
     rel: 'follows',
     feed: 'wuDDnMxVtk8U9hrueDj/T0itgp5HJZ4ZDEJodTyoMdg=.blake2s' },
  signature: 'sJ9QyqfNA1zAPCSV1ZLuzrV0X8SZk9PNqVkeqiZsGs/u1HtT0VJKh1eh3VW865U5cTfSN5NyFitHzvqKDyZZEw==.blake2s.k256' }
{ previous: 'StuL0ufrLKPwgU0V/hjE2iNDX8YFGvED/qp35xRd2P4=.blake2s',
  author: 'r+MiCfhoSQm10BfneXkmtG/H5sioWZW0yrPOkXr5i94=.blake2s',
  sequence: 119,
  timestamp: 1419977402528,
  hash: 'blake2s',
  content: 
   { type: 'post',
     postType: 'text',
     text: 'it, uh, wasnt big enough. trying to set off the size limit here. Trying again...',
     repliesTo: 
      { msg: 'StuL0ufrLKPwgU0V/hjE2iNDX8YFGvED/qp35xRd2P4=.blake2s',
        rel: 'replies-to' } },
  signature: 'a6M+khOMgT+faz/QHrrBlfI9lv3KBlvytr1VEiuE0ydCXAjzi2liutsYLQPwPz5q+zg9DsMTdIbpuNCNAKC5Nw==.blake2s.k256' }

@dominictarr you probably know the most elegant way to solve this

dominictarr commented 9 years ago

Right, so did you clear your .ssb but keep the same key? I think what we need to do is just ignore every message after that, but not crash.

pfrazee commented 9 years ago

no, i cleared my entire .ssb. my old feed just got replicated back to me

i was able to fix it by making the "seq too high" an expected error condition instead of a throw

On Tue, Jan 20, 2015 at 1:07 AM, Dominic Tarr notifications@github.com wrote:

Right, so did you clear your .ssb but keep the same key? I think what we need to do is just ignore every message after that, but not crash.

— Reply to this email directly or view it on GitHub https://github.com/ssbc/secure-scuttlebutt/issues/79#issuecomment-70612779 .

dominictarr commented 9 years ago

can we close this, now that ssbc/secure-scuttlebutt#78 is merged?

pfrazee commented 9 years ago

yeah