Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of outbound message queue, including expiry mechanism #2227

Merged
merged 1 commit into from
Mar 13, 2019

Conversation

anorth
Copy link
Member

@anorth anorth commented Mar 11, 2019

This is the core of #2146.

This is not yet integrated into the message sender plumbing, which will provide values for chain height,
or chain syncing, which will remove/expire messages.

Copy link
Contributor

@acruikshank acruikshank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little difficult to evaluate this out of the context of the problem it is attempting to solve. I'd prefer a larger PR that includes the integration code. This is a great data structure and the testing is lovely. Looking forward to seeing it integrated.

core/message_queue.go Outdated Show resolved Hide resolved
// in the queue for that address (indicating the message had already been removed).
// Returns an error if the expected nonce is greater than the smallest in the queue.
// The caller may wish to check that the returned message is equal to that expected (not just in nonce value).
func (mq *MessageQueue) RemoveNext(sender address.Address, expectedNonce uint64) (*types.SignedMessage, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear how the caller is going to know the expected nonce.
In general, there's a lot of logic around nonce and block height tracking that I was expecting to see inside this queue. Will this data structure be wrapped in another, smarter message queue looking thing that handles that logic? It seems a bit much for a plumbing struct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caller is going to see a message in a block and read its nonce from that. Nonces should be contiguous, so a gap will error here. But the sequence may also restart from an earlier point after a reorg.


// NextStamp returns the stamp for the next message in the queue for an address, or zero if the
// queue is empty.
func (mq *MessageQueue) NextStamp(sender address.Address) uint64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this exposed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll 'fess up that I can't remember, but I think there was a good reason. I should remove this if unused after integration.


type queuedMessage struct {
msg *types.SignedMessage
stamp uint64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just call this blockHeight? That's the intent, and calling it stamp when it's actually a block height will be confusing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hear you and it's worth talking about it. I intend this data structure to be self contained, in that it implemented the interface and semantics described in its comments. While it does have an intended use case, it's correctness need not depend on that.

It wasn't an obvious answer to use block height for the timeout. If we change our mind, nothing in this structure should need to change.

core/message_queue.go Show resolved Hide resolved
core/message_queue_test.go Outdated Show resolved Hide resolved
core/message_queue_test.go Outdated Show resolved Hide resolved
@anorth
Copy link
Member Author

anorth commented Mar 12, 2019

@acruikshank I can see we have a difference in philosophy here between this and #2237 (I reviewed that before reading here). I have intentionally decoupled the data structure from the hookup/strategy code that will use it (not yet written) and put it up for review to ensure that it stands alone. The abstraction over the definition of block height, etc, is intentional. There is some chance the interface will need changing as I integrate.

I don't yet know what the integration code will be called, but certainly it will be more than just plumbing. A MessageQueueExpirer perhaps. I hope it will be testable in ~isolation, though.

I prefer small PRs that don't do any more than necessary for a self-contained change. I want feedback on the internals here before I do all the hookup work, in case I'm wildly off-target. One alternative approach I could follow (next time) is to do the hookup work but to a stub implementation in one or more PRs, and then fill out the implementation (i.e. top-down). Another alternative is to do all the work in secret and then put up 3-4 PRs, based off each other, for review in parallel. That would give you a lot more context and make it more likely I get the interface exactly right, but I fear the constant chained rebasing involved in such an approach.

@anorth anorth force-pushed the anorth/mqueue branch 3 times, most recently from 82e4c01 to 5c05aad Compare March 12, 2019 02:40
…chanism. The core of #2146.

This is not yet integrated into the message sender plumbing, which will provide values for chain height,
or chain syncing, which will remove/expire messages.
@anorth anorth merged commit 67ca342 into master Mar 13, 2019
@anorth anorth deleted the anorth/mqueue branch March 13, 2019 03:17
frrist pushed a commit that referenced this pull request Mar 13, 2019
…chanism. The core of #2146. (#2227)

This is not yet integrated into the message sender plumbing, which will provide values for chain height, or chain syncing, which will remove/expire messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants