Skip to content

Commit 3ee4fc2

Browse files
authored
Swap RPC implementation (#40)
* Initial Swap RPC implementation * Fix swap payer being the swap subsidizer * Minor renames * Fix user account in pre swap ixn * Implement WaitForBlockchainStatus * Support umlimited swaps and add balance checks * Pull in v1.8.3 APIs * Add comments * Swap authority should be excluded from pre swap remaining account list * Cleanup timeouts through configs * Improve swap validation * Add a swap antispam guard
1 parent 7264363 commit 3ee4fc2

File tree

14 files changed

+803
-31
lines changed

14 files changed

+803
-31
lines changed

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ require (
66
firebase.google.com/go/v4 v4.8.0
77
github.com/aws/aws-sdk-go-v2 v0.17.0
88
github.com/bits-and-blooms/bloom/v3 v3.1.0
9-
github.com/code-payments/code-protobuf-api v1.8.2
9+
github.com/code-payments/code-protobuf-api v1.8.3
1010
github.com/emirpasic/gods v1.12.0
1111
github.com/envoyproxy/protoc-gen-validate v0.1.0
1212
github.com/golang-jwt/jwt/v5 v5.0.0
13-
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
1413
github.com/golang/protobuf v1.5.3
1514
github.com/google/uuid v1.3.0
1615
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2
@@ -97,7 +96,6 @@ require (
9796
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
9897
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
9998
go.opencensus.io v0.23.0 // indirect
100-
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 // indirect
10199
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect
102100
golang.org/x/sys v0.13.0 // indirect
103101
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect

go.sum

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH
108108
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
109109
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
110110
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
111-
github.com/code-payments/code-protobuf-api v1.8.2 h1:fl5BS54jI8kqFG9qOyvkwdmZNX9FyG0WvgUTpu/2/dg=
112-
github.com/code-payments/code-protobuf-api v1.8.2/go.mod h1:pHQm75vydD6Cm2qHAzlimW6drysm489Z4tVxC2zHSsU=
111+
github.com/code-payments/code-protobuf-api v1.8.3 h1:BEGKUvHZu5TvfsX4zhzSppuvZGlHH/DbvVBS0/oB18M=
112+
github.com/code-payments/code-protobuf-api v1.8.3/go.mod h1:pHQm75vydD6Cm2qHAzlimW6drysm489Z4tVxC2zHSsU=
113113
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
114114
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
115115
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
@@ -175,8 +175,6 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
175175
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
176176
github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE=
177177
github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
178-
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
179-
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
180178
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
181179
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
182180
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -573,8 +571,6 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk
573571
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
574572
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
575573
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
576-
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
577-
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
578574
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
579575
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
580576
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

pkg/code/antispam/metrics.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const (
2323

2424
actionWelcomeBonus = "WelcomeBonus"
2525
actionReferralBonus = "ReferralBonus"
26+
27+
actionSwap = "Swap"
2628
)
2729

2830
func recordDenialEvent(ctx context.Context, action, reason string) {

pkg/code/antispam/swap.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package antispam
2+
3+
import (
4+
"context"
5+
6+
"github.com/sirupsen/logrus"
7+
8+
"github.com/code-payments/code-server/pkg/code/common"
9+
"github.com/code-payments/code-server/pkg/code/data/phone"
10+
"github.com/code-payments/code-server/pkg/code/data/user/identity"
11+
"github.com/code-payments/code-server/pkg/grpc/client"
12+
"github.com/code-payments/code-server/pkg/metrics"
13+
)
14+
15+
// AllowSwap determines whether a phone-verified owner account can perform a swap.
16+
// The objective here is to limit attacks against our Swap Subsidizer's SOL balance.
17+
//
18+
// todo: needs tests
19+
func (g *Guard) AllowSwap(ctx context.Context, owner *common.Account) (bool, error) {
20+
tracer := metrics.TraceMethodCall(ctx, metricsStructName, "AllowSwap")
21+
defer tracer.End()
22+
23+
log := g.log.WithFields(logrus.Fields{
24+
"method": "AllowSwap",
25+
"owner": owner.PublicKey().ToBase58(),
26+
})
27+
log = client.InjectLoggingMetadata(ctx, log)
28+
29+
// Deny abusers from known IPs
30+
if isIpBanned(ctx) {
31+
log.Info("ip is banned")
32+
recordDenialEvent(ctx, actionSwap, "ip banned")
33+
return false, nil
34+
}
35+
36+
verification, err := g.data.GetLatestPhoneVerificationForAccount(ctx, owner.PublicKey().ToBase58())
37+
if err == phone.ErrVerificationNotFound {
38+
// Owner account was never phone verified, so deny the action.
39+
log.Info("owner account is not phone verified")
40+
recordDenialEvent(ctx, actionSwap, "not phone verified")
41+
return false, nil
42+
} else if err != nil {
43+
tracer.OnError(err)
44+
log.WithError(err).Warn("failure getting phone verification record")
45+
return false, err
46+
}
47+
48+
log = log.WithField("phone", verification.PhoneNumber)
49+
50+
// Deny abusers from known phone ranges
51+
if hasBannedPhoneNumberPrefix(verification.PhoneNumber) {
52+
log.Info("denying phone prefix")
53+
recordDenialEvent(ctx, actionSwap, "phone prefix banned")
54+
return false, nil
55+
}
56+
57+
user, err := g.data.GetUserByPhoneView(ctx, verification.PhoneNumber)
58+
switch err {
59+
case nil:
60+
// Deny banned users forever
61+
if user.IsBanned {
62+
log.Info("denying banned user")
63+
recordDenialEvent(ctx, actionSwap, "user banned")
64+
return false, nil
65+
}
66+
67+
// Staff users have unlimited access to enable testing and demoing.
68+
if user.IsStaffUser {
69+
return true, nil
70+
}
71+
case identity.ErrNotFound:
72+
default:
73+
tracer.OnError(err)
74+
log.WithError(err).Warn("failure getting user identity by phone view")
75+
return false, err
76+
}
77+
78+
return true, nil
79+
}

pkg/code/server/grpc/transaction/v2/config.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ const (
2121
SubmitIntentTimeoutConfigEnvName = envConfigPrefix + "SUBMIT_INTENT_TIMEOUT"
2222
defaultSubmitIntentTimeout = 5 * time.Second
2323

24-
SubmitIntentReceiveTimeoutConfigEnvName = envConfigPrefix + "SUBMIT_INTENT_RECEIVE_TIMEOUT"
25-
defaultSubmitIntentReceiveTimeout = time.Second
24+
SwapTimeoutConfigEnvName = envConfigPrefix + "SWAP_TIMEOUT"
25+
defaultSwapTimeout = 60 * time.Second
26+
27+
ClientReceiveTimeoutConfigEnvName = envConfigPrefix + "CLIENT_RECEIVE_TIMEOUT"
28+
defaultClientReceiveTimeout = time.Second
2629

2730
FeeCollectorTokenPublicKeyConfigEnvName = envConfigPrefix + "FEE_COLLECTOR_TOKEN_PUBLIC_KEY"
2831
defaultFeeCollectorPublicKey = "invalid" // Ensure something valid is set
@@ -33,6 +36,9 @@ const (
3336
AirdropperOwnerPublicKeyEnvName = envConfigPrefix + "AIRDROPPER_OWNER_PUBLIC_KEY"
3437
defaultAirdropperOwnerPublicKey = "invalid" // Ensure something valid is set
3538

39+
SwapSubsidizerOwnerPublicKeyEnvName = envConfigPrefix + "SWAP_SUBSIDIZER_OWNER_PUBLIC_KEY"
40+
defaultSwapSubsidizerOwnerPublicKey = "invalid" // Ensure something valid is set
41+
3642
TreasuryPoolOneKinBucketConfigEnvName = envConfigPrefix + "TREASURY_POOL_1_KIN_BUCKET"
3743
TreasuryPoolTenKinBucketConfigEnvName = envConfigPrefix + "TREASURY_POOL_10_KIN_BUCKET"
3844
TreasuryPoolHundredKinBucketConfigEnvName = envConfigPrefix + "TREASURY_POOL_100_KIN_BUCKET"
@@ -55,11 +61,13 @@ type conf struct {
5561
disableAmlChecks config.Bool // To avoid limits during testing
5662
disableBlockchainChecks config.Bool
5763
submitIntentTimeout config.Duration
58-
submitIntentReceiveTimeout config.Duration
64+
swapTimeout config.Duration
65+
clientReceiveTimeout config.Duration
5966
feeCollectorTokenPublicKey config.String
6067
enableAirdrops config.Bool
6168
enableAsyncAirdropProcessing config.Bool
6269
airdropperOwnerPublicKey config.String
70+
swapSubsidizerOwnerPublicKey config.String
6371
treasuryPoolOneKinBucket config.String
6472
treasuryPoolTenKinBucket config.String
6573
treasuryPoolHundredKinBucket config.String
@@ -84,11 +92,13 @@ func WithEnvConfigs() ConfigProvider {
8492
disableAmlChecks: wrapper.NewBoolConfig(memory.NewConfig(false), false),
8593
disableBlockchainChecks: env.NewBoolConfig(DisableBlockchainChecksConfigEnvName, defaultDisableBlockchainChecks),
8694
submitIntentTimeout: env.NewDurationConfig(SubmitIntentTimeoutConfigEnvName, defaultSubmitIntentTimeout),
87-
submitIntentReceiveTimeout: env.NewDurationConfig(SubmitIntentReceiveTimeoutConfigEnvName, defaultSubmitIntentReceiveTimeout),
95+
swapTimeout: env.NewDurationConfig(SwapTimeoutConfigEnvName, defaultSwapTimeout),
96+
clientReceiveTimeout: env.NewDurationConfig(ClientReceiveTimeoutConfigEnvName, defaultClientReceiveTimeout),
8897
feeCollectorTokenPublicKey: env.NewStringConfig(FeeCollectorTokenPublicKeyConfigEnvName, defaultFeeCollectorPublicKey),
8998
enableAirdrops: env.NewBoolConfig(EnableAirdropsConfigEnvName, defaultEnableAirdrops),
9099
enableAsyncAirdropProcessing: wrapper.NewBoolConfig(memory.NewConfig(true), true),
91100
airdropperOwnerPublicKey: env.NewStringConfig(AirdropperOwnerPublicKeyEnvName, defaultAirdropperOwnerPublicKey),
101+
swapSubsidizerOwnerPublicKey: env.NewStringConfig(SwapSubsidizerOwnerPublicKeyEnvName, defaultSwapSubsidizerOwnerPublicKey),
92102
treasuryPoolOneKinBucket: env.NewStringConfig(TreasuryPoolOneKinBucketConfigEnvName, defaultTreasuryPoolName),
93103
treasuryPoolTenKinBucket: env.NewStringConfig(TreasuryPoolTenKinBucketConfigEnvName, defaultTreasuryPoolName),
94104
treasuryPoolHundredKinBucket: env.NewStringConfig(TreasuryPoolHundredKinBucketConfigEnvName, defaultTreasuryPoolName),
@@ -108,7 +118,7 @@ type testOverrides struct {
108118
enableAntispamChecks bool
109119
enableAmlChecks bool
110120
enableAirdrops bool
111-
submitIntentReceiveTimeout time.Duration
121+
clientReceiveTimeout time.Duration
112122
feeCollectorTokenPublicKey string
113123
treasuryPoolOneKinBucket string
114124
treasuryPoolTenKinBucket string
@@ -127,11 +137,13 @@ func withManualTestOverrides(overrides *testOverrides) ConfigProvider {
127137
disableAmlChecks: wrapper.NewBoolConfig(memory.NewConfig(!overrides.enableAmlChecks), false),
128138
disableBlockchainChecks: wrapper.NewBoolConfig(memory.NewConfig(true), true),
129139
submitIntentTimeout: wrapper.NewDurationConfig(memory.NewConfig(defaultSubmitIntentTimeout), defaultSubmitIntentTimeout),
130-
submitIntentReceiveTimeout: wrapper.NewDurationConfig(memory.NewConfig(overrides.submitIntentReceiveTimeout), defaultSubmitIntentReceiveTimeout),
140+
swapTimeout: wrapper.NewDurationConfig(memory.NewConfig(defaultSwapTimeout), defaultSwapTimeout),
141+
clientReceiveTimeout: wrapper.NewDurationConfig(memory.NewConfig(overrides.clientReceiveTimeout), defaultClientReceiveTimeout),
131142
feeCollectorTokenPublicKey: wrapper.NewStringConfig(memory.NewConfig(overrides.feeCollectorTokenPublicKey), defaultFeeCollectorPublicKey),
132143
enableAirdrops: wrapper.NewBoolConfig(memory.NewConfig(overrides.enableAirdrops), false),
133144
enableAsyncAirdropProcessing: wrapper.NewBoolConfig(memory.NewConfig(false), false),
134145
airdropperOwnerPublicKey: wrapper.NewStringConfig(memory.NewConfig(defaultAirdropperOwnerPublicKey), defaultAirdropperOwnerPublicKey),
146+
swapSubsidizerOwnerPublicKey: wrapper.NewStringConfig(memory.NewConfig(defaultSwapSubsidizerOwnerPublicKey), defaultSwapSubsidizerOwnerPublicKey),
135147
treasuryPoolOneKinBucket: wrapper.NewStringConfig(memory.NewConfig(overrides.treasuryPoolOneKinBucket), defaultTreasuryPoolName),
136148
treasuryPoolTenKinBucket: wrapper.NewStringConfig(memory.NewConfig(overrides.treasuryPoolTenKinBucket), defaultTreasuryPoolName),
137149
treasuryPoolHundredKinBucket: wrapper.NewStringConfig(memory.NewConfig(overrides.treasuryPoolHundredKinBucket), defaultTreasuryPoolName),

pkg/code/server/grpc/transaction/v2/errors.go

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
commonpb "github.com/code-payments/code-protobuf-api/generated/go/common/v1"
1111
transactionpb "github.com/code-payments/code-protobuf-api/generated/go/transaction/v2"
1212

13-
"github.com/code-payments/code-server/pkg/solana"
1413
"github.com/code-payments/code-server/pkg/code/transaction"
14+
"github.com/code-payments/code-server/pkg/solana"
1515
)
1616

1717
const (
@@ -84,6 +84,42 @@ func (e IntentDeniedError) Error() string {
8484
return e.message
8585
}
8686

87+
type SwapValidationError struct {
88+
message string
89+
}
90+
91+
func newSwapValidationError(message string) SwapValidationError {
92+
return SwapValidationError{
93+
message: message,
94+
}
95+
}
96+
97+
func newSwapValidationErrorf(format string, args ...any) SwapValidationError {
98+
return newSwapValidationError(fmt.Sprintf(format, args...))
99+
}
100+
101+
func (e SwapValidationError) Error() string {
102+
return e.message
103+
}
104+
105+
type SwapDeniedError struct {
106+
message string
107+
}
108+
109+
func newSwapDeniedError(message string) SwapDeniedError {
110+
return SwapDeniedError{
111+
message: message,
112+
}
113+
}
114+
115+
func newSwapDeniedErrorf(format string, args ...any) SwapDeniedError {
116+
return newSwapDeniedError(fmt.Sprintf(format, args...))
117+
}
118+
119+
func (e SwapDeniedError) Error() string {
120+
return e.message
121+
}
122+
87123
type StaleStateError struct {
88124
message string
89125
}
@@ -209,3 +245,56 @@ func handleSubmitIntentStructuredError(streamer transactionpb.Transaction_Submit
209245
}
210246
return streamer.Send(errResp)
211247
}
248+
249+
func handleSwapError(streamer transactionpb.Transaction_SwapServer, err error) error {
250+
// gRPC status errors are passed through as is
251+
if _, ok := status.FromError(err); ok {
252+
return err
253+
}
254+
255+
// Case 1: Errors that map to a Code error response
256+
switch err.(type) {
257+
case SwapValidationError:
258+
return handleSwapStructuredError(
259+
streamer,
260+
transactionpb.SwapResponse_Error_INVALID_SWAP,
261+
toReasonStringErrorDetails(err),
262+
)
263+
case SwapDeniedError:
264+
return handleSwapStructuredError(
265+
streamer,
266+
transactionpb.SwapResponse_Error_DENIED,
267+
toReasonStringErrorDetails(err),
268+
)
269+
}
270+
271+
switch err {
272+
case ErrInvalidSignature:
273+
return handleSwapStructuredError(
274+
streamer,
275+
transactionpb.SwapResponse_Error_SIGNATURE_ERROR,
276+
toReasonStringErrorDetails(err),
277+
)
278+
case ErrNotImplemented:
279+
return status.Error(codes.Unimplemented, err.Error())
280+
}
281+
282+
// Case 2: Errors that map to gRPC status errors
283+
switch err {
284+
case ErrTimedOutReceivingRequest:
285+
return status.Error(codes.DeadlineExceeded, err.Error())
286+
}
287+
return status.Error(codes.Internal, "rpc server failure")
288+
}
289+
290+
func handleSwapStructuredError(streamer transactionpb.Transaction_SwapServer, code transactionpb.SwapResponse_Error_Code, errorDetails ...*transactionpb.ErrorDetails) error {
291+
errResp := &transactionpb.SwapResponse{
292+
Response: &transactionpb.SwapResponse_Error_{
293+
Error: &transactionpb.SwapResponse_Error{
294+
Code: code,
295+
ErrorDetails: errorDetails,
296+
},
297+
},
298+
}
299+
return streamer.Send(errResp)
300+
}

pkg/code/server/grpc/transaction/v2/intent.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
messagingpb "github.com/code-payments/code-protobuf-api/generated/go/messaging/v1"
2323
transactionpb "github.com/code-payments/code-protobuf-api/generated/go/transaction/v2"
2424

25-
"github.com/code-payments/code-server/pkg/code/chat"
2625
chat_util "github.com/code-payments/code-server/pkg/code/chat"
2726
"github.com/code-payments/code-server/pkg/code/common"
2827
code_data "github.com/code-payments/code-server/pkg/code/data"
@@ -46,7 +45,8 @@ import (
4645
)
4746

4847
const (
49-
// Assumes the client signature index is consistent across all transactions.
48+
// Assumes the client signature index is consistent across all transactions,
49+
// including those constructed in the SubmitIntent and Swap RPCs.
5050
clientSignatureIndex = 1
5151
)
5252

@@ -800,7 +800,7 @@ func (s *transactionServer) SubmitIntent(streamer transactionpb.Transaction_Subm
800800
}
801801
}
802802

803-
var chatMessagesToPush []*chat.MessageWithOwner
803+
var chatMessagesToPush []*chat_util.MessageWithOwner
804804

805805
// Save all of the required DB records in one transaction to complete the
806806
// intent operation. It's very bad if we end up failing halfway through.
@@ -1025,7 +1025,7 @@ func (s *transactionServer) boundedSubmitIntentRecv(ctx context.Context, streame
10251025
}()
10261026

10271027
select {
1028-
case <-time.After(s.conf.submitIntentReceiveTimeout.Get(ctx)):
1028+
case <-time.After(s.conf.clientReceiveTimeout.Get(ctx)):
10291029
return nil, ErrTimedOutReceivingRequest
10301030
case <-done:
10311031
return req, err

pkg/code/server/grpc/transaction/v2/intent_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,7 @@ func TestSubmitIntent_InvalidNumberOfSignaturesSubmitted(t *testing.T) {
26962696

26972697
func TestSubmitIntent_TimeBoundedRequestSend(t *testing.T) {
26982698
server, phone, _, cleanup := setupTestEnv(t, &testOverrides{
2699-
submitIntentReceiveTimeout: 100 * time.Millisecond,
2699+
clientReceiveTimeout: 100 * time.Millisecond,
27002700
})
27012701
defer cleanup()
27022702

0 commit comments

Comments
 (0)