Skip to content

Commit 50e7375

Browse files
authored
account bundle migration cleanup (keybase#14890)
* loads of stellar bundle cleanups first pass only create v2 bundles only postwithchainlink v2 bundles stop posting v1 bundles stop fetching v1 bundles remove v1 bundles remove v1 bundle objects from avdl reclaim Bundle type names without Restricted disambiguate AccountBundle pull out boxing logic from bundle.go the way the old bundle stuff had it fix the wrong version type add back the old bundle tests but updated for the new paradigm completely remove all remaining references to stellar_acct_bundles feature fix stellar upkeep bug CORE-9574 consolidate pukGen leaking from bundle fetching apis * remove unused variable in test * push FetchWholeBundle down into a private test method
1 parent eb34099 commit 50e7375

28 files changed

Lines changed: 1396 additions & 2711 deletions

‎go/libkb/features.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ type FeatureFlagSet struct {
6464
}
6565

6666
const (
67-
FeatureFTL = Feature("ftl")
68-
FeatureStellarAcctBundles = Feature("stellar_acct_bundles")
69-
FeatureIMPTOFU = Feature("imptofu")
67+
FeatureFTL = Feature("ftl")
68+
FeatureIMPTOFU = Feature("imptofu")
7069
)
7170

7271
// NewFeatureFlagSet makes a new set of feature flags.

‎go/protocol/stellar1/bundle.go‎

Lines changed: 12 additions & 150 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎go/protocol/stellar1/extras.go‎

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -125,44 +125,13 @@ func (s SecretKey) SecureNoLogString() string {
125125
return string(s)
126126
}
127127

128-
// CheckInvariants checks that the bundle satisfies
128+
// CheckInvariants checks that the Bundle satisfies
129129
// 1. No duplicate account IDs
130130
// 2. Exactly one primary account
131131
// 3. Non-negative revision numbers
132-
func (s Bundle) CheckInvariants() error {
133-
accountIDs := make(map[AccountID]bool)
134-
var foundPrimary bool
135-
for _, entry := range s.Accounts {
136-
_, found := accountIDs[entry.AccountID]
137-
if found {
138-
return fmt.Errorf("duplicate account ID: %v", entry.AccountID)
139-
}
140-
accountIDs[entry.AccountID] = true
141-
if entry.IsPrimary {
142-
if foundPrimary {
143-
return errors.New("multiple primary accounts")
144-
}
145-
foundPrimary = true
146-
}
147-
if entry.Mode == AccountMode_NONE {
148-
return errors.New("account missing mode")
149-
}
150-
}
151-
if !foundPrimary {
152-
return errors.New("missing primary account")
153-
}
154-
if s.Revision < 1 {
155-
return fmt.Errorf("revision %v < 1", s.Revision)
156-
}
157-
return nil
158-
}
159-
160-
// CheckInvariants checks that the BundleRestricted satisfies
161-
// 1. No duplicate account IDs
162-
// 2. Exactly one primary account
163-
// 3. Non-negative revision numbers
164-
// 4. Account Bundle maps to Accounts
165-
func (r BundleRestricted) CheckInvariants() error {
132+
// 4. Account Bundle accountIDs are consistent
133+
// 5. every account in AccountBundles is also in Accounts
134+
func (r Bundle) CheckInvariants() error {
166135
accountIDs := make(map[AccountID]bool)
167136
var foundPrimary bool
168137
for _, entry := range r.Accounts {
@@ -194,6 +163,15 @@ func (r BundleRestricted) CheckInvariants() error {
194163
if accID != accBundle.AccountID {
195164
return fmt.Errorf("account ID mismatch in bundle for %v", accID)
196165
}
166+
var AccountBundleInAccounts bool
167+
for _, accountListAccount := range r.Accounts {
168+
if accountListAccount.AccountID == accID {
169+
AccountBundleInAccounts = true
170+
}
171+
}
172+
if !AccountBundleInAccounts {
173+
return fmt.Errorf("account in AccountBundles not in Accounts %v", accID)
174+
}
197175
}
198176
return nil
199177
}
@@ -207,15 +185,6 @@ func (s Bundle) PrimaryAccount() (BundleEntry, error) {
207185
return BundleEntry{}, errors.New("primary stellar account not found")
208186
}
209187

210-
func (s BundleRestricted) PrimaryAccount() (BundleEntryRestricted, error) {
211-
for _, entry := range s.Accounts {
212-
if entry.IsPrimary {
213-
return entry, nil
214-
}
215-
}
216-
return BundleEntryRestricted{}, errors.New("primary stellar account not found")
217-
}
218-
219188
func (s Bundle) Lookup(acctID AccountID) (BundleEntry, error) {
220189
for _, entry := range s.Accounts {
221190
if entry.AccountID == acctID {
@@ -225,15 +194,6 @@ func (s Bundle) Lookup(acctID AccountID) (BundleEntry, error) {
225194
return BundleEntry{}, errors.New("stellar account not found")
226195
}
227196

228-
func (s BundleRestricted) Lookup(acctID AccountID) (BundleEntryRestricted, error) {
229-
for _, entry := range s.Accounts {
230-
if entry.AccountID == acctID {
231-
return entry, nil
232-
}
233-
}
234-
return BundleEntryRestricted{}, errors.New("stellar account not found")
235-
}
236-
237197
// Eq compares assets strictly.
238198
// Assets are not Eq if their type is different
239199
// even if they have the same code and issuer.

‎go/protocol/stellar1/local.go‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)