Skip to content

Commit

Permalink
Update to avalanchego@master (#1508)
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 authored Sep 5, 2024
1 parent d385a04 commit 9f2bbcd
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 195 deletions.
4 changes: 2 additions & 2 deletions examples/morpheusvm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ava-labs/hypersdk/examples/morpheusvm
go 1.21.12

require (
github.com/ava-labs/avalanchego v1.11.11-0.20240827034238-fc892827880a
github.com/ava-labs/avalanchego v1.11.12-0.20240905030632-718128aacc19
github.com/ava-labs/hypersdk v0.0.1
github.com/fatih/color v1.13.0
github.com/onsi/ginkgo/v2 v2.13.1
Expand All @@ -16,7 +16,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-0.20240802110637-b3e5088d062d // indirect
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732 // 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 Down
8 changes: 4 additions & 4 deletions examples/morpheusvm/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.11-0.20240827034238-fc892827880a h1:TMhT+mI6R1szbDPJFJXVquDnpZX3RJ+HH127K4Fdo3Q=
github.com/ava-labs/avalanchego v1.11.11-0.20240827034238-fc892827880a/go.mod h1:9e0UPXJboybmgFjeTj+SFbK4ugbrdG4t68VdiUW5oQ8=
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d h1:klPTcKVvqfA2KSKaRvQAO56Pd4XAqGhwgMTQ6/W+w7w=
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
github.com/ava-labs/avalanchego v1.11.12-0.20240905030632-718128aacc19 h1:p7nUMQ5/R8l2XdDUlEcJgf4KDW7ZyeqKVfYg6bSnpLg=
github.com/ava-labs/avalanchego v1.11.12-0.20240905030632-718128aacc19/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/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
4 changes: 2 additions & 2 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.11-0.20240827034238-fc892827880a
github.com/ava-labs/avalanchego v1.11.12-0.20240905030632-718128aacc19
github.com/btcsuite/btcd/btcutil v1.1.3
github.com/bytecodealliance/wasmtime-go/v14 v14.0.0
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593
Expand Down Expand Up @@ -38,7 +38,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-0.20240802110637-b3e5088d062d // indirect
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240815193440-a96bc921e732 // 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 Down
8 changes: 4 additions & 4 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.11-0.20240827034238-fc892827880a h1:TMhT+mI6R1szbDPJFJXVquDnpZX3RJ+HH127K4Fdo3Q=
github.com/ava-labs/avalanchego v1.11.11-0.20240827034238-fc892827880a/go.mod h1:9e0UPXJboybmgFjeTj+SFbK4ugbrdG4t68VdiUW5oQ8=
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d h1:klPTcKVvqfA2KSKaRvQAO56Pd4XAqGhwgMTQ6/W+w7w=
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
github.com/ava-labs/avalanchego v1.11.12-0.20240905030632-718128aacc19 h1:p7nUMQ5/R8l2XdDUlEcJgf4KDW7ZyeqKVfYg6bSnpLg=
github.com/ava-labs/avalanchego v1.11.12-0.20240905030632-718128aacc19/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/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
109 changes: 0 additions & 109 deletions internal/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ type Handler interface {
requestID uint32,
response []byte,
) error

CrossChainAppRequest(context.Context, ids.ID, uint32, time.Time, []byte) error
CrossChainAppRequestFailed(context.Context, ids.ID, uint32) error
CrossChainAppResponse(context.Context, ids.ID, uint32, []byte) error
}

func (n *Manager) Register() (uint8, common.AppSender) {
Expand Down Expand Up @@ -273,60 +269,6 @@ func (n *Manager) Disconnected(ctx context.Context, nodeID ids.NodeID) error {
return nil
}

func (n *Manager) CrossChainAppRequest(
ctx context.Context,
chainID ids.ID,
requestID uint32,
deadline time.Time,
msg []byte,
) error {
parsedMsg, handler, ok := n.routeIncomingMessage(msg)
if !ok {
n.log.Debug(
"could not route incoming CrossChainAppRequest",
zap.Stringer("chainID", chainID),
zap.Uint32("requestID", requestID),
)
return nil
}
return handler.CrossChainAppRequest(ctx, chainID, requestID, deadline, parsedMsg)
}

func (n *Manager) CrossChainAppRequestFailed(
ctx context.Context,
chainID ids.ID,
requestID uint32,
) error {
handler, cRequestID, ok := n.handleSharedRequestID(n.nodeID, requestID)
if !ok {
n.log.Debug(
"could not handle incoming CrossChainAppRequestFailed",
zap.Stringer("chainID", chainID),
zap.Uint32("requestID", requestID),
)
return nil
}
return handler.CrossChainAppRequestFailed(ctx, chainID, cRequestID)
}

func (n *Manager) CrossChainAppResponse(
ctx context.Context,
chainID ids.ID,
requestID uint32,
response []byte,
) error {
handler, cRequestID, ok := n.handleSharedRequestID(n.nodeID, requestID)
if !ok {
n.log.Debug(
"could not handle incoming CrossChainAppResponse",
zap.Stringer("chainID", chainID),
zap.Uint32("requestID", requestID),
)
return nil
}
return handler.CrossChainAppResponse(ctx, chainID, cRequestID, response)
}

// WrappedAppSender is used to get a shared requestID and to prepend messages
// with the handler identifier.
type WrappedAppSender struct {
Expand Down Expand Up @@ -403,57 +345,6 @@ func (w *WrappedAppSender) SendAppGossip(ctx context.Context, cfg common.SendCon
)
}

// SendCrossChainAppRequest sends an application-level request to a
// specific chain.
//
// A nil return value guarantees that the VM corresponding to this
// CrossChainAppSender eventually receives either:
// * A CrossChainAppResponse from [chainID] with ID [requestID]
// * A CrossChainAppRequestFailed from [chainID] with ID [requestID]
// Exactly one of the above messages will eventually be received from
// [chainID].
// A non-nil error should be considered fatal.
func (w *WrappedAppSender) SendCrossChainAppRequest(
ctx context.Context,
chainID ids.ID,
requestID uint32,
appRequestBytes []byte,
) error {
newRequestID := w.n.getSharedRequestID(w.handler, w.n.nodeID, requestID)
return w.n.sender.SendCrossChainAppRequest(
ctx,
chainID,
newRequestID,
w.createMessageBytes(appRequestBytes),
)
}

// SendCrossChainAppResponse sends an application-level response to a
// specific chain
//
// This response must be in response to a CrossChainAppRequest that the VM
// corresponding to this CrossChainAppSender received from [chainID] with ID
// [requestID].
// A non-nil error should be considered fatal.
func (w *WrappedAppSender) SendCrossChainAppResponse(
ctx context.Context,
chainID ids.ID,
requestID uint32,
appResponseBytes []byte,
) error {
// We don't need to wrap this response because the sender should know what
// requestID is associated with which handler.
return w.n.sender.SendCrossChainAppResponse(ctx, chainID, requestID, appResponseBytes)
}

// SendCrossChainAppError sends an application-level error to a CrossChainAppRequest
func (w *WrappedAppSender) SendCrossChainAppError(
ctx context.Context, chainID ids.ID, requestID uint32, errorCode int32,
errorMessage string,
) error {
return w.n.sender.SendCrossChainAppError(ctx, chainID, requestID, errorCode, errorMessage)
}

func (w *WrappedAppSender) createMessageBytes(src []byte) []byte {
messageBytes := make([]byte, 1+len(src))
messageBytes[0] = w.handler
Expand Down
18 changes: 0 additions & 18 deletions vm/network_state_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,3 @@ func (s *StateSyncHandler) AppResponse(
) error {
return s.vm.stateSyncNetworkClient.AppResponse(ctx, nodeID, requestID, response)
}

func (*StateSyncHandler) CrossChainAppRequest(
context.Context,
ids.ID,
uint32,
time.Time,
[]byte,
) error {
return nil
}

func (*StateSyncHandler) CrossChainAppRequestFailed(context.Context, ids.ID, uint32) error {
return nil
}

func (*StateSyncHandler) CrossChainAppResponse(context.Context, ids.ID, uint32, []byte) error {
return nil
}
18 changes: 0 additions & 18 deletions vm/network_tx_gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,3 @@ func (*TxGossipHandler) AppResponse(
) error {
return nil
}

func (*TxGossipHandler) CrossChainAppRequest(
context.Context,
ids.ID,
uint32,
time.Time,
[]byte,
) error {
return nil
}

func (*TxGossipHandler) CrossChainAppRequestFailed(context.Context, ids.ID, uint32) error {
return nil
}

func (*TxGossipHandler) CrossChainAppResponse(context.Context, ids.ID, uint32, []byte) error {
return nil
}
38 changes: 0 additions & 38 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1037,44 +1037,6 @@ func (vm *VM) AppResponse(
return vm.networkManager.AppResponse(ctx, nodeID, requestID, response)
}

func (vm *VM) CrossChainAppRequest(
ctx context.Context,
nodeID ids.ID,
requestID uint32,
deadline time.Time,
request []byte,
) error {
ctx, span := vm.tracer.Start(ctx, "VM.CrossChainAppRequest")
defer span.End()

return vm.networkManager.CrossChainAppRequest(ctx, nodeID, requestID, deadline, request)
}

func (vm *VM) CrossChainAppRequestFailed(
ctx context.Context,
nodeID ids.ID,
requestID uint32,
_ *common.AppError,
) error {
ctx, span := vm.tracer.Start(ctx, "VM.CrossChainAppRequestFailed")
defer span.End()

// TODO: add support for handling common.AppError
return vm.networkManager.CrossChainAppRequestFailed(ctx, nodeID, requestID)
}

func (vm *VM) CrossChainAppResponse(
ctx context.Context,
nodeID ids.ID,
requestID uint32,
response []byte,
) error {
ctx, span := vm.tracer.Start(ctx, "VM.CrossChainAppResponse")
defer span.End()

return vm.networkManager.CrossChainAppResponse(ctx, nodeID, requestID, response)
}

// implements "block.ChainVM.commom.VM.validators.Connector"
func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, v *version.Application) error {
ctx, span := vm.tracer.Start(ctx, "VM.Connected")
Expand Down

0 comments on commit 9f2bbcd

Please sign in to comment.