diff --git a/chanevents/analyzer.go b/chanevents/analyzer.go index abbd3dd..b23183c 100644 --- a/chanevents/analyzer.go +++ b/chanevents/analyzer.go @@ -69,32 +69,31 @@ type channelEventSeq = iter.Seq2[*ChannelEvent, error] // pair over the analysis window. It carries no derived rates or categories. The // consumer derives velocity and uptime fraction from these and the window, and // reconstructs any categorization (such as forwards observed without qualifying -// uptime) from EffectiveUptime and ForwardedAmount. +// uptime) from EffectiveUptime and ForwardedMsat. type ForwardingAbility struct { // EffectiveUptime is the time the pair held at least the liquidity floor // of directional forwardable liquidity over the window. EffectiveUptime time.Duration - // ForwardedAmount is the total successfully forwarded amount over the - // window, at satoshi granularity. - ForwardedAmount btcutil.Amount + // ForwardedMsat is the total successfully forwarded amount over the + // window, in millisatoshis. + ForwardedMsat lnwire.MilliSatoshi // FeeMsat is the total fee earned on the pair's forwards over the // window. FeeMsat lnwire.MilliSatoshi // Forwards is how many successful forwards the pair carried. It decides - // whether the pair forwarded at all, since both sums can be zero for - // one that did: sub-satoshi volume floors away and a zero-fee policy - // earns nothing. + // whether the pair forwarded at all, since the fee total can be zero + // for one that did under a zero-fee policy. Forwards int64 } // pairForwards accumulates what one direction of a peer pair carried over the // analysis window. type pairForwards struct { - // amount is the total forwarded amount, at satoshi granularity. - amount btcutil.Amount + // amountMsat is the total forwarded amount, in millisatoshis. + amountMsat lnwire.MilliSatoshi // feeMsat is the total fee earned on those forwards. feeMsat lnwire.MilliSatoshi @@ -272,7 +271,7 @@ func (a *ForwardingAnalyzer) getForwardingData(ctx context.Context, startTime, successfulForwards[pair] = totals } - totals.amount += fwd.AmountMsatOut.ToSatoshis() + totals.amountMsat += fwd.AmountMsatOut totals.feeMsat += fwd.FeeMsat totals.forwards++ } @@ -923,7 +922,7 @@ func makeAbility(totalUptime time.Duration, return &ForwardingAbility{ EffectiveUptime: totalUptime, - ForwardedAmount: totals.amount, + ForwardedMsat: totals.amountMsat, FeeMsat: totals.feeMsat, Forwards: totals.forwards, } diff --git a/chanevents/analyzer_test.go b/chanevents/analyzer_test.go index f95c9fb..4e3168d 100644 --- a/chanevents/analyzer_test.go +++ b/chanevents/analyzer_test.go @@ -601,7 +601,8 @@ func TestCalculateBothDirectionsUptime(t *testing.T) { forwards: int64(len(tc.successAmts)), } for _, amt := range tc.successAmts { - forwards.amount += amt + forwards.amountMsat += + lnwire.NewMSatFromSatoshis(amt) // Two msat of fee per satoshi // forwarded, so the fee total is @@ -651,7 +652,7 @@ func TestCalculateBothDirectionsUptime(t *testing.T) { require.NoError(t, err) require.Equal(t, &ForwardingAbility{ EffectiveUptime: tc.expectedUptime, - ForwardedAmount: forwards.amount, + ForwardedMsat: forwards.amountMsat, FeeMsat: forwards.feeMsat, Forwards: forwards.forwards, }, abilityAB) @@ -716,15 +717,15 @@ func TestCalculateBothDirectionsUptimeAsymmetric(t *testing.T) { liquidityFloor, statesA, statesB, sumARemote, sumALocal, sumBRemote, sumBLocal, mergeEventSlices(nil, nil), - pairForwards{amount: 100, feeMsat: 200, forwards: 2}, - pairForwards{amount: 50, feeMsat: 100, forwards: 1}, + pairForwards{amountMsat: 100_000, feeMsat: 200, forwards: 2}, + pairForwards{amountMsat: 50_000, feeMsat: 100, forwards: 1}, ) require.NoError(t, err) require.Equal( t, &ForwardingAbility{ EffectiveUptime: 100 * time.Second, - ForwardedAmount: 100, + ForwardedMsat: 100_000, FeeMsat: 200, Forwards: 2, }, abilityAB, @@ -734,7 +735,7 @@ func TestCalculateBothDirectionsUptimeAsymmetric(t *testing.T) { // Forwards landed but BA never crossed the floor: zero // uptime, volume and fees still reported. EffectiveUptime: 0, - ForwardedAmount: 50, + ForwardedMsat: 50_000, FeeMsat: 100, Forwards: 1, }, abilityBA, @@ -1041,14 +1042,17 @@ func TestEffectiveUptimeArgs(t *testing.T) { // Case 1: liquidityFloor = 50k. Liquidity of 1M exceeds the floor for // the whole 60s window, so effective uptime is the full minute and the - // forwarded volume is the 400k sat total, earning 400k msat. + // forwarded volume is the 400M msat total, earning 400k msat. abilities, err := a.EffectiveUptime(ctx, startTime, endTime, 50_000) require.NoError(t, err) pair := PeerPair{PeerIn: validPubKey1, PeerOut: validPubKey2} require.Contains(t, abilities, pair) require.Equal(t, time.Minute, abilities[pair].EffectiveUptime) - require.Equal(t, btcutil.Amount(400_000), abilities[pair].ForwardedAmount) + require.Equal( + t, lnwire.MilliSatoshi(400_000_000), + abilities[pair].ForwardedMsat, + ) require.Equal( t, lnwire.MilliSatoshi(400_000), abilities[pair].FeeMsat, ) @@ -1062,7 +1066,10 @@ func TestEffectiveUptimeArgs(t *testing.T) { require.Contains(t, abilities, pair) require.Zero(t, abilities[pair].EffectiveUptime) - require.Equal(t, btcutil.Amount(400_000), abilities[pair].ForwardedAmount) + require.Equal( + t, lnwire.MilliSatoshi(400_000_000), + abilities[pair].ForwardedMsat, + ) require.Equal( t, lnwire.MilliSatoshi(400_000), abilities[pair].FeeMsat, ) diff --git a/cmd/frcli/forwarding_ability.go b/cmd/frcli/forwarding_ability.go index 93c88af..7ca8875 100644 --- a/cmd/frcli/forwarding_ability.go +++ b/cmd/frcli/forwarding_ability.go @@ -44,8 +44,8 @@ var forwardingAbilityCommand = cli.Command{ type pairView struct { PeerIn string `json:"peer_in"` PeerOut string `json:"peer_out"` - EffectiveUptimeS int64 `json:"effective_uptime_s"` - ForwardedSat int64 `json:"forwarded_sat"` + EffectiveUptimeS uint64 `json:"effective_uptime_s"` + ForwardedMsat int64 `json:"forwarded_msat"` FeeMsat int64 `json:"fee_msat"` Forwards int64 `json:"forwards"` UptimeFraction float64 `json:"uptime_fraction"` @@ -89,18 +89,21 @@ func queryForwardingAbility(ctx *cli.Context) error { ) / float64(windowSeconds) } + // Volume over the uptime that carried it, in + // millisatoshis per second. if ability.EffectiveUptimeS > 0 { - velocity = float64(ability.ForwardedSat) / + velocity = float64(ability.ForwardedMsat) / float64(ability.EffectiveUptimeS) } - // Fees over volume. A pair with only sub-satoshi - // forwards has no volume to divide by, so it keeps a - // zero rate rather than an infinite one. + // Fees over volume, both in millisatoshis, so the rate + // is the unitless fraction of volume kept as fees. A + // pair with no volume has nothing to divide by, so it + // keeps a zero rate rather than an infinite one. var feeRate float64 - if ability.ForwardedSat > 0 { + if ability.ForwardedMsat > 0 { feeRate = float64(ability.FeeMsat) / - (float64(ability.ForwardedSat) * 1000) + float64(ability.ForwardedMsat) } views = append( @@ -108,7 +111,7 @@ func queryForwardingAbility(ctx *cli.Context) error { PeerIn: inPeer, PeerOut: outPeer, EffectiveUptimeS: ability.EffectiveUptimeS, - ForwardedSat: ability.ForwardedSat, + ForwardedMsat: ability.ForwardedMsat, FeeMsat: ability.FeeMsat, Forwards: ability.Forwards, UptimeFraction: uptimeFraction, diff --git a/frdrpc/faraday.pb.go b/frdrpc/faraday.pb.go index 2142bde..9191f3f 100644 --- a/frdrpc/faraday.pb.go +++ b/frdrpc/faraday.pb.go @@ -2409,20 +2409,18 @@ type ForwardingAbilityEntry struct { PackedIdx uint32 `protobuf:"varint,1,opt,name=packed_idx,json=packedIdx,proto3" json:"packed_idx,omitempty"` // Seconds the peer pair held at least the requested liquidity floor of // directional forwardable liquidity over the window. - EffectiveUptimeS int64 `protobuf:"varint,2,opt,name=effective_uptime_s,json=effectiveUptimeS,proto3" json:"effective_uptime_s,omitempty"` - // Total successfully forwarded amount over the window, in satoshis. A - // pair whose forwards were all sub-satoshi reports zero here and still - // reports them in forwards. - ForwardedSat int64 `protobuf:"varint,3,opt,name=forwarded_sat,json=forwardedSat,proto3" json:"forwarded_sat,omitempty"` + EffectiveUptimeS uint64 `protobuf:"varint,2,opt,name=effective_uptime_s,json=effectiveUptimeS,proto3" json:"effective_uptime_s,omitempty"` + // Total successfully forwarded amount over the window, in millisatoshis. + ForwardedMsat int64 `protobuf:"varint,3,opt,name=forwarded_msat,json=forwardedMsat,proto3" json:"forwarded_msat,omitempty"` // Total fees earned on the pair's forwards over the window, in // millisatoshis. Fees are reported at millisatoshi granularity because a // single forward routinely earns less than one satoshi, and a satoshi // granular sum would floor a low-fee pair's earnings to zero. FeeMsat int64 `protobuf:"varint,4,opt,name=fee_msat,json=feeMsat,proto3" json:"fee_msat,omitempty"` // The number of successful forwards the pair carried over the window. It - // decides whether the pair forwarded at all, since both sums can be zero - // for one that did: sub-satoshi volume floors away and a zero-fee policy - // earns nothing. With forwarded_sat it also gives the mean forward size. + // decides whether the pair forwarded at all, since the fee total can be + // zero for one that did under a zero-fee policy. With forwarded_msat it + // also gives the mean forward size. Forwards int64 `protobuf:"varint,5,opt,name=forwards,proto3" json:"forwards,omitempty"` } @@ -2465,16 +2463,16 @@ func (x *ForwardingAbilityEntry) GetPackedIdx() uint32 { return 0 } -func (x *ForwardingAbilityEntry) GetEffectiveUptimeS() int64 { +func (x *ForwardingAbilityEntry) GetEffectiveUptimeS() uint64 { if x != nil { return x.EffectiveUptimeS } return 0 } -func (x *ForwardingAbilityEntry) GetForwardedSat() int64 { +func (x *ForwardingAbilityEntry) GetForwardedMsat() int64 { if x != nil { - return x.ForwardedSat + return x.ForwardedMsat } return 0 } @@ -2782,114 +2780,114 @@ var file_faraday_proto_rawDesc = []byte{ 0x0c, 0x52, 0x10, 0x75, 0x70, 0x42, 0x75, 0x74, 0x49, 0x64, 0x6c, 0x65, 0x42, 0x69, 0x74, 0x6d, 0x61, 0x73, 0x6b, 0x12, 0x29, 0x0a, 0x10, 0x75, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0f, 0x75, - 0x70, 0x74, 0x69, 0x6d, 0x65, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, 0xc1, + 0x70, 0x74, 0x69, 0x6d, 0x65, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x22, 0xc3, 0x01, 0x0a, 0x16, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x41, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x5f, 0x69, 0x64, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x49, 0x64, 0x78, 0x12, 0x2c, 0x0a, 0x12, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x75, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x55, - 0x70, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, - 0x64, 0x65, 0x64, 0x5f, 0x73, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x66, - 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x65, 0x64, 0x53, 0x61, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x66, - 0x65, 0x65, 0x5f, 0x6d, 0x73, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x66, - 0x65, 0x65, 0x4d, 0x73, 0x61, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, - 0x64, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, - 0x64, 0x73, 0x2a, 0xa1, 0x01, 0x0a, 0x0b, 0x47, 0x72, 0x61, 0x6e, 0x75, 0x6c, 0x61, 0x72, 0x69, - 0x74, 0x79, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x47, 0x52, - 0x41, 0x4e, 0x55, 0x4c, 0x41, 0x52, 0x49, 0x54, 0x59, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4d, - 0x49, 0x4e, 0x55, 0x54, 0x45, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x49, 0x56, 0x45, 0x5f, - 0x4d, 0x49, 0x4e, 0x55, 0x54, 0x45, 0x53, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x46, 0x49, 0x46, - 0x54, 0x45, 0x45, 0x4e, 0x5f, 0x4d, 0x49, 0x4e, 0x55, 0x54, 0x45, 0x53, 0x10, 0x03, 0x12, 0x12, - 0x0a, 0x0e, 0x54, 0x48, 0x49, 0x52, 0x54, 0x59, 0x5f, 0x4d, 0x49, 0x4e, 0x55, 0x54, 0x45, 0x53, - 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x4f, 0x55, 0x52, 0x10, 0x05, 0x12, 0x0d, 0x0a, 0x09, - 0x53, 0x49, 0x58, 0x5f, 0x48, 0x4f, 0x55, 0x52, 0x53, 0x10, 0x06, 0x12, 0x10, 0x0a, 0x0c, 0x54, - 0x57, 0x45, 0x4c, 0x56, 0x45, 0x5f, 0x48, 0x4f, 0x55, 0x52, 0x53, 0x10, 0x07, 0x12, 0x07, 0x0a, - 0x03, 0x44, 0x41, 0x59, 0x10, 0x08, 0x2a, 0x6a, 0x0a, 0x0b, 0x46, 0x69, 0x61, 0x74, 0x42, 0x61, - 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, - 0x5f, 0x46, 0x49, 0x41, 0x54, 0x42, 0x41, 0x43, 0x4b, 0x45, 0x4e, 0x44, 0x10, 0x00, 0x12, 0x0b, - 0x0a, 0x07, 0x43, 0x4f, 0x49, 0x4e, 0x43, 0x41, 0x50, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x43, - 0x4f, 0x49, 0x4e, 0x44, 0x45, 0x53, 0x4b, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x55, 0x53, - 0x54, 0x4f, 0x4d, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x49, 0x4e, 0x47, 0x45, 0x43, - 0x4b, 0x4f, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x42, 0x49, 0x54, 0x46, 0x49, 0x4e, 0x45, 0x58, - 0x10, 0x05, 0x2a, 0xa2, 0x02, 0x0a, 0x09, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x16, 0x0a, - 0x12, 0x4c, 0x4f, 0x43, 0x41, 0x4c, 0x5f, 0x43, 0x48, 0x41, 0x4e, 0x4e, 0x45, 0x4c, 0x5f, 0x4f, - 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x52, 0x45, 0x4d, 0x4f, 0x54, 0x45, 0x5f, - 0x43, 0x48, 0x41, 0x4e, 0x4e, 0x45, 0x4c, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x02, 0x12, 0x14, - 0x0a, 0x10, 0x43, 0x48, 0x41, 0x4e, 0x4e, 0x45, 0x4c, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x5f, 0x46, - 0x45, 0x45, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x48, 0x41, 0x4e, 0x4e, 0x45, 0x4c, 0x5f, - 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x45, 0x43, 0x45, 0x49, - 0x50, 0x54, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x41, 0x59, 0x4d, 0x45, 0x4e, 0x54, 0x10, - 0x06, 0x12, 0x07, 0x0a, 0x03, 0x46, 0x45, 0x45, 0x10, 0x07, 0x12, 0x14, 0x0a, 0x10, 0x43, 0x49, - 0x52, 0x43, 0x55, 0x4c, 0x41, 0x52, 0x5f, 0x52, 0x45, 0x43, 0x45, 0x49, 0x50, 0x54, 0x10, 0x08, - 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x4f, 0x52, 0x57, 0x41, 0x52, 0x44, 0x10, 0x09, 0x12, 0x0f, 0x0a, - 0x0b, 0x46, 0x4f, 0x52, 0x57, 0x41, 0x52, 0x44, 0x5f, 0x46, 0x45, 0x45, 0x10, 0x0a, 0x12, 0x14, - 0x0a, 0x10, 0x43, 0x49, 0x52, 0x43, 0x55, 0x4c, 0x41, 0x52, 0x5f, 0x50, 0x41, 0x59, 0x4d, 0x45, - 0x4e, 0x54, 0x10, 0x0b, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x49, 0x52, 0x43, 0x55, 0x4c, 0x41, 0x52, - 0x5f, 0x46, 0x45, 0x45, 0x10, 0x0c, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x57, 0x45, 0x45, 0x50, 0x10, - 0x0d, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x57, 0x45, 0x45, 0x50, 0x5f, 0x46, 0x45, 0x45, 0x10, 0x0e, - 0x12, 0x15, 0x0a, 0x11, 0x43, 0x48, 0x41, 0x4e, 0x4e, 0x45, 0x4c, 0x5f, 0x43, 0x4c, 0x4f, 0x53, - 0x45, 0x5f, 0x46, 0x45, 0x45, 0x10, 0x0f, 0x2a, 0x70, 0x0a, 0x10, 0x43, 0x68, 0x61, 0x6e, 0x6e, - 0x65, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x43, - 0x48, 0x41, 0x4e, 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, - 0x4e, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x48, 0x41, 0x4e, 0x5f, 0x45, 0x56, 0x45, 0x4e, - 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x43, 0x48, - 0x41, 0x4e, 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x4f, 0x46, 0x46, 0x4c, 0x49, 0x4e, 0x45, - 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x48, 0x41, 0x4e, 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, - 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x03, 0x32, 0x83, 0x06, 0x0a, 0x0d, 0x46, 0x61, - 0x72, 0x61, 0x64, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x65, 0x0a, 0x16, 0x4f, - 0x75, 0x74, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x25, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x4f, - 0x75, 0x74, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x66, - 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x6d, - 0x6d, 0x65, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x69, 0x0a, 0x18, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x52, - 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x27, - 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x55, + 0x70, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x12, 0x25, 0x0a, 0x0e, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, + 0x64, 0x65, 0x64, 0x5f, 0x6d, 0x73, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, + 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x65, 0x64, 0x4d, 0x73, 0x61, 0x74, 0x12, 0x19, 0x0a, + 0x08, 0x66, 0x65, 0x65, 0x5f, 0x6d, 0x73, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x07, 0x66, 0x65, 0x65, 0x4d, 0x73, 0x61, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x6f, 0x72, 0x77, + 0x61, 0x72, 0x64, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x66, 0x6f, 0x72, 0x77, + 0x61, 0x72, 0x64, 0x73, 0x2a, 0xa1, 0x01, 0x0a, 0x0b, 0x47, 0x72, 0x61, 0x6e, 0x75, 0x6c, 0x61, + 0x72, 0x69, 0x74, 0x79, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, + 0x47, 0x52, 0x41, 0x4e, 0x55, 0x4c, 0x41, 0x52, 0x49, 0x54, 0x59, 0x10, 0x00, 0x12, 0x0a, 0x0a, + 0x06, 0x4d, 0x49, 0x4e, 0x55, 0x54, 0x45, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x49, 0x56, + 0x45, 0x5f, 0x4d, 0x49, 0x4e, 0x55, 0x54, 0x45, 0x53, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x46, + 0x49, 0x46, 0x54, 0x45, 0x45, 0x4e, 0x5f, 0x4d, 0x49, 0x4e, 0x55, 0x54, 0x45, 0x53, 0x10, 0x03, + 0x12, 0x12, 0x0a, 0x0e, 0x54, 0x48, 0x49, 0x52, 0x54, 0x59, 0x5f, 0x4d, 0x49, 0x4e, 0x55, 0x54, + 0x45, 0x53, 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x4f, 0x55, 0x52, 0x10, 0x05, 0x12, 0x0d, + 0x0a, 0x09, 0x53, 0x49, 0x58, 0x5f, 0x48, 0x4f, 0x55, 0x52, 0x53, 0x10, 0x06, 0x12, 0x10, 0x0a, + 0x0c, 0x54, 0x57, 0x45, 0x4c, 0x56, 0x45, 0x5f, 0x48, 0x4f, 0x55, 0x52, 0x53, 0x10, 0x07, 0x12, + 0x07, 0x0a, 0x03, 0x44, 0x41, 0x59, 0x10, 0x08, 0x2a, 0x6a, 0x0a, 0x0b, 0x46, 0x69, 0x61, 0x74, + 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, + 0x57, 0x4e, 0x5f, 0x46, 0x49, 0x41, 0x54, 0x42, 0x41, 0x43, 0x4b, 0x45, 0x4e, 0x44, 0x10, 0x00, + 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4f, 0x49, 0x4e, 0x43, 0x41, 0x50, 0x10, 0x01, 0x12, 0x0c, 0x0a, + 0x08, 0x43, 0x4f, 0x49, 0x4e, 0x44, 0x45, 0x53, 0x4b, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x43, + 0x55, 0x53, 0x54, 0x4f, 0x4d, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x49, 0x4e, 0x47, + 0x45, 0x43, 0x4b, 0x4f, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x42, 0x49, 0x54, 0x46, 0x49, 0x4e, + 0x45, 0x58, 0x10, 0x05, 0x2a, 0xa2, 0x02, 0x0a, 0x09, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, + 0x16, 0x0a, 0x12, 0x4c, 0x4f, 0x43, 0x41, 0x4c, 0x5f, 0x43, 0x48, 0x41, 0x4e, 0x4e, 0x45, 0x4c, + 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x52, 0x45, 0x4d, 0x4f, 0x54, + 0x45, 0x5f, 0x43, 0x48, 0x41, 0x4e, 0x4e, 0x45, 0x4c, 0x5f, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x02, + 0x12, 0x14, 0x0a, 0x10, 0x43, 0x48, 0x41, 0x4e, 0x4e, 0x45, 0x4c, 0x5f, 0x4f, 0x50, 0x45, 0x4e, + 0x5f, 0x46, 0x45, 0x45, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x48, 0x41, 0x4e, 0x4e, 0x45, + 0x4c, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x45, 0x43, + 0x45, 0x49, 0x50, 0x54, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x41, 0x59, 0x4d, 0x45, 0x4e, + 0x54, 0x10, 0x06, 0x12, 0x07, 0x0a, 0x03, 0x46, 0x45, 0x45, 0x10, 0x07, 0x12, 0x14, 0x0a, 0x10, + 0x43, 0x49, 0x52, 0x43, 0x55, 0x4c, 0x41, 0x52, 0x5f, 0x52, 0x45, 0x43, 0x45, 0x49, 0x50, 0x54, + 0x10, 0x08, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x4f, 0x52, 0x57, 0x41, 0x52, 0x44, 0x10, 0x09, 0x12, + 0x0f, 0x0a, 0x0b, 0x46, 0x4f, 0x52, 0x57, 0x41, 0x52, 0x44, 0x5f, 0x46, 0x45, 0x45, 0x10, 0x0a, + 0x12, 0x14, 0x0a, 0x10, 0x43, 0x49, 0x52, 0x43, 0x55, 0x4c, 0x41, 0x52, 0x5f, 0x50, 0x41, 0x59, + 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x0b, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x49, 0x52, 0x43, 0x55, 0x4c, + 0x41, 0x52, 0x5f, 0x46, 0x45, 0x45, 0x10, 0x0c, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x57, 0x45, 0x45, + 0x50, 0x10, 0x0d, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x57, 0x45, 0x45, 0x50, 0x5f, 0x46, 0x45, 0x45, + 0x10, 0x0e, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x48, 0x41, 0x4e, 0x4e, 0x45, 0x4c, 0x5f, 0x43, 0x4c, + 0x4f, 0x53, 0x45, 0x5f, 0x46, 0x45, 0x45, 0x10, 0x0f, 0x2a, 0x70, 0x0a, 0x10, 0x43, 0x68, 0x61, + 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, + 0x12, 0x43, 0x48, 0x41, 0x4e, 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, + 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x48, 0x41, 0x4e, 0x5f, 0x45, 0x56, + 0x45, 0x4e, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, + 0x43, 0x48, 0x41, 0x4e, 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x4f, 0x46, 0x46, 0x4c, 0x49, + 0x4e, 0x45, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x48, 0x41, 0x4e, 0x5f, 0x45, 0x56, 0x45, + 0x4e, 0x54, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x03, 0x32, 0x83, 0x06, 0x0a, 0x0d, + 0x46, 0x61, 0x72, 0x61, 0x64, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x65, 0x0a, + 0x16, 0x4f, 0x75, 0x74, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, + 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x25, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, + 0x2e, 0x4f, 0x75, 0x74, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, + 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, + 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x63, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x69, 0x0a, 0x18, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, - 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a, - 0x0d, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x75, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1c, + 0x12, 0x27, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, + 0x6f, 0x6c, 0x64, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x64, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x66, 0x72, 0x64, 0x72, + 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, + 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x4c, 0x0a, 0x0d, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x75, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x12, 0x1c, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x75, + 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x75, 0x65, 0x52, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x66, - 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x75, 0x65, 0x52, 0x65, 0x70, - 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x0f, 0x43, - 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x6e, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x12, 0x1e, - 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, - 0x6e, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, - 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, - 0x6e, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x49, 0x0a, 0x0c, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x61, 0x74, 0x65, 0x12, - 0x1b, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, - 0x65, 0x52, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x66, - 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x61, - 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x09, 0x4e, 0x6f, - 0x64, 0x65, 0x41, 0x75, 0x64, 0x69, 0x74, 0x12, 0x18, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, - 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x75, 0x64, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x19, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x41, - 0x75, 0x64, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x0b, - 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1a, 0x2e, 0x66, 0x72, - 0x64, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, - 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, 0x68, 0x61, 0x6e, 0x6e, - 0x65, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1c, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, + 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, + 0x0f, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x49, 0x6e, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, + 0x12, 0x1e, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, + 0x6c, 0x49, 0x6e, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1f, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, + 0x6c, 0x49, 0x6e, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x49, 0x0a, 0x0c, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x61, 0x74, + 0x65, 0x12, 0x1b, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x45, 0x78, 0x63, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x52, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, + 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x52, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x09, + 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x75, 0x64, 0x69, 0x74, 0x12, 0x18, 0x2e, 0x66, 0x72, 0x64, 0x72, + 0x70, 0x63, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x41, 0x75, 0x64, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x4e, 0x6f, 0x64, + 0x65, 0x41, 0x75, 0x64, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x46, + 0x0a, 0x0b, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1a, 0x2e, + 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x66, 0x72, 0x64, 0x72, + 0x70, 0x63, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, 0x68, 0x61, + 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1c, 0x2e, 0x66, 0x72, 0x64, + 0x72, 0x70, 0x63, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, - 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x58, 0x0a, 0x11, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, - 0x69, 0x6e, 0x67, 0x41, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x20, 0x2e, 0x66, 0x72, 0x64, - 0x72, 0x70, 0x63, 0x2e, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x41, 0x62, - 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x66, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x58, 0x0a, 0x11, 0x46, 0x6f, 0x72, 0x77, 0x61, + 0x72, 0x64, 0x69, 0x6e, 0x67, 0x41, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x20, 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, - 0x41, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, - 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, - 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x66, 0x61, 0x72, 0x61, - 0x64, 0x61, 0x79, 0x2f, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x41, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, + 0x2e, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, + 0x6e, 0x67, 0x41, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x66, 0x61, + 0x72, 0x61, 0x64, 0x61, 0x79, 0x2f, 0x66, 0x72, 0x64, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/frdrpc/faraday.proto b/frdrpc/faraday.proto index 22dd372..fc67cb4 100644 --- a/frdrpc/faraday.proto +++ b/frdrpc/faraday.proto @@ -744,12 +744,10 @@ message ForwardingAbilityEntry { // Seconds the peer pair held at least the requested liquidity floor of // directional forwardable liquidity over the window. - int64 effective_uptime_s = 2; + uint64 effective_uptime_s = 2; - // Total successfully forwarded amount over the window, in satoshis. A - // pair whose forwards were all sub-satoshi reports zero here and still - // reports them in forwards. - int64 forwarded_sat = 3; + // Total successfully forwarded amount over the window, in millisatoshis. + int64 forwarded_msat = 3; // Total fees earned on the pair's forwards over the window, in // millisatoshis. Fees are reported at millisatoshi granularity because a @@ -758,8 +756,8 @@ message ForwardingAbilityEntry { int64 fee_msat = 4; // The number of successful forwards the pair carried over the window. It - // decides whether the pair forwarded at all, since both sums can be zero - // for one that did: sub-satoshi volume floors away and a zero-fee policy - // earns nothing. With forwarded_sat it also gives the mean forward size. + // decides whether the pair forwarded at all, since the fee total can be + // zero for one that did under a zero-fee policy. With forwarded_msat it + // also gives the mean forward size. int64 forwards = 5; } diff --git a/frdrpc/faraday.swagger.json b/frdrpc/faraday.swagger.json index 1e0262c..9b4a4e2 100644 --- a/frdrpc/faraday.swagger.json +++ b/frdrpc/faraday.swagger.json @@ -1035,13 +1035,13 @@ }, "effective_uptime_s": { "type": "string", - "format": "int64", + "format": "uint64", "description": "Seconds the peer pair held at least the requested liquidity floor of\ndirectional forwardable liquidity over the window." }, - "forwarded_sat": { + "forwarded_msat": { "type": "string", "format": "int64", - "description": "Total successfully forwarded amount over the window, in satoshis. A\npair whose forwards were all sub-satoshi reports zero here and still\nreports them in forwards." + "description": "Total successfully forwarded amount over the window, in millisatoshis." }, "fee_msat": { "type": "string", @@ -1051,7 +1051,7 @@ "forwards": { "type": "string", "format": "int64", - "description": "The number of successful forwards the pair carried over the window. It\ndecides whether the pair forwarded at all, since both sums can be zero\nfor one that did: sub-satoshi volume floors away and a zero-fee policy\nearns nothing. With forwarded_sat it also gives the mean forward size." + "description": "The number of successful forwards the pair carried over the window. It\ndecides whether the pair forwarded at all, since the fee total can be\nzero for one that did under a zero-fee policy. With forwarded_msat it\nalso gives the mean forward size." } } }, diff --git a/frdrpc/forwarding_ability_codec.go b/frdrpc/forwarding_ability_codec.go index 6821d24..7f21aff 100644 --- a/frdrpc/forwarding_ability_codec.go +++ b/frdrpc/forwarding_ability_codec.go @@ -23,13 +23,12 @@ type ForwardingAbility struct { // liquidity floor of directional forwardable liquidity over the window. // The value is whole seconds: sub-second uptime floors to zero, so a // pair that forwarded volume over a fleeting qualifying window can - // report a zero uptime alongside a non-zero ForwardedSat. - EffectiveUptimeS int64 + // report a zero uptime alongside a non-zero ForwardedMsat. + EffectiveUptimeS uint64 - // ForwardedSat is the total successfully forwarded amount over the - // window, in satoshis. A pair whose forwards were all sub-satoshi - // reports zero here and still reports them in Forwards. - ForwardedSat int64 + // ForwardedMsat is the total successfully forwarded amount over the + // window, in millisatoshis. + ForwardedMsat int64 // FeeMsat is the total fee earned on the pair's forwards over the // window, in millisatoshis. A single forward routinely earns less than @@ -38,9 +37,8 @@ type ForwardingAbility struct { FeeMsat int64 // Forwards is how many successful forwards the pair carried. It decides - // whether the pair forwarded at all, since both sums can be zero for - // one that did: sub-satoshi volume floors away and a zero-fee policy - // earns nothing. + // whether the pair forwarded at all, since the fee total can be zero + // for one that did under a zero-fee policy. Forwards int64 } @@ -69,9 +67,10 @@ const ( // facts even if its uptime is below the threshold; otherwise the pair is // compacted to a bit when it was up enough, and dropped when it was not. // -// The count decides whether the pair forwarded, not the sums: both can be zero -// for a pair that did, and demoting it to a bit would record it as idle. -func (a ForwardingAbility) tier(minUptimeS int64) abilityTier { +// The count decides whether the pair forwarded, not the sums: a zero-fee policy +// leaves the fee total at zero for a pair that did, and demoting it to a bit +// would record it as idle. +func (a ForwardingAbility) tier(minUptimeS uint64) abilityTier { switch { case a.Forwards > 0: return tierEntry @@ -92,12 +91,12 @@ func (a ForwardingAbility) tier(minUptimeS int64) abilityTier { // the threshold fraction" contract. The result is floored at one second so a // pair with zero uptime is never treated as up. A non-positive window admits // nothing. -func MinQualifyingUptime(threshold float64, windowSeconds int64) int64 { +func MinQualifyingUptime(threshold float64, windowSeconds int64) uint64 { if windowSeconds <= 0 { - return math.MaxInt64 + return math.MaxUint64 } - v := int64(math.Ceil(threshold * float64(windowSeconds))) + v := uint64(math.Ceil(threshold * float64(windowSeconds))) if v < 1 { v = 1 } @@ -195,7 +194,7 @@ func EncodeForwardingAbility(abilities map[string]map[string]ForwardingAbility, entries = append(entries, &ForwardingAbilityEntry{ PackedIdx: packed, EffectiveUptimeS: a.EffectiveUptimeS, - ForwardedSat: a.ForwardedSat, + ForwardedMsat: a.ForwardedMsat, FeeMsat: a.FeeMsat, Forwards: a.Forwards, }) @@ -320,7 +319,7 @@ func DecodeForwardingAbility(resp *ForwardingAbilityResponse) ( record( inIdx, outIdx, ForwardingAbility{ EffectiveUptimeS: entry.EffectiveUptimeS, - ForwardedSat: entry.ForwardedSat, + ForwardedMsat: entry.ForwardedMsat, FeeMsat: entry.FeeMsat, Forwards: entry.Forwards, }, @@ -349,7 +348,13 @@ func DecodeForwardingAbility(resp *ForwardingAbilityResponse) ( // bitmask bytes directly, skipping zero bytes, so cost scales with the // number of set bits rather than the O(n*n) pair space; padding bits // beyond n*n are ignored. - windowSeconds := resp.EndTime - resp.StartTime + // The window is a difference of signed unix timestamps, so an end + // before the start yields zero uptime rather than wrapping into a + // near-infinite one. + var windowSeconds uint64 + if d := resp.EndTime - resp.StartTime; d > 0 { + windowSeconds = uint64(d) + } for i, b := range bitmask { if b == 0 { continue @@ -388,7 +393,7 @@ func DecodeForwardingAbility(resp *ForwardingAbilityResponse) ( record( inIdx, outIdx, ForwardingAbility{ EffectiveUptimeS: windowSeconds, - ForwardedSat: 0, + ForwardedMsat: 0, }, ) } diff --git a/frdrpc/forwarding_ability_codec_test.go b/frdrpc/forwarding_ability_codec_test.go index f4e38d9..d247093 100644 --- a/frdrpc/forwarding_ability_codec_test.go +++ b/frdrpc/forwarding_ability_codec_test.go @@ -51,7 +51,7 @@ func TestForwardingAbilityCodecRoundTrip(t *testing.T) { fwdKey(1): { fwdKey(2): { EffectiveUptimeS: 80, - ForwardedSat: 1500, + ForwardedMsat: 1_500_000, FeeMsat: 1500, Forwards: 3, }, @@ -59,7 +59,7 @@ func TestForwardingAbilityCodecRoundTrip(t *testing.T) { fwdKey(2): { fwdKey(1): { EffectiveUptimeS: 0, - ForwardedSat: 2500, + ForwardedMsat: 2_500_000, FeeMsat: 5000, Forwards: 1, }, @@ -75,7 +75,7 @@ func TestForwardingAbilityCodecRoundTrip(t *testing.T) { fwdKey(2), ForwardingAbility{ EffectiveUptimeS: 80, - ForwardedSat: 1500, + ForwardedMsat: 1_500_000, FeeMsat: 1500, Forwards: 3, }, @@ -85,7 +85,7 @@ func TestForwardingAbilityCodecRoundTrip(t *testing.T) { fwdKey(1), ForwardingAbility{ EffectiveUptimeS: 0, - ForwardedSat: 2500, + ForwardedMsat: 2_500_000, FeeMsat: 5000, Forwards: 1, }, @@ -154,7 +154,7 @@ func TestForwardingAbilityCodecRoundTrip(t *testing.T) { fwdKey(1): { fwdKey(2): { EffectiveUptimeS: 80, - ForwardedSat: 1500, + ForwardedMsat: 1_500_000, FeeMsat: 750, Forwards: 2, }, @@ -169,9 +169,9 @@ func TestForwardingAbilityCodecRoundTrip(t *testing.T) { }, fwdKey(3): { fwdKey(1): { - ForwardedSat: 500, - FeeMsat: 250, - Forwards: 1, + ForwardedMsat: 500_000, + FeeMsat: 250, + Forwards: 1, }, }, }, @@ -186,7 +186,7 @@ func TestForwardingAbilityCodecRoundTrip(t *testing.T) { fwdKey(2), ForwardingAbility{ EffectiveUptimeS: 80, - ForwardedSat: 1500, + ForwardedMsat: 1_500_000, FeeMsat: 750, Forwards: 2, }, @@ -202,9 +202,9 @@ func TestForwardingAbilityCodecRoundTrip(t *testing.T) { fwdKey(3), fwdKey(1), ForwardingAbility{ - ForwardedSat: 500, - FeeMsat: 250, - Forwards: 1, + ForwardedMsat: 500_000, + FeeMsat: 250, + Forwards: 1, }, }, }, @@ -313,7 +313,7 @@ func TestMinQualifyingUptime(t *testing.T) { name string threshold float64 window int64 - want int64 + want uint64 }{ { "half of clean window", @@ -343,7 +343,7 @@ func TestMinQualifyingUptime(t *testing.T) { "non-positive window admits nothing", 0.5, 0, - math.MaxInt64, + math.MaxUint64, }, } @@ -395,7 +395,7 @@ func TestForwardingAbilityDecodeEntryPrecedence(t *testing.T) { { PackedIdx: (0 << 16) | 1, EffectiveUptimeS: 42, - ForwardedSat: 7, + ForwardedMsat: 7_000, FeeMsat: 21, Forwards: 2, }, @@ -408,7 +408,7 @@ func TestForwardingAbilityDecodeEntryPrecedence(t *testing.T) { require.Equal( t, ForwardingAbility{ EffectiveUptimeS: 42, - ForwardedSat: 7, + ForwardedMsat: 7_000, FeeMsat: 21, Forwards: 2, }, @@ -435,7 +435,7 @@ func TestForwardingAbilityDecodeBadIndex(t *testing.T) { // peer. PackedIdx: (0 << 16) | 1, EffectiveUptimeS: 3600, - ForwardedSat: 1000, + ForwardedMsat: 1_000_000, }, }, } @@ -475,8 +475,8 @@ func TestForwardingAbilityEncodePeerCap(t *testing.T) { for i := 1; i <= maxPackedPeers+1; i++ { // Use a carried forward so inclusion is threshold-independent. outMap[fwdKey(i)] = ForwardingAbility{ - ForwardedSat: 1, - Forwards: 1, + ForwardedMsat: 1_000, + Forwards: 1, } } abilities := map[string]map[string]ForwardingAbility{ @@ -498,14 +498,14 @@ func TestForwardingAbilityEncodeNormalizesCase(t *testing.T) { abilities := map[string]map[string]ForwardingAbility{ strings.ToUpper(peer): { fwdKey(2): { - ForwardedSat: 20, - Forwards: 1, + ForwardedMsat: 20_000, + Forwards: 1, }, }, peer: { fwdKey(3): { - ForwardedSat: 40, - Forwards: 1, + ForwardedMsat: 40_000, + Forwards: 1, }, }, } @@ -521,15 +521,15 @@ func TestForwardingAbilityEncodeNormalizesCase(t *testing.T) { require.NoError(t, err) require.Equal( t, ForwardingAbility{ - ForwardedSat: 20, - Forwards: 1, + ForwardedMsat: 20_000, + Forwards: 1, }, decoded[peer][fwdKey(2)], ) require.Equal( t, ForwardingAbility{ - ForwardedSat: 40, - Forwards: 1, + ForwardedMsat: 40_000, + Forwards: 1, }, decoded[peer][fwdKey(3)], ) @@ -547,14 +547,14 @@ func TestForwardingAbilityEncodeRejectsCaseCollision(t *testing.T) { abilities := map[string]map[string]ForwardingAbility{ strings.ToUpper(inPeer): { outPeer: { - ForwardedSat: 10, - Forwards: 1, + ForwardedMsat: 10_000, + Forwards: 1, }, }, inPeer: { outPeer: { - ForwardedSat: 20, - Forwards: 1, + ForwardedMsat: 20_000, + Forwards: 1, }, }, } @@ -589,7 +589,7 @@ func TestForwardingAbilityCodecRoundTripHighIndices(t *testing.T) { // Add pair that forwarded. enc = ForwardingAbility{ EffectiveUptimeS: 70, - ForwardedSat: int64(i + 1), + ForwardedMsat: int64(i + 1), FeeMsat: int64(i + 1), Forwards: 1, } @@ -598,7 +598,7 @@ func TestForwardingAbilityCodecRoundTripHighIndices(t *testing.T) { // Add up, but idle pair. enc = ForwardingAbility{EffectiveUptimeS: 60} dec = ForwardingAbility{ - EffectiveUptimeS: endTime - startTime, + EffectiveUptimeS: uint64(endTime - startTime), } } diff --git a/frdrpcserver/forwarding_ability.go b/frdrpcserver/forwarding_ability.go index 9cc8652..4e54577 100644 --- a/frdrpcserver/forwarding_ability.go +++ b/frdrpcserver/forwarding_ability.go @@ -124,12 +124,12 @@ func (s *RPCServer) ForwardingAbility(ctx context.Context, } nested[pair.PeerIn][pair.PeerOut] = frdrpc.ForwardingAbility{ - EffectiveUptimeS: int64( + EffectiveUptimeS: uint64( ability.EffectiveUptime.Seconds(), ), - ForwardedSat: int64(ability.ForwardedAmount), - FeeMsat: int64(ability.FeeMsat), - Forwards: ability.Forwards, + ForwardedMsat: int64(ability.ForwardedMsat), + FeeMsat: int64(ability.FeeMsat), + Forwards: ability.Forwards, } } diff --git a/frdrpcserver/forwarding_ability_test.go b/frdrpcserver/forwarding_ability_test.go index f9e905a..aa9512d 100644 --- a/frdrpcserver/forwarding_ability_test.go +++ b/frdrpcserver/forwarding_ability_test.go @@ -66,7 +66,7 @@ func TestForwardingAbility(t *testing.T) { PeerOut: peerOut, }: { EffectiveUptime: 90 * time.Second, - ForwardedAmount: 550, + ForwardedMsat: 550_000, FeeMsat: 1100, Forwards: 2, }, @@ -92,7 +92,8 @@ func TestForwardingAbility(t *testing.T) { t, 90, resp.Entries[0].EffectiveUptimeS, ) require.EqualValues( - t, 550, resp.Entries[0].ForwardedSat, + t, 550_000, + resp.Entries[0].ForwardedMsat, ) require.EqualValues( t, 1100, resp.Entries[0].FeeMsat, @@ -172,7 +173,7 @@ func TestForwardingAbility(t *testing.T) { return map[chanevents.PeerPair]chanevents.ForwardingAbility{ {PeerIn: peerIn, PeerOut: peerOut}: { EffectiveUptime: 10 * time.Second, - ForwardedAmount: 999, + ForwardedMsat: 999_000, }, }, nil }, diff --git a/itest/channel_events_test.go b/itest/channel_events_test.go index 2178bb1..2921a5d 100644 --- a/itest/channel_events_test.go +++ b/itest/channel_events_test.go @@ -230,9 +230,9 @@ func TestForwardingAbility(t *testing.T) { // The bob self-pair was up but never forwarded through itself, so it // surfaces via the up-but-idle bitmask: non-zero effective uptime and // no forwards, hence neither volume nor fees. - require.Greater(c.t, ability.EffectiveUptimeS, int64(0)) + require.Greater(c.t, ability.EffectiveUptimeS, uint64(0)) require.Zero(c.t, ability.Forwards) - require.Zero(c.t, ability.ForwardedSat) + require.Zero(c.t, ability.ForwardedMsat) require.Zero(c.t, ability.FeeMsat) } diff --git a/version.go b/version.go index 1b157b4..4220724 100644 --- a/version.go +++ b/version.go @@ -25,7 +25,7 @@ const ( // Please update release_notes.md when updating this! appMajor uint = 0 appMinor uint = 2 - appPatch uint = 17 + appPatch uint = 18 // appPreRelease MUST only contain characters from semanticAlphabet // per the semantic versioning spec.