Skip to content

Commit

Permalink
database: No longer store or retrieve InitialIP (#7942)
Browse files Browse the repository at this point in the history
The initialIP column has been defaulted to 0.0.0.0 since #7760. Remove
this field from the all structs while leaving the schema itself intact.

Part of #7917
  • Loading branch information
beautifulentropy authored Jan 13, 2025
1 parent 274d446 commit 45a56ae
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 91 deletions.
3 changes: 1 addition & 2 deletions cmd/bad-key-revoker/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ func insertRegistration(t *testing.T, dbMap *db.WrappedMap, fc clock.Clock, addr
}
res, err := dbMap.ExecContext(
context.Background(),
"INSERT INTO registrations (jwk, jwk_sha256, contact, agreement, initialIP, createdAt, status, LockCol) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
"INSERT INTO registrations (jwk, jwk_sha256, contact, agreement, createdAt, status, LockCol) VALUES (?, ?, ?, ?, ?, ?, ?)",
[]byte{},
fmt.Sprintf("%x", jwkHash),
contactStr,
"yes",
[]byte{},
fc.Now(),
string(core.StatusValid),
0,
Expand Down
129 changes: 60 additions & 69 deletions core/proto/core.pb.go

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

2 changes: 1 addition & 1 deletion core/proto/core.proto
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ message Registration {
repeated string contact = 3;
bool contactsPresent = 4;
string agreement = 5;
bytes initialIP = 6;
reserved 6; // Previously initialIP
reserved 7; // Previously createdAtNS
google.protobuf.Timestamp createdAt = 9;
string status = 8;
Expand Down
21 changes: 5 additions & 16 deletions sa/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"errors"
"fmt"
"math"
"net"
"net/url"
"slices"
"strconv"
Expand Down Expand Up @@ -274,18 +273,11 @@ type issuedNameModel struct {

// regModel is the description of a core.Registration in the database before
type regModel struct {
ID int64 `db:"id"`
Key []byte `db:"jwk"`
KeySHA256 string `db:"jwk_sha256"`
Contact string `db:"contact"`
Agreement string `db:"agreement"`
// InitialIP is stored as sixteen binary bytes, regardless of whether it
// represents a v4 or v6 IP address.
//
// Deprecated: This field is no longer used and will be removed from the
// database schema in a future release. Although deprecated, this column
// remains NOT NULL in the database, so a value must still be provided.
InitialIP []byte `db:"initialIp"`
ID int64 `db:"id"`
Key []byte `db:"jwk"`
KeySHA256 string `db:"jwk_sha256"`
Contact string `db:"contact"`
Agreement string `db:"agreement"`
CreatedAt time.Time `db:"createdAt"`
LockCol int64
Status string `db:"status"`
Expand Down Expand Up @@ -328,9 +320,6 @@ func registrationPbToModel(reg *corepb.Registration) (*regModel, error) {
KeySHA256: sha,
Contact: string(jsonContact),
Agreement: reg.Agreement,
// Although deprecated, this column remains NOT NULL in the database, so
// a value must still be provided.
InitialIP: net.ParseIP("0.0.0.0").To16(),
CreatedAt: createdAt,
Status: reg.Status,
}, nil
Expand Down
3 changes: 0 additions & 3 deletions wfe2/wfe.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,6 @@ func (wfe *WebFrontEndImpl) NewAccount(
ContactsPresent: contactsPresent,
Agreement: wfe.SubscriberAgreementURL,
Key: keyBytes,
// TODO(#7671): This must remain until InitialIP is removed from
// corepb.Registration.
InitialIP: net.ParseIP("0.0.0.0").To16(),
}

refundLimits, err := wfe.checkNewAccountLimits(ctx, ip)
Expand Down

0 comments on commit 45a56ae

Please sign in to comment.