Skip to content

Commit 269976d

Browse files
authored
fix: lighter signing hash (#93)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> ## Related Issue Or Context <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Otherwise, describe context and motivation for change herre --> Closes: #<issue> ## How Has This Been Tested? Testing details. <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have ensured that all acceptance criteria (or expected behavior) from issue are met - [ ] I have updated the documentation locally and in docs. - [ ] I have added tests to cover my changes. - [ ] I have ensured that all the checks are passing and green, I've signed the CLA bot
1 parent a6b55ac commit 269976d

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

chains/lighter/message/lighter.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/rs/zerolog/log"
1616
"github.com/sprintertech/sprinter-signing/chains/evm/calls/consts"
1717
"github.com/sprintertech/sprinter-signing/chains/evm/signature"
18+
lighterChain "github.com/sprintertech/sprinter-signing/chains/lighter"
1819
"github.com/sprintertech/sprinter-signing/comm"
1920
"github.com/sprintertech/sprinter-signing/protocol/lighter"
2021
"github.com/sprintertech/sprinter-signing/tss"
@@ -118,7 +119,7 @@ func (h *LighterMessageHandler) HandleMessage(m *message.Message) (*proposal.Pro
118119
return nil, err
119120
}
120121

121-
sessionID := fmt.Sprintf("lighter-%s", "")
122+
sessionID := fmt.Sprintf("%d-%s", lighterChain.LIGHTER_DOMAIN_ID, data.OrderHash)
122123
signing, err := signing.NewSigning(
123124
new(big.Int).SetBytes(unlockHash),
124125
sessionID,
@@ -147,7 +148,7 @@ func (h *LighterMessageHandler) verifyWithdrawal(tx *lighter.LighterTx, borrowAm
147148
}
148149

149150
if borrowAmount.Cmp(new(big.Int).SetUint64(tx.Transfer.USDCAmount)) != -1 {
150-
return errors.New("borrow amount higher transfer amount")
151+
return errors.New("borrow amount higher than transfer amount")
151152
}
152153

153154
return nil

chains/lighter/message/lighter_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_ValidMessage() {
8585
LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"),
8686
Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"),
8787
OrderHash: "orderHash",
88+
DepositTxHash: "orderHash",
8889
BorrowAmount: big.NewInt(1900000),
8990
}
9091

@@ -128,6 +129,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidTxType() {
128129
LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"),
129130
Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"),
130131
OrderHash: "orderHash",
132+
DepositTxHash: "orderHash",
131133
BorrowAmount: big.NewInt(1900000),
132134
}
133135
s.mockTxFetcher.EXPECT().GetTx(ad.OrderHash).Return(&lighter.LighterTx{
@@ -169,6 +171,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidAccount() {
169171
LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"),
170172
Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"),
171173
OrderHash: "orderHash",
174+
DepositTxHash: "orderHash",
172175
BorrowAmount: big.NewInt(1900000),
173176
}
174177
s.mockTxFetcher.EXPECT().GetTx(ad.OrderHash).Return(&lighter.LighterTx{
@@ -210,6 +213,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_MissingTx() {
210213
LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"),
211214
Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"),
212215
OrderHash: "orderHash",
216+
DepositTxHash: "orderHash",
213217
BorrowAmount: big.NewInt(1900000),
214218
}
215219
s.mockTxFetcher.EXPECT().GetTx(ad.OrderHash).Return(nil, fmt.Errorf("not found"))
@@ -245,6 +249,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_BorrowAmountTooHigh(
245249
LiquidityPool: common.HexToAddress("0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657"),
246250
Caller: common.HexToAddress("0xde526bA5d1ad94cC59D7A79d99A59F607d31A657"),
247251
OrderHash: "orderHash",
252+
DepositTxHash: "orderHash",
248253
BorrowAmount: big.NewInt(2000000),
249254
}
250255

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,6 @@ github.com/spf13/viper v1.9.0 h1:yR6EXjTp0y0cLN8OZg1CRZmOBdI88UcGkhgyJhu6nZk=
948948
github.com/spf13/viper v1.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4=
949949
github.com/sprintertech/lifi-solver v0.0.0-20251023154209-4cf9ac1ab166 h1:mCcKOxfLs+5tFGD5ZyVVMeqlUuNzhHttul05x27zWFo=
950950
github.com/sprintertech/lifi-solver v0.0.0-20251023154209-4cf9ac1ab166/go.mod h1:EbAH3JJxioBVuHvyjaP5zTh6uPmumCpbE93WEjwpRm0=
951-
github.com/sprintertech/solver-config/go v0.0.0-20251024140304-ee77ffefd608 h1:J5RxJUhqMGfoIUb8XnSjDBlUMH658nM9NIjXft+DjkA=
952-
github.com/sprintertech/solver-config/go v0.0.0-20251024140304-ee77ffefd608/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ=
953951
github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e h1:5sSP6GbqCT/ApxxZmUtav6GHy5Ke98zh5oqQxewhJd4=
954952
github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ=
955953
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=

0 commit comments

Comments
 (0)