-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(backend): rename "payment pointer" tables & columns to use "wallet address" #1937
feat(backend): rename "payment pointer" tables & columns to use "wallet address" #1937
Conversation
The backend service isn't going to build in this branch (yet), but the migration should run successfully. |
84baa04
to
d8ea382
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This concern spans this PR as well as the code changes. There are payment pointer webhook events which are being renamed to wallet address. I think there will be webhook events with JSON payloads with a paymentPointer
key in existing deployments (e.g. testnet). Can we rule out that this will cause any problems? Are we never referencing the walletAddress
key in the event payload read from the db? Otherwise I think we'd need to update the keys to walletAddress
.
This is the same potential issue I ran into when renaming sendAmount
-> debitAmount
here: #1755 (comment)
This is what the migration to rename the keys looked like: https://github.com/interledger/rafiki/blob/main/packages/auth/migrations/20230907201006_rename-limits-jsonb-keys.js
5294676
to
d1cca1c
Compare
packages/backend/migrations/20230918113102_rename_payment_pointer_tables.js
Outdated
Show resolved
Hide resolved
}), | ||
knex.schema.alterTable('quotes', function (table) { | ||
table.renameColumn('paymentPointerId', 'walletAddressId') | ||
table.foreign('walletAddressId').references('walletAddresses.id') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not actually sure, what happens to the existing paymentPointer.id
foreign key here? Does it get properly handled in the rename, or dropped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also applies the indexes (not pictured above) in line 16: table.index(['walletAddressId', 'createdAt', 'id'])
.
Looks like the migration is duplicating these. Two fkey constraints with different fkey names but the same relationship. I think we can just remove the table.foreign('walletAddressId').references('walletAddresses.id')
line (and the indexes). This is what I see in Indexes
and Foreign-key constraints:
from doing a \d quotes
after this migration.
quote:
Indexes:
"quotes_pkey" PRIMARY KEY, btree (id)
"quotes_paymentpointerid_createdat_id_index" btree ("walletAddressId", "createdAt", id)
"quotes_walletaddressid_createdat_id_index" btree ("walletAddressId", "createdAt", id)
Foreign-key constraints:
"quotes_assetid_foreign" FOREIGN KEY ("assetId") REFERENCES assets(id)
"quotes_feeid_foreign" FOREIGN KEY ("feeId") REFERENCES fees(id)
"quotes_paymentpointerid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
"quotes_walletaddressid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
and here is some of \d "walletAddresses"
for good measure (see the duplicate quote fkey):
Referenced by:
TABLE ""incomingPayments"" CONSTRAINT "incomingpayments_paymentpointerid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
TABLE ""incomingPayments"" CONSTRAINT "incomingpayments_walletaddressid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
TABLE ""outgoingPayments"" CONSTRAINT "outgoingpayments_paymentpointerid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
TABLE ""outgoingPayments"" CONSTRAINT "outgoingpayments_walletaddressid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
TABLE ""walletAddressKeys"" CONSTRAINT "paymentpointerkeys_paymentpointerid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
TABLE "quotes" CONSTRAINT "quotes_paymentpointerid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
TABLE "quotes" CONSTRAINT "quotes_walletaddressid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
TABLE ""walletAddressKeys"" CONSTRAINT "walletaddresskeys_walletaddressid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually instead of removing these lines we might want to just drop the old one. This way we end up with "quotes_walletaddressid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id)
instead of "quotes_paymentpointerid_foreign" FOREIGN KEY ("walletAddressId") REFERENCES "walletAddresses"(id).
So doing like:
knex.schema.alterTable('quotes', function (table) {
table.dropForeign(['paymentPointerId'])
table.dropIndex(['paymentPointerId', 'createdAt', 'id'])
table.renameColumn('paymentPointerId', 'walletAddressId')
table.foreign('walletAddressId').references('walletAddresses.id')
table.index(['walletAddressId', 'createdAt', 'id'])
}),
data: knex.raw( | ||
"data::jsonb - 'paymentPointerUrl' || jsonb_build_object('walletAddressUrl', data::jsonb->'paymentPointerUrl')" | ||
) | ||
}) | ||
.whereRaw("data->'paymentPointerUrl' is not null"), | ||
knex('webhookEvents') | ||
.update({ | ||
// renames payment_pointer.not_found values (if any) to wallet_address.not_found for type key in data json column | ||
type: knex.raw("REPLACE(type, 'payment_pointer.', 'wallet_address.')") | ||
}) | ||
.whereLike('type', 'payment_pointer%') | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i inserted some dummy data before this migration and this and similar all seem to be working correctly
table.foreign('walletAddressId').references('walletAddresses.id') | ||
table.index(['walletAddressId']) | ||
table.index(['createdAt']) | ||
table.index(['id']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indexes are not aggregated because the original indexes weren't either. Aggregating them produces, for example:
Indexes:
"outgoingpayments_walletaddressid_createdat_id_index" btree ("walletAddressId", "createdAt", id)
Whereas originally the indexes were not aggregated:
"outgoingpayments_paymentpointerid__index" btree ("paymentPointerId")
"outgoingpayments_createdat_index" btree ("createdAt")
"outgoingpayments_id_index" btree (id)
So table.index
is called separately each time to preserve this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indexes are not aggregated because the original indexes weren't either.
It seems like they are originally 1 composite index to me but maybe I'm missing something... without running this migration I see "outgoingpayments_paymentpointerid_createdat_id_index" btree ("paymentPointerId", "createdAt", id)
(same for quotes
, did not check the rest). It's also what I would expect from the original migration:
rafiki/packages/backend/migrations/20221129213751_create_outgoing_payments_table.js
Line 28 in 07cff89
table.index(['paymentPointerId', 'createdAt', 'id']) |
If they were seperate indexes I also don't think we'd need to do table.dropIndex(['paymentPointerId', 'createdAt', 'id'])
, but instead would just drop the payment pointer one (and thus not have to re-add the others).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, they're composite. A misreading on my part earlier. So we'll keep the composite dropping & adding of these indexes.
bc761b0
to
b1bde3d
Compare
ab8f43e
to
efe2cd7
Compare
4f1a863
to
b1bde3d
Compare
b1bde3d
to
bc761b0
Compare
…et address" (#1937) Co-authored-by: Nathan Lie <nathanlie@Nathans-MacBook-Pro.local>
* feat(backend): rename "payment pointer" tables & columns to use "wallet address" (#1937) Co-authored-by: Nathan Lie <nathanlie@Nathans-MacBook-Pro.local> * feat(backend, mock-ase): rename payment pointer to wallet address in rafiki code (#2029) * fix(backend): rename paymentPointerId column in combinedPaymentsView to walletAddressId (#2043) * docs: replace payment pointer with wallet address (#1951) * feat(backend): remove connections route (#1940) (#2051) Co-authored-by: Ömer Talha Özdemir <omer@fynbos.dev> * feat(backend): unauthenticated get incoming payment (#1952) (#2052) Co-authored-by: Ömer Talha Özdemir <omer@fynbos.dev> Co-authored-by: Blair Currey <12960453+BlairCurrey@users.noreply.github.com> * feat(auth): fix auth tests for access tokens (#2053) * feat(backend): remove payment pointer from url, retrieve it from request query or body (#2042) * refactor(backend): swap connection for methods (#2054) Co-authored-by: Nathan Lie <lie4nathan@gmail.com> * fix(backend): resolve breaking build after main rebase (#2085) * fix(backend): combined_payment, ilp service tests (#2094) * fix(backend): combined_payment, ilp service tests * chore(backend): format * fix(backend): bad test refactor * fix(postman): invalid json (#2096) * fix: fetch walletAddress graph in quote and outgoing payment service (#2099) * fix(postman): env var usage (#2107) * feat(backend): add quotes route to exceptions in wallet address middleware (#2108) * chore: formatting * fix(backend): fix GET /incoming-payments (#2111) * fix(backend): remove wallet address from OP response id and fix receiver service (#2115) * fix: remove wallet address from op resource urls * feat: return auth server url in public incoming payment and fix receiver service * fix: quote issue * fix: walletAddress middleware * chore: update postman * fix: listing * chore: remove console.log * fix: progress towards making listing work * fix(backend): fix create remote incoming payment (#2121) * fix(postman): misc postman fixes * fix(postman): complete incoming payment (#2126) * fix: file name correction (#2127) * fix: GET resource lists, use op client (#2122) * fix(postman): update list urls * fix(openapi): rm defaults for first, last * refactor(postman): query param order for readability * fix(backend): update to new open-payments pkgs * fix(backend): use op client to get authServer * fix(backend): rm old code * fix(backend): receiver tests * chore: cleanup * feat: make list query parameter configurable * chore: update OP package and fix types --------- Co-authored-by: Sabine Schaller <sabine@interledger.org> * fix(postman): additional fixes * fix: wallet address on the fly creation (#2129) * chore: update postman environments * Postman: update description for P2P example * Postman: Remove finalizationReason from getGrants API + fix createWalletAddress * chore: bump open-payments package in auth * chore: update last few remaining mentions of payment pointers * chore(postman): remove references to payment pointer * chore: update another reference to pp --------- Co-authored-by: Nathan Lie <nathanlie@Nathans-MacBook-Pro.local> Co-authored-by: Ömer Talha Özdemir <omer@fynbos.dev> Co-authored-by: Blair Currey <12960453+BlairCurrey@users.noreply.github.com> Co-authored-by: Sabine Schaller <sabine@interledger.org> Co-authored-by: Sarah Jones <sarah38186@gmail.com> Co-authored-by: Max Kurapov <maxkurapov@gmail.com> Co-authored-by: Max Kurapov <max@interledger.org>
Changes proposed in this pull request
Context
Fixes #1934.
Checklist
fixes #number