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

Factor message packaging out of plumbing into core.Outbox #2795

Merged
merged 4 commits into from
May 22, 2019
Merged

Conversation

anorth
Copy link
Member

@anorth anorth commented May 20, 2019

This is part of follow-up refactoring to the message queue that @acruikshank and I discussed a while ago. Sorry it's a little long: the delta is mostly moving and simplifying the old Sender test to exercise the outbox instead.

I intend to also:

  • move the blocktimer out of message pool (this change means one of the Add callers now knows height)
  • move the policy for handling new tipsets into Outbox

}

// Send marshals and sends a message, retaining it in the outbound message queue.
func (ob *Outbox) Send(ctx context.Context, from, to address.Address, value *types.AttoFIL,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a fairly direct move from msg.Sender, but with tighter dependencies and the message pool/publish extracted to publisher.

"github.com/stretchr/testify/require"
)

func TestOutbox(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

These are ported from the msg.Sender tests, but with fakes instead of real dependencies (chain store, state HAMT etc).

I dropped a few internal tests for nextNonce and added some nonce checks to the existing tests, so this test is now in a _test package.

@@ -119,7 +119,7 @@ type Node struct {
// Incoming messages for block mining.
MsgPool *core.MessagePool
// Messages sent and not yet mined.
Outbox *core.MessageQueue
MsgQueue *core.MessageQueue
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 replace this with the actual outbox object soon.

node/node.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rosalinekarr rosalinekarr left a comment

Choose a reason for hiding this comment

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

Looks great, but I'd really rather not adding duplicate functionality with the actorProvider. Otherwise, just a few questions, but nothing blocking.

core/outbox.go Show resolved Hide resolved
node/node.go Outdated Show resolved Hide resolved
core/outbox.go Show resolved Hide resolved
if err != nil {
return nil, errors.Wrapf(err, "no actor at address %s", addr)
}
return actr, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

With regard to using the chainFacade instead of chainProvider and actorProvider, this method is identical to plumbing/bcf/blockchain_facade.go line 89.

if err = p.network.Publish(p.topic, encoded); err != nil {
return errors.Wrap(err, "failed to publish message to network")
}
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks great, but I'm not totally clear on why this is under node. Why not put it with the outbox? It feels like the node directory has been sort of devolving into a "misc" folder lately.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a package-level dependency injection. The outbox doesn't know or care how messages are published to the network. This change removed the import of net/pubsub by the core package.

It's "wiring" which definitely feels miscellaneous but is what the node package alone should be doing.

plumbing/msg/sender.go Show resolved Hide resolved
@anorth anorth requested a review from rosalinekarr May 21, 2019 05:23
Copy link
Contributor

@rosalinekarr rosalinekarr left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Couldn't find anything wrong. I like that we're moving this code out of plumbing. I'm with @rosalinekarr that I'm a little uneasy adding code to the node package, but I see the reasoning.

core/outbox_test.go Outdated Show resolved Hide resolved
@anorth anorth merged commit 92883c2 into master May 22, 2019
@ZenGround0 ZenGround0 deleted the anorth/sender branch October 29, 2019 14:50
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