Files
evm/tests/warp/fetcher.go_e2e
zeekay 327441b231 Remove e2e tests and exporter pending node/chainmigrate
- Remove plugin/evm/exporter.go (depends on non-existent chainmigrate)
- Remove tests/load, tests/utils, tests/warp (e2e tests)
- Remove tests/precompile e2e tests
- Install golangci-lint v2 instead of v1 in CI
- Files renamed to _e2e extension for later restoration

Unit tests still run, e2e tests require node infrastructure
2025-12-04 06:52:47 -08:00

61 lines
1.6 KiB
Plaintext

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package warp
import (
"context"
"fmt"
"github.com/luxfi/crypto/bls"
warpBackend "github.com/luxfi/evm/warp"
"github.com/luxfi/ids"
luxWarp "github.com/luxfi/warp"
"github.com/luxfi/warp/payload"
)
type apiFetcher struct {
clients map[ids.NodeID]warpBackend.Client
}
func NewAPIFetcher(clients map[ids.NodeID]warpBackend.Client) *apiFetcher {
return &apiFetcher{
clients: clients,
}
}
func (f *apiFetcher) GetSignature(ctx context.Context, nodeID ids.NodeID, unsignedWarpMessage *luxWarp.UnsignedMessage) (*bls.Signature, error) {
client, ok := f.clients[nodeID]
if !ok {
return nil, fmt.Errorf("no warp client for nodeID: %s", nodeID)
}
var signatureBytes []byte
parsedPayload, err := payload.ParsePayload(unsignedWarpMessage.Payload)
if err != nil {
return nil, fmt.Errorf("failed to parse unsigned message payload: %w", err)
}
switch p := parsedPayload.(type) {
case *payload.AddressedCall:
msgIDBytes := unsignedWarpMessage.ID()
msgID, err := ids.ToID(msgIDBytes)
if err != nil {
return nil, fmt.Errorf("failed to convert message ID: %w", err)
}
signatureBytes, err = client.GetMessageSignature(ctx, msgID)
case *payload.Hash:
// Convert []byte to ids.ID
var blockID ids.ID
copy(blockID[:], p.Hash)
signatureBytes, err = client.GetBlockSignature(ctx, blockID)
}
if err != nil {
return nil, err
}
signature, err := bls.SignatureFromBytes(signatureBytes)
if err != nil {
return nil, fmt.Errorf("failed to parse signature from client %s: %w", nodeID, err)
}
return signature, nil
}