Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warp API support #345

Merged
merged 15 commits into from
Jun 26, 2024
58 changes: 30 additions & 28 deletions relayer/application_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ var (
// to a specific destination address on a specific destination blockchain. This routing information is
// encapsulated in [relayerID], which also represents the database key for an ApplicationRelayer.
type ApplicationRelayer struct {
logger logging.Logger
metrics *ApplicationRelayerMetrics
network *peers.AppRequestNetwork
messageCreator message.Creator
sourceBlockchain config.SourceBlockchain
signingSubnetID ids.ID
destinationClient vms.DestinationClient
relayerID database.RelayerID
warpQuorum config.WarpQuorum
checkpointManager *checkpoint.CheckpointManager
currentRequestID uint32
lock *sync.RWMutex
warpClient *rpc.Client
logger logging.Logger
metrics *ApplicationRelayerMetrics
network *peers.AppRequestNetwork
messageCreator message.Creator
sourceBlockchain config.SourceBlockchain
signingSubnetID ids.ID
destinationClient vms.DestinationClient
relayerID database.RelayerID
warpQuorum config.WarpQuorum
checkpointManager *checkpoint.CheckpointManager
currentRequestID uint32
lock *sync.RWMutex
sourceWarpSignatureClient *rpc.Client
}

func NewApplicationRelayer(
Expand Down Expand Up @@ -130,19 +130,19 @@ func NewApplicationRelayer(
}

ar := ApplicationRelayer{
logger: logger,
metrics: metrics,
network: network,
messageCreator: messageCreator,
sourceBlockchain: sourceBlockchain,
destinationClient: destinationClient,
relayerID: relayerID,
signingSubnetID: signingSubnet,
warpQuorum: quorum,
checkpointManager: checkpointManager,
currentRequestID: rand.Uint32(), // TODONOW: pass via ctor
lock: &sync.RWMutex{},
warpClient: warpClient,
logger: logger,
metrics: metrics,
network: network,
messageCreator: messageCreator,
sourceBlockchain: sourceBlockchain,
destinationClient: destinationClient,
relayerID: relayerID,
signingSubnetID: signingSubnet,
warpQuorum: quorum,
checkpointManager: checkpointManager,
currentRequestID: rand.Uint32(), // TODONOW: pass via ctor
lock: &sync.RWMutex{},
sourceWarpSignatureClient: warpClient,
}

return &ar, nil
Expand Down Expand Up @@ -229,7 +229,9 @@ func (r *ApplicationRelayer) relayMessage(
startCreateSignedMessageTime := time.Now()
// Query nodes on the origin chain for signatures, and construct the signed warp message.
var signedMessage *avalancheWarp.Message
if r.sourceBlockchain.UseAppRequestNetwork() {

// sourceWarpSignatureClient is nil iff the source blockchain is configured to fetch signatures via AppRequest
cam-schultz marked this conversation as resolved.
Show resolved Hide resolved
if r.sourceWarpSignatureClient == nil {
signedMessage, err = r.createSignedMessageAppRequest(unsignedMessage, requestID)
if err != nil {
r.logger.Error(
Expand Down Expand Up @@ -291,7 +293,7 @@ func (r *ApplicationRelayer) createSignedMessage(unsignedMessage *avalancheWarp.
zap.String("signingSubnetID", r.signingSubnetID.String()),
)

err = r.warpClient.CallContext(
err = r.sourceWarpSignatureClient.CallContext(
context.Background(),
&signedWarpMessageBytes,
"warp_getMessageAggregateSignature",
Expand Down