-
Notifications
You must be signed in to change notification settings - Fork 9
sdk/state: new state StateClosedWithOutdatedState #324
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic looks great 👍🏻. I think as a follow up this functionality could be refactored inside of txbuild, that would continue to keep logic about sequence numbers in that package.
sdk/txbuild/sequence.go
Outdated
func SequenceNumberToTransactionType(startingSeqNum, seqNum int64) TransactionType { | ||
if startingSeqNum%m == seqNum%m { | ||
return TransactionTypeDeclaration | ||
} | ||
return TransactionTypeClose | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some tests that demonstrate even and odd starting sequences, and then both tx types? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good idea c1426f1
writing the test made me think that we should add a TransactionTypeOpen
(if they're the same)
also there's 1 unique case of the startingSequence + 1, which isn't a transaction type. Maybe we should add a type for that as well (it would be something like TransactionTypeNone)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added them here
d5e1329
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can focus on the transaction types being for close agreements then, because I don't think we get much bang out of adding other types.
I wouldn't worry about adding the none case either, we don't sign txs with those sequence numbers. I'd just panic in that case, it's code that should never be hit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the panic 0b1d1df
imo I think the TransactionTypeFormation
makes sense, isn't used now but may save a bug down the line if someone means to get the formation tx seq and not the declaration tx seq 🤷
up to you though I can remove if it's added code for no reason
edit: "if they meant to be referring to a formation tx and not a declaration tx" I mean
…payment-channels into acharb-ingestclose
WHAT
if the seq num gets moved to a seq corresponding to an early close transaction (close transaction other than the latestAuthorized one) then the channel state will return a new state
StateClosedWithOutdatedState
, and close the channel from ingesting new transactionsWHY
currently the channel stays on
StateClosingWithOutdatedState
if we've ingested an earlier closeTx. The channel state should return closed since that's what occurred on the network. Also we should block new transactions from being ingested so that EI submitting new transactions does not interfere with the channel state.closes #308