Skip to content

Commit

Permalink
Remove put gossip (#2790)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Mar 6, 2024
1 parent dc03622 commit 90a13f3
Show file tree
Hide file tree
Showing 21 changed files with 66 additions and 412 deletions.
30 changes: 0 additions & 30 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,16 +607,6 @@ func (m *manager) createAvalancheChain(
avalancheMessageSender = sender.Trace(avalancheMessageSender, m.Tracer)
}

err = m.VertexAcceptorGroup.RegisterAcceptor(
ctx.ChainID,
"gossip",
avalancheMessageSender,
false,
)
if err != nil { // Set up the event dispatcher
return nil, fmt.Errorf("problem initializing event dispatcher: %w", err)
}

// Passes messages from the snowman engines to the network
snowmanMessageSender, err := sender.New(
ctx,
Expand All @@ -635,16 +625,6 @@ func (m *manager) createAvalancheChain(
snowmanMessageSender = sender.Trace(snowmanMessageSender, m.Tracer)
}

err = m.BlockAcceptorGroup.RegisterAcceptor(
ctx.ChainID,
"gossip",
snowmanMessageSender,
false,
)
if err != nil { // Set up the event dispatcher
return nil, fmt.Errorf("problem initializing event dispatcher: %w", err)
}

chainConfig, err := m.getChainConfig(ctx.ChainID)
if err != nil {
return nil, fmt.Errorf("error while fetching chain config: %w", err)
Expand Down Expand Up @@ -1000,16 +980,6 @@ func (m *manager) createSnowmanChain(
messageSender = sender.Trace(messageSender, m.Tracer)
}

err = m.BlockAcceptorGroup.RegisterAcceptor(
ctx.ChainID,
"gossip",
messageSender,
false,
)
if err != nil { // Set up the event dispatcher
return nil, fmt.Errorf("problem initializing event dispatcher: %w", err)
}

var (
bootstrapFunc func()
subnetConnector = validators.UnhandledSubnetConnector
Expand Down
8 changes: 2 additions & 6 deletions chains/subnets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,12 @@ func TestSubnetConfigs(t *testing.T) {
config: map[ids.ID]subnets.Config{
constants.PrimaryNetworkID: {},
testSubnetID: {
GossipConfig: subnets.GossipConfig{
AcceptedFrontierValidatorSize: 123456789,
},
ValidatorOnly: true,
},
},
subnetID: testSubnetID,
want: subnets.Config{
GossipConfig: subnets.GossipConfig{
AcceptedFrontierValidatorSize: 123456789,
},
ValidatorOnly: true,
},
},
}
Expand Down
22 changes: 1 addition & 21 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ const (
chainUpgradeFileName = "upgrade"
subnetConfigFileExt = ".json"

keystoreDeprecationMsg = "keystore API is deprecated"
acceptedFrontierGossipDeprecationMsg = "push-based accepted frontier gossip is deprecated"
keystoreDeprecationMsg = "keystore API is deprecated"
)

var (
Expand All @@ -64,13 +63,6 @@ var (
deprecatedKeys = map[string]string{
KeystoreAPIEnabledKey: keystoreDeprecationMsg,

ConsensusGossipAcceptedFrontierValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipAcceptedFrontierNonValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipAcceptedFrontierPeerSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipOnAcceptValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipOnAcceptNonValidatorSizeKey: acceptedFrontierGossipDeprecationMsg,
ConsensusGossipOnAcceptPeerSizeKey: acceptedFrontierGossipDeprecationMsg,

SnowRogueCommitThresholdKey: commitThresholdDeprecationMsg,
SnowVirtuousCommitThresholdKey: commitThresholdDeprecationMsg,
}
Expand Down Expand Up @@ -257,17 +249,6 @@ func getAdaptiveTimeoutConfig(v *viper.Viper) (timer.AdaptiveTimeoutConfig, erro
return config, nil
}

func getGossipConfig(v *viper.Viper) subnets.GossipConfig {
return subnets.GossipConfig{
AcceptedFrontierValidatorSize: uint(v.GetUint32(ConsensusGossipAcceptedFrontierValidatorSizeKey)),
AcceptedFrontierNonValidatorSize: uint(v.GetUint32(ConsensusGossipAcceptedFrontierNonValidatorSizeKey)),
AcceptedFrontierPeerSize: uint(v.GetUint32(ConsensusGossipAcceptedFrontierPeerSizeKey)),
OnAcceptValidatorSize: uint(v.GetUint32(ConsensusGossipOnAcceptValidatorSizeKey)),
OnAcceptNonValidatorSize: uint(v.GetUint32(ConsensusGossipOnAcceptNonValidatorSizeKey)),
OnAcceptPeerSize: uint(v.GetUint32(ConsensusGossipOnAcceptPeerSizeKey)),
}
}

func getNetworkConfig(
v *viper.Viper,
networkID uint32,
Expand Down Expand Up @@ -1112,7 +1093,6 @@ func getDefaultSubnetConfig(v *viper.Viper) subnets.Config {
return subnets.Config{
ConsensusParameters: getConsensusConfig(v),
ValidatorOnly: false,
GossipConfig: getGossipConfig(v),
ProposerMinBlockDelay: proposervm.DefaultMinBlockDelay,
ProposerNumHistoricalBlocks: proposervm.DefaultNumHistoricalBlocks,
}
Expand Down
16 changes: 0 additions & 16 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/consensus/snowball"
"github.com/ava-labs/avalanchego/subnets"
"github.com/ava-labs/avalanchego/utils/constants"
)

func TestGetChainConfigsFromFiles(t *testing.T) {
Expand Down Expand Up @@ -420,20 +419,6 @@ func TestGetSubnetConfigsFromFile(t *testing.T) {
},
expectedErr: nil,
},
"gossip config": {
fileName: "2Ctt6eGAeo4MLqTmGa7AdRecuVMPGWEX9wSsCLBYrLhX4a394i.json",
givenJSON: `{"gossipOnAcceptValidatorSize": 100 }`,
testF: func(require *require.Assertions, given map[ids.ID]subnets.Config) {
id, _ := ids.FromString("2Ctt6eGAeo4MLqTmGa7AdRecuVMPGWEX9wSsCLBYrLhX4a394i")
config, ok := given[id]
require.True(ok)
require.Equal(uint(100), config.GossipConfig.OnAcceptValidatorSize)
// must still respect defaults
require.Equal(20, config.ConsensusParameters.K)
require.Equal(uint(constants.DefaultConsensusGossipOnAcceptPeerSize), config.GossipConfig.OnAcceptPeerSize)
},
expectedErr: nil,
},
}

for name, test := range tests {
Expand Down Expand Up @@ -528,7 +513,6 @@ func TestGetSubnetConfigsFromFlags(t *testing.T) {
require.Equal(20, config.ConsensusParameters.AlphaConfidence)
require.Equal(30, config.ConsensusParameters.K)
// must still respect defaults
require.Equal(uint(constants.DefaultConsensusGossipAcceptedFrontierPeerSize), config.GossipConfig.AcceptedFrontierPeerSize)
require.Equal(256, config.ConsensusParameters.MaxOutstandingItems)
},
expectedErr: nil,
Expand Down
6 changes: 0 additions & 6 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,6 @@ func addNodeFlags(fs *pflag.FlagSet) {
fs.Uint(ConsensusAppConcurrencyKey, constants.DefaultConsensusAppConcurrency, "Maximum number of goroutines to use when handling App messages on a chain")
fs.Duration(ConsensusShutdownTimeoutKey, constants.DefaultConsensusShutdownTimeout, "Timeout before killing an unresponsive chain")
fs.Duration(ConsensusFrontierPollFrequencyKey, constants.DefaultFrontierPollFrequency, "Frequency of polling for new consensus frontiers")
fs.Uint(ConsensusGossipAcceptedFrontierValidatorSizeKey, constants.DefaultConsensusGossipAcceptedFrontierValidatorSize, "Number of validators to gossip to when gossiping accepted frontier")
fs.Uint(ConsensusGossipAcceptedFrontierNonValidatorSizeKey, constants.DefaultConsensusGossipAcceptedFrontierNonValidatorSize, "Number of non-validators to gossip to when gossiping accepted frontier")
fs.Uint(ConsensusGossipAcceptedFrontierPeerSizeKey, constants.DefaultConsensusGossipAcceptedFrontierPeerSize, "Number of peers to gossip to when gossiping accepted frontier")
fs.Uint(ConsensusGossipOnAcceptValidatorSizeKey, constants.DefaultConsensusGossipOnAcceptValidatorSize, "Number of validators to gossip to each accepted container to")
fs.Uint(ConsensusGossipOnAcceptNonValidatorSizeKey, constants.DefaultConsensusGossipOnAcceptNonValidatorSize, "Number of non-validators to gossip to each accepted container to")
fs.Uint(ConsensusGossipOnAcceptPeerSizeKey, constants.DefaultConsensusGossipOnAcceptPeerSize, "Number of peers to gossip to each accepted container to")

// Inbound Throttling
fs.Uint64(InboundThrottlerAtLargeAllocSizeKey, constants.DefaultInboundThrottlerAtLargeAllocSize, "Size, in bytes, of at-large byte allocation in inbound message throttler")
Expand Down
6 changes: 0 additions & 6 deletions config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ const (
ConsensusAppConcurrencyKey = "consensus-app-concurrency"
ConsensusShutdownTimeoutKey = "consensus-shutdown-timeout"
ConsensusFrontierPollFrequencyKey = "consensus-frontier-poll-frequency"
ConsensusGossipAcceptedFrontierValidatorSizeKey = "consensus-accepted-frontier-gossip-validator-size"
ConsensusGossipAcceptedFrontierNonValidatorSizeKey = "consensus-accepted-frontier-gossip-non-validator-size"
ConsensusGossipAcceptedFrontierPeerSizeKey = "consensus-accepted-frontier-gossip-peer-size"
ConsensusGossipOnAcceptValidatorSizeKey = "consensus-on-accept-gossip-validator-size"
ConsensusGossipOnAcceptNonValidatorSizeKey = "consensus-on-accept-gossip-non-validator-size"
ConsensusGossipOnAcceptPeerSizeKey = "consensus-on-accept-gossip-peer-size"
ProposerVMUseCurrentHeightKey = "proposervm-use-current-height"
FdLimitKey = "fd-limit"
IndexEnabledKey = "index-enabled"
Expand Down
13 changes: 4 additions & 9 deletions message/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/proto/pb/p2p"
"github.com/ava-labs/avalanchego/utils/constants"
)

var (
Expand Down Expand Up @@ -106,14 +105,10 @@ func GetRequestID(m any) (uint32, bool) {
return requestID, true
}

// AppGossip is the only message currently not containing a requestID
// Here we assign the requestID already in use for gossiped containers
// to allow a uniform handling of all messages
if _, ok := m.(*p2p.AppGossip); ok {
return constants.GossipMsgRequestID, true
}

return 0, false
// AppGossip is the only inbound message not containing a requestID. For
// ease of handling, imagine that it does have a requestID.
_, ok := m.(*p2p.AppGossip)
return 0, ok
}

type engineTypeGetter interface {
Expand Down
27 changes: 0 additions & 27 deletions snow/engine/common/mock_sender.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 6 additions & 16 deletions snow/engine/common/no_ops_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/message"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/version"
Expand Down Expand Up @@ -180,21 +179,12 @@ func NewNoOpPutHandler(log logging.Logger) PutHandler {
}

func (nop *noOpPutHandler) Put(_ context.Context, nodeID ids.NodeID, requestID uint32, _ []byte) error {
if requestID == constants.GossipMsgRequestID {
nop.log.Verbo("dropping request",
zap.String("reason", "unhandled by this gear"),
zap.Stringer("messageOp", message.PutOp),
zap.Stringer("nodeID", nodeID),
zap.Uint32("requestID", requestID),
)
} else {
nop.log.Debug("dropping request",
zap.String("reason", "unhandled by this gear"),
zap.Stringer("messageOp", message.PutOp),
zap.Stringer("nodeID", nodeID),
zap.Uint32("requestID", requestID),
)
}
nop.log.Debug("dropping request",
zap.String("reason", "unhandled by this gear"),
zap.Stringer("messageOp", message.PutOp),
zap.Stringer("nodeID", nodeID),
zap.Uint32("requestID", requestID),
)
return nil
}

Expand Down
11 changes: 0 additions & 11 deletions snow/engine/common/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/utils/set"
)

Expand Down Expand Up @@ -35,15 +34,12 @@ import (
// time the requestID space has been exhausted, the beginning of the requestID
// space is free of conflicts.
type Sender interface {
snow.Acceptor

StateSummarySender
AcceptedStateSummarySender
FrontierSender
AcceptedSender
FetchSender
QuerySender
Gossiper
AppSender
}

Expand Down Expand Up @@ -160,13 +156,6 @@ type QuerySender interface {
)
}

// Gossiper defines how a consensus engine gossips a container on the accepted
// frontier to other nodes
type Gossiper interface {
// Gossip the provided container throughout the network
SendGossip(ctx context.Context, container []byte)
}

// NetworkAppSender sends VM-level messages to nodes in the network.
type NetworkAppSender interface {
// Send an application-level request.
Expand Down
Loading

0 comments on commit 90a13f3

Please sign in to comment.