-
Notifications
You must be signed in to change notification settings - Fork 28
Feat/675 on chain ouis devaddrs #972
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
Open
bryzettler
wants to merge
46
commits into
main
Choose a base branch
from
feat/675-on-chain-ouis-devaddrs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
6b001b0
Rename tables to temp and update read sql
bryzettler 9ea6c12
gitignore
bryzettler a250645
rm migrations for clean db slate
bryzettler d36b034
Reads refactored and working
bryzettler 707f31e
cargo
bryzettler 83e6966
remove unused update_payer and opt for not defaulting locked
bryzettler 351a0c1
conflicts
bryzettler 04f6a73
conflicts
bryzettler 9c49421
conflicts
bryzettler d068ff6
fix lock file
bryzettler 12bc361
cargo build
bryzettler 9afae96
remove legacy code
bryzettler eb95520
Added migation for payer => escrow_key and swaped out all instances o…
bryzettler dd34010
escrow_key logic change and tests pasting for iot_config
bryzettler c9b28b8
add test table migrations and trigger
bryzettler d09ae0e
update migration timestamp
bryzettler 73b6212
add triggers to solana_organization table
bryzettler 24affd2
update DevAddrEuiValidator logic
bryzettler 531a64e
Fix toggling of locked
bryzettler 4aeb2c2
pass payer as string for escrow_key
bryzettler 72eb9cd
remove cargo patches
bryzettler f04628d
self review
bryzettler a4dc309
clippy
bryzettler 34637ae
pr feedback
bryzettler ec61111
use V2 of org proto
bryzettler 54e8ee5
update from helium-lib pr feedback
bryzettler 2ae7e0a
fix tests
bryzettler 704e051
unpatch crate
bryzettler 2a461ef
Merge branch 'main' into feat/675-on-chain-ouis-devaddrs
bryzettler 6fb7a40
Merge branch 'main' into feat/675-on-chain-ouis-devaddrs
bryzettler 6343dec
payer => escrow_key
bryzettler 76d7945
wip moving from solana Pubkey to helium_crypto::PublicKeyBinary
bryzettler 3d6893c
Merge branch 'main' into feat/675-on-chain-ouis-devaddrs
bryzettler ed1dd82
payer => escrow_key and go back to PublicKeyBinary
bryzettler 6a74356
add logic for keeping delegate cache upto date
bryzettler 6a09a41
working with other packages
bryzettler bc7fb50
comment out patches
bryzettler 6e8dd0f
Fix rebase issue
bryzettler d0f08e1
address pr comments
bryzettler fce6459
pr feedback
bryzettler d359fa6
tweaks
bryzettler c82c674
remove settings.toml
bryzettler 4dd01e1
Merge branch 'main' into feat/675-on-chain-ouis-devaddrs
bryzettler a14fcd4
Merge branch 'main' into feat/675-on-chain-ouis-devaddrs
bryzettler 28629c6
fixed merge issues
bryzettler 14c93e6
tweaks
bryzettler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ flamegraph.* | |
|
||
!/minio/bucket-policy.json | ||
*.bak | ||
*settings.toml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- Migration here solely for testing purposes | ||
-- An instance of account-postgres-sink | ||
-- Will alter this table depending on an on-chain struct | ||
CREATE TABLE IF NOT EXISTS solana_net_ids ( | ||
address TEXT PRIMARY KEY, | ||
id INTEGER NOT NULL, | ||
authority TEXT NOT NULL, | ||
current_addr_offset NUMERIC NOT NULL | ||
); |
39 changes: 39 additions & 0 deletions
39
iot_config/migrations/20241203190910_solana_organizations.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- Migration here solely for testing purposes | ||
-- An instance of account-postgres-sink | ||
-- Will alter this table depending on an on-chain struct | ||
CREATE TABLE IF NOT EXISTS solana_organizations ( | ||
address TEXT PRIMARY KEY, | ||
net_id TEXT NOT NULL, | ||
authority TEXT NOT NULL, | ||
oui BIGINT NOT NULL, | ||
escrow_key TEXT NOT NULL, | ||
approved BOOLEAN NOT NULL | ||
); | ||
|
||
CREATE OR REPLACE FUNCTION delete_routes_on_solana_organizations_delete() RETURNS trigger AS $$ | ||
BEGIN | ||
DELETE FROM routes WHERE routes.oui = OLD.oui; | ||
RETURN OLD; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
CREATE TRIGGER delete_routes_on_solana_organizations_delete | ||
AFTER DELETE ON solana_organizations | ||
FOR EACH ROW | ||
EXECUTE FUNCTION delete_routes_on_solana_organizations_delete(); | ||
|
||
CREATE OR REPLACE FUNCTION add_lock_record_on_solana_organizations_insert() RETURNS trigger AS $$ | ||
BEGIN | ||
INSERT INTO organization_locks (organization, locked) | ||
SELECT sol_org.address, COALESCE(org.locked, TRUE) | ||
FROM solana_organizations sol_org | ||
LEFT JOIN organizations org ON sol_org.oui = org.oui | ||
WHERE sol_org.address = NEW.address; | ||
RETURN NEW; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
CREATE TRIGGER add_lock_record_on_solana_organizations_insert | ||
AFTER INSERT ON solana_organizations | ||
FOR EACH ROW | ||
EXECUTE FUNCTION add_lock_record_on_solana_organizations_insert(); |
10 changes: 10 additions & 0 deletions
10
iot_config/migrations/20241203190923_solana_organization_devaddr_constraints.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- Migration here solely for testing purposes | ||
-- An instance of account-postgres-sink | ||
-- Will alter this table depending on an on-chain struct | ||
CREATE TABLE IF NOT EXISTS solana_organization_devaddr_constraints ( | ||
address TEXT PRIMARY KEY, | ||
net_id TEXT NOT NULL, | ||
organization TEXT NOT NULL, | ||
start_addr NUMERIC NOT NULL, | ||
end_addr NUMERIC NOT NULL | ||
) |
8 changes: 8 additions & 0 deletions
8
iot_config/migrations/20241203190936_solana_organization_delegate_keys.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Migration here solely for testing purposes | ||
-- An instance of account-postgres-sink | ||
-- Will alter this table depending on an on-chain struct | ||
CREATE TABLE IF NOT EXISTS solana_organization_delegate_keys ( | ||
address TEXT PRIMARY KEY, | ||
organization TEXT NOT NULL, | ||
delegate TEXT NOT NULL | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE routes DROP CONSTRAINT IF EXISTS routes_oui_fkey; |
22 changes: 22 additions & 0 deletions
22
iot_config/migrations/20241203193310_add_organization_locks.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
create table organization_locks ( | ||
organization TEXT PRIMARY KEY NOT NULL, | ||
locked BOOL DEFAULT false, | ||
inserted_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now() | ||
); | ||
|
||
select trigger_updated_at('organization_locks'); | ||
|
||
DO $$ | ||
BEGIN | ||
IF EXISTS ( | ||
SELECT FROM information_schema.tables | ||
WHERE table_name = 'solana_organizations' | ||
) THEN | ||
INSERT INTO organization_locks (organization, locked) | ||
SELECT sol_org.address, org.locked | ||
FROM solana_organizations sol_org | ||
LEFT JOIN organizations org ON sol_org.oui = org.oui; | ||
END IF; | ||
END; | ||
$$; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could we move all the tables for testing into a single migration file?
Or into the fixtures folder somehow so we don't have to wonder about dangling tables in prod that are unused?
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.
These tables should never be dangling as they are the exact tables that a postgres_sink_instance will be creating/managing. They just need to exist at runtime for the tests also.