Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Conversation

@patrick-ogrady
Copy link
Contributor

Next, we'll need to implement the AppSender component to send gossip to others.

vm/vm.go Outdated

log.Debug("AppGossip %d transactions are being added to mempool", len(txs))
for _, tx := range txs {
switch vm.mempool.Add(tx) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll also want to verify these txs before insertion (see logic in SubmitTx)

Copy link
Contributor

Choose a reason for hiding this comment

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

You may just want to abstract the inside of that func so you only call notifyBuildBlock after all txs are added to the mempool.

Copy link
Contributor

Choose a reason for hiding this comment

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

SubmitTx may also handle the re-gossiping for you (as you'll want to continue propagating tx to other nodes)

@gyuho gyuho changed the title vm: implement "AppGossip" [AV-1026] vm: implement "AppGossip" Dec 14, 2021
vm/vm.go Outdated

// next iteration should be gossip
// after waiting for this node to build a block
buildBlk = false
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should do something more sophisticated here.

Copy link
Contributor

Choose a reason for hiding this comment

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

vm: batch transactions in "Submit"
mempool: prevent races in mempool

Signed-off-by: Gyuho Lee <[email protected]>
vm/vm.go Outdated
// wait for this node to build a block
// rather than trigger gossip immediately
select {
case <-vm.fromEngine:
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be a timeout here. Maybe something like 1s?

In an ideal world, we have the option to attempt to build a block synchronously (and if can't it says we won't).

Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't build a block, we should still gossip.

Copy link
Contributor

Choose a reason for hiding this comment

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

the real complication here is that there could be stale messages in this channel after we pass here so that on the next read, we think a block was just triggered when there wasn't.

Copy link
Contributor

Choose a reason for hiding this comment

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

What you may need to do is just have an atomic var that you reset before calling NotifyBlockReady

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leaving it as TODO. Looks like, unless we add request ID for each common.PendingTxs, there's no way to confirm the engine events.


// Triggers "AppGossip" on the pending transactions in the mempool.
// "force" is true to re-gossip whether recently gossiped or not
func (vm *VM) GossipTxs(force bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

vm/network.go Outdated
// submit incoming gossip
log.Debug("AppGossip transactions are being submitted", "txs", len(txs))
if err := vm.Submit(txs...); err != nil {
log.Warn(
Copy link
Contributor

Choose a reason for hiding this comment

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

You should only do log.Trace on incoming gossip verification.

Copy link
Contributor

Choose a reason for hiding this comment

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

Otherwise, easy to trigger you to write a shit ton of logs from a malicious peer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No Trace level logging in the one used here. So, switched to Debug level.

@gyuho gyuho merged commit 917b26a into ava-labs:master Dec 18, 2021
@gyuho gyuho deleted the implement-gossip branch December 18, 2021 03:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants