Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/handlers/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (h *SigningHandler) HandleSigning(w http.ResponseWriter, r *http.Request) {

err = <-errChn
if err != nil {
JSONError(w, fmt.Errorf("singing failed: %s", err), http.StatusInternalServerError)
JSONError(w, fmt.Errorf("signing failed: %s", err), http.StatusInternalServerError)
return
}

Expand Down
10 changes: 9 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"github.com/sprintertech/lifi-solver/pkg/pricing"
"github.com/sprintertech/lifi-solver/pkg/protocols"
"github.com/sprintertech/lifi-solver/pkg/protocols/lifi/validation"
"github.com/sprintertech/lifi-solver/pkg/router"
"github.com/sprintertech/lifi-solver/pkg/token"
"github.com/sprintertech/lifi-solver/pkg/tokenpricing/pyth"
solverConfig "github.com/sprintertech/solver-config/go/config"
Expand All @@ -32,6 +34,8 @@ import (
"github.com/sprintertech/sprinter-signing/chains/evm/calls/events"
evmListener "github.com/sprintertech/sprinter-signing/chains/evm/listener"
evmMessage "github.com/sprintertech/sprinter-signing/chains/evm/message"

lifiConfig "github.com/sprintertech/lifi-solver/pkg/config"
"github.com/sprintertech/sprinter-signing/chains/lighter"
lighterMessage "github.com/sprintertech/sprinter-signing/chains/lighter/message"
"github.com/sprintertech/sprinter-signing/comm"
Expand Down Expand Up @@ -292,10 +296,13 @@ func Run() error {
err = usdPricer.Start(ctx)
panicOnError(err)

lifiConfig, err := lifiConfig.GetSolverConfig(protocols.LifiEscrow, lifiConfig.PulsarSolver, solverConfig)
panicOnError(err)

resolver := token.NewTokenResolver(solverConfig, usdPricer)
orderPricer := pricing.NewStandardPricer(resolver)
lifiApi := lifi.NewLifiAPI()
lifiValidator := validation.NewLifiEscrowOrderValidator(solverConfig, orderPricer, resolver)
lifiValidator := validation.NewLifiEscrowOrderValidator(solverConfig, resolver)

lifiMh := evmMessage.NewLifiEscrowMessageHandler(
*c.GeneralChainConfig.Id,
Expand All @@ -309,6 +316,7 @@ func Run() error {
tokenStore,
lifiApi,
orderPricer,
router.NewRouter(resolver, nil, nil, lifiConfig.Routes),
lifiValidator,
sigChn,
)
Expand Down
12 changes: 10 additions & 2 deletions chains/evm/message/lifiEscrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,22 @@ import (

"github.com/sprintertech/lifi-solver/pkg/pricing"
"github.com/sprintertech/lifi-solver/pkg/protocols/lifi"
"github.com/sprintertech/lifi-solver/pkg/router"
)

type OrderFetcher interface {
GetOrder(orderID string) (*lifi.LifiOrder, error)
}

type OrderValidator interface {
Validate(order *lifi.LifiOrder) error
Validate(order *lifi.AugmentedLifiOrder) error
}

type LifiEscrowMessageHandler struct {
chainID uint64
validator OrderValidator
orderPricer pricing.OrderPricer
router router.OrderRouter
confirmationWatcher ConfirmationWatcher

lifiAddresses map[uint64]common.Address
Expand Down Expand Up @@ -64,6 +66,7 @@ func NewLifiEscrowMessageHandler(
tokenStore config.TokenStore,
orderFetcher OrderFetcher,
orderPricer pricing.OrderPricer,
router router.OrderRouter,
validator OrderValidator,
sigChn chan any,
) *LifiEscrowMessageHandler {
Expand All @@ -81,6 +84,7 @@ func NewLifiEscrowMessageHandler(
orderPricer: orderPricer,
validator: validator,
sigChn: sigChn,
router: router,
}
}

Expand Down Expand Up @@ -257,7 +261,11 @@ func (h *LifiEscrowMessageHandler) verifyOrder(order *lifi.LifiOrder, borrowAmou
return fmt.Errorf("order input is less than requested borrow amount")
}

return h.validator.Validate(order)
augmentedOrder, err := order.AugmentedOrder(h.orderPricer, h.router)
if err != nil {
return err
}
return h.validator.Validate(augmentedOrder)
}

func (h *LifiEscrowMessageHandler) Listen(ctx context.Context) {
Expand Down
28 changes: 4 additions & 24 deletions chains/evm/message/lifiEscrow_test.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
package message_test

import (
"encoding/json"
"fmt"
"math/big"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
lifiTypes "github.com/sprintertech/lifi-solver/pkg/protocols/lifi"
"github.com/sprintertech/sprinter-signing/chains/evm/message"
mock_message "github.com/sprintertech/sprinter-signing/chains/evm/message/mock"
"github.com/sprintertech/sprinter-signing/comm"
mock_communication "github.com/sprintertech/sprinter-signing/comm/mock"
mock_host "github.com/sprintertech/sprinter-signing/comm/p2p/mock/host"
"github.com/sprintertech/sprinter-signing/config"
"github.com/sprintertech/sprinter-signing/keyshare"
"github.com/sprintertech/sprinter-signing/protocol/lifi/mock"
mock_tss "github.com/sprintertech/sprinter-signing/tss/ecdsa/common/mock"
"github.com/stretchr/testify/suite"
coreMessage "github.com/sygmaprotocol/sygma-core/relayer/message"
"go.uber.org/mock/gomock"
)

/*
type LifiEscrowMessageHandlerTestSuite struct {
suite.Suite

Expand Down Expand Up @@ -111,6 +88,7 @@ func (s *LifiEscrowMessageHandlerTestSuite) SetupTest() {
tokenStore,
s.mockOrderFetcher,
s.mockOrderPricer,
nil,
s.mockOrderValidator,
s.sigChn,
)
Expand Down Expand Up @@ -226,3 +204,5 @@ func (s *LifiEscrowMessageHandlerTestSuite) Test_HandleMessage_ValidOrder() {
err = <-errChn
s.Nil(err)
}

*/
2 changes: 1 addition & 1 deletion chains/evm/message/mock/lifiEscrow.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion chains/evm/message/unlock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (s *LifiUnlockHandlerTestSuite) SetupTest() {
gomock.Any(),
gomock.Any(),
comm.LifiUnlockMsg,
fmt.Sprintf("%d-%s", 10, comm.LifiUnlockMsg),
fmt.Sprintf("%d-%s", 10, comm.LifiUnlockSessionID),
).Return(nil)

s.handler = message.NewLifiUnlockHandler(
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/rs/zerolog v1.25.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.9.0
github.com/sprintertech/lifi-solver v0.0.0-20251023154209-4cf9ac1ab166
github.com/sprintertech/lifi-solver v0.0.0-20251106144931-4586926e1a4c
github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e
github.com/stretchr/testify v1.10.0
github.com/sygmaprotocol/sygma-core v0.0.0-20250304150334-bd39ac4f7b82
Expand Down Expand Up @@ -70,6 +70,8 @@ require (
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.3.2 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cn
github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/ferranbt/fastssz v0.1.4 h1:OCDB+dYDEQDvAgtAGnTSidK1Pe2tW3nFV40XyMkTeDY=
github.com/ferranbt/fastssz v0.1.4/go.mod h1:Ea3+oeoRGGLGm5shYAeDgu6PGUlcvQhE2fILyD9+tGg=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
Expand Down Expand Up @@ -494,6 +496,8 @@ github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
Expand Down Expand Up @@ -946,8 +950,8 @@ github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.9.0 h1:yR6EXjTp0y0cLN8OZg1CRZmOBdI88UcGkhgyJhu6nZk=
github.com/spf13/viper v1.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4=
github.com/sprintertech/lifi-solver v0.0.0-20251023154209-4cf9ac1ab166 h1:mCcKOxfLs+5tFGD5ZyVVMeqlUuNzhHttul05x27zWFo=
github.com/sprintertech/lifi-solver v0.0.0-20251023154209-4cf9ac1ab166/go.mod h1:EbAH3JJxioBVuHvyjaP5zTh6uPmumCpbE93WEjwpRm0=
github.com/sprintertech/lifi-solver v0.0.0-20251106144931-4586926e1a4c h1:gt7WBOMG049RFW0E0tq7t5PuaU3utWDgbzzq98iMyug=
github.com/sprintertech/lifi-solver v0.0.0-20251106144931-4586926e1a4c/go.mod h1:3yuTgBKvA5WLCFsXXuBnOzk5nNS58phc881uXLGfD0o=
github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e h1:5sSP6GbqCT/ApxxZmUtav6GHy5Ke98zh5oqQxewhJd4=
github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ=
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
Expand Down
4 changes: 2 additions & 2 deletions tss/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (c *Coordinator) handleError(ctx context.Context, err error, tssProcesses [
}
rp.Go(func(ctx context.Context) error { return c.retry(ctx, tssProcesses, resultChn, excludedPeers) })
} else if errors.As(err, &subsetError) {
// wait for start message if existing singing process fails
// wait for start message if existing signing process fails
rp.Go(func(ctx context.Context) error {
return c.waitForStart(ctx, tssProcesses, resultChn, peer.ID(""))
})
Expand Down Expand Up @@ -316,7 +316,7 @@ func (c *Coordinator) waitForStart(
log.Debug().Str("SessionID", tssProcess.SessionID()).Msgf("received start message from %s", startMsg.From)

// having startMsg.From as "" is special case when peer is not selected in subset
// but should wait for start message if existing singing process fails
// but should wait for start message if existing signing process fails
if coordinator != "" && startMsg.From != coordinator {
log.Warn().Msgf("Received start message from a peer %s that is not the coordinator %s", startMsg.From.String(), coordinator.String())
continue
Expand Down
Loading