node: cleanup buffer size configuration

This commit is contained in:
tbjump 2023-05-24 20:25:43 +00:00 committed by tbjump
parent 44c8146c3f
commit a1ce981b49
3 changed files with 14 additions and 8 deletions

View File

@ -62,6 +62,15 @@ import (
googleapi_option "google.golang.org/api/option"
)
const (
inboundObservationBufferSize = 50
inboundSignedVaaBufferSize = 50
observationRequestOutboundBufferSize = 50
observationRequestInboundBufferSize = 50
// observationRequestBufferSize is the buffer size of the per-network reobservation channel
observationRequestBufferSize = 25
)
var (
p2pNetworkID *string
p2pPort *uint
@ -403,9 +412,6 @@ var NodeCmd = &cobra.Command{
// guardians to reduce risk from a compromised builder.
var Build = "prod"
// observationRequestBufferSize is the buffer size of the per-network reobservation channel
const observationRequestBufferSize = 25
func runNode(cmd *cobra.Command, args []string) {
if Build == "dev" && !*unsafeDevMode {
fmt.Println("This is a development build. --unsafeDevMode must be enabled.")
@ -907,13 +913,13 @@ func runNode(cmd *cobra.Command, args []string) {
setReadC, setWriteC := makeChannelPair[*common.GuardianSet](0)
// Inbound signed VAAs
signedInReadC, signedInWriteC := makeChannelPair[*gossipv1.SignedVAAWithQuorum](50)
signedInReadC, signedInWriteC := makeChannelPair[*gossipv1.SignedVAAWithQuorum](inboundSignedVaaBufferSize)
// Inbound observation requests from the p2p service (for all chains)
obsvReqReadC, obsvReqWriteC := makeChannelPair[*gossipv1.ObservationRequest](common.ObsvReqChannelSize)
obsvReqReadC, obsvReqWriteC := makeChannelPair[*gossipv1.ObservationRequest](observationRequestInboundBufferSize)
// Outbound observation requests
obsvReqSendReadC, obsvReqSendWriteC := makeChannelPair[*gossipv1.ObservationRequest](common.ObsvReqChannelSize)
obsvReqSendReadC, obsvReqSendWriteC := makeChannelPair[*gossipv1.ObservationRequest](observationRequestOutboundBufferSize)
// Injected VAAs (manually generated rather than created via observation)
injectReadC, injectWriteC := makeChannelPair[*vaa.VAA](0)

View File

@ -6,8 +6,6 @@ import (
gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
)
const ObsvReqChannelSize = 50
var ErrChanFull = errors.New("channel is full")
func PostObservationRequest(obsvReqSendC chan<- *gossipv1.ObservationRequest, req *gossipv1.ObservationRequest) error {

View File

@ -11,6 +11,8 @@ import (
)
func TestObsvReqSendLimitEnforced(t *testing.T) {
const ObsvReqChannelSize = 50
obsvReqSendC := make(chan *gossipv1.ObservationRequest, ObsvReqChannelSize)
// If the channel overflows, the write hangs, so use a go routine with a timeout.