Skip to content

Commit

Permalink
Replace internal/network usage with p2p
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
  • Loading branch information
joshua-kim committed Oct 1, 2024
1 parent ee24ecc commit ea4a5f0
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 530 deletions.
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ava-labs/hypersdk
go 1.21.12

require (
github.com/ava-labs/avalanchego v1.11.12-rc.2
github.com/ava-labs/avalanchego v1.11.12-rc.2.0.20240925164311-0a46687774d3
github.com/bytecodealliance/wasmtime-go/v14 v14.0.0
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593
github.com/gorilla/rpc v1.2.0
Expand Down Expand Up @@ -37,7 +37,7 @@ require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732 // indirect
github.com/ava-labs/coreth v0.13.8 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
Expand All @@ -61,7 +61,6 @@ require (
github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/ethereum/go-ethereum v1.13.14 // indirect
github.com/fjl/memsize v0.0.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
Expand Down
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.11.12-rc.2 h1:H1C0gsTOtwMD3qrouEqry0hfoBIC//9lEiDh/AvpaaY=
github.com/ava-labs/avalanchego v1.11.12-rc.2/go.mod h1:yFx3V31Jy9NFa8GZlgGnwiVf8KGjeF2+Uc99l9Scd/8=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732 h1:wlhGJbmb7s3bU2QWtxKjscGjfHknQiq+cVhhUjONsB8=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732/go.mod h1:RkQLaQ961Xe/sUb3ycn4Qi18vPPuEetTqDf2eDcquAs=
github.com/ava-labs/avalanchego v1.11.12-rc.2.0.20240925164311-0a46687774d3 h1:UBhn6lWfTRHAWHPTV/eAXeGgOefV5XegKnLNPfjZ+io=
github.com/ava-labs/avalanchego v1.11.12-rc.2.0.20240925164311-0a46687774d3/go.mod h1:YzHJbHAJOlRLwG1pxWk4uAI7nvV4cxpgQL1FSAx/H4Y=
github.com/ava-labs/coreth v0.13.8 h1:f14X3KgwHl9LwzfxlN6S4bbn5VA2rhEsNnHaRLSTo/8=
github.com/ava-labs/coreth v0.13.8/go.mod h1:t3BSv/eQv0AlDPMfEDCMMoD/jq1RkUsbFzQAFg5qBcE=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down Expand Up @@ -184,8 +184,6 @@ github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0Hw
github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down
4 changes: 2 additions & 2 deletions internal/gossiper/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"context"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/network/p2p"
)

type Gossiper interface {
Run(common.AppSender)
Run(client *p2p.Client)
Queue(context.Context)
Force(context.Context) error // may be triggered by run already
HandleAppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error
Expand Down
9 changes: 5 additions & 4 deletions internal/gossiper/manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/network/p2p"
"github.com/ava-labs/avalanchego/snow/engine/common"
"go.uber.org/zap"

Expand All @@ -19,7 +20,7 @@ var _ Gossiper = (*Manual)(nil)

type Manual struct {
vm VM
appSender common.AppSender
client *p2p.Client
doneGossip chan struct{}
}

Expand All @@ -30,8 +31,8 @@ func NewManual(vm VM) *Manual {
}
}

func (g *Manual) Run(appSender common.AppSender) {
g.appSender = appSender
func (g *Manual) Run(client *p2p.Client) {
g.client = client

// Only respond to explicitly triggered gossip
close(g.doneGossip)
Expand Down Expand Up @@ -73,7 +74,7 @@ func (g *Manual) Force(ctx context.Context) error {
if err != nil {
return err
}
if err := g.appSender.SendAppGossip(ctx, common.SendConfig{Validators: 10}, b); err != nil {
if err := g.client.AppGossip(ctx, common.SendConfig{Validators: 10}, b); err != nil {
g.vm.Logger().Warn(
"GossipTxs failed",
zap.Error(err),
Expand Down
9 changes: 5 additions & 4 deletions internal/gossiper/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/network/p2p"
"github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/utils/timer"
Expand All @@ -29,7 +30,7 @@ var _ Gossiper = (*Proposer)(nil)
type Proposer struct {
vm VM
cfg *ProposerConfig
appSender common.AppSender
client *p2p.Client
doneGossip chan struct{}

lastVerified int64
Expand Down Expand Up @@ -293,8 +294,8 @@ func (g *Proposer) Queue(context.Context) {
}

// periodically but less aggressively force-regossip the pending
func (g *Proposer) Run(appSender common.AppSender) {
g.appSender = appSender
func (g *Proposer) Run(client *p2p.Client) {
g.client = client
defer close(g.doneGossip)

// Timer blocks until stopped
Expand Down Expand Up @@ -376,5 +377,5 @@ func (g *Proposer) sendTxs(ctx context.Context, txs []*chain.Transaction) error
}
recipients.Add(proposer)
}
return g.appSender.SendAppGossip(ctx, common.SendConfig{NodeIDs: recipients}, b)
return g.client.AppGossip(ctx, common.SendConfig{NodeIDs: recipients}, b)
}
Loading

0 comments on commit ea4a5f0

Please sign in to comment.