Skip to content

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
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Sep 11, 2024
9ea6c12
gitignore
bryzettler Sep 12, 2024
a250645
rm migrations for clean db slate
bryzettler Sep 12, 2024
d36b034
Reads refactored and working
bryzettler Sep 12, 2024
707f31e
cargo
bryzettler Nov 8, 2024
83e6966
remove unused update_payer and opt for not defaulting locked
bryzettler Sep 17, 2024
351a0c1
conflicts
bryzettler Nov 8, 2024
04f6a73
conflicts
bryzettler Nov 8, 2024
9c49421
conflicts
bryzettler Nov 8, 2024
d068ff6
fix lock file
bryzettler Nov 8, 2024
12bc361
cargo build
bryzettler Nov 8, 2024
9afae96
remove legacy code
bryzettler Nov 20, 2024
eb95520
Added migation for payer => escrow_key and swaped out all instances o…
bryzettler Nov 22, 2024
dd34010
escrow_key logic change and tests pasting for iot_config
bryzettler Dec 3, 2024
c9b28b8
add test table migrations and trigger
bryzettler Dec 3, 2024
d09ae0e
update migration timestamp
bryzettler Dec 3, 2024
73b6212
add triggers to solana_organization table
bryzettler Dec 3, 2024
24affd2
update DevAddrEuiValidator logic
bryzettler Dec 4, 2024
531a64e
Fix toggling of locked
bryzettler Dec 4, 2024
4aeb2c2
pass payer as string for escrow_key
bryzettler Dec 6, 2024
72eb9cd
remove cargo patches
bryzettler Dec 6, 2024
f04628d
self review
bryzettler Dec 6, 2024
a4dc309
clippy
bryzettler Dec 6, 2024
34637ae
pr feedback
bryzettler Dec 10, 2024
ec61111
use V2 of org proto
bryzettler Dec 11, 2024
54e8ee5
update from helium-lib pr feedback
bryzettler Dec 20, 2024
2ae7e0a
fix tests
bryzettler Jan 15, 2025
704e051
unpatch crate
bryzettler Jan 17, 2025
2a461ef
Merge branch 'main' into feat/675-on-chain-ouis-devaddrs
bryzettler Feb 26, 2025
6fb7a40
Merge branch 'main' into feat/675-on-chain-ouis-devaddrs
bryzettler Feb 27, 2025
6343dec
payer => escrow_key
bryzettler Feb 27, 2025
76d7945
wip moving from solana Pubkey to helium_crypto::PublicKeyBinary
bryzettler Feb 27, 2025
3d6893c
Merge branch 'main' into feat/675-on-chain-ouis-devaddrs
bryzettler Mar 14, 2025
ed1dd82
payer => escrow_key and go back to PublicKeyBinary
bryzettler Mar 17, 2025
6a74356
add logic for keeping delegate cache upto date
bryzettler Mar 18, 2025
6a09a41
working with other packages
bryzettler Mar 21, 2025
bc7fb50
comment out patches
bryzettler Mar 21, 2025
6e8dd0f
Fix rebase issue
bryzettler Apr 15, 2025
d0f08e1
address pr comments
bryzettler Apr 15, 2025
fce6459
pr feedback
bryzettler Apr 17, 2025
d359fa6
tweaks
bryzettler Apr 17, 2025
c82c674
remove settings.toml
bryzettler Apr 17, 2025
4dd01e1
Merge branch 'main' into feat/675-on-chain-ouis-devaddrs
bryzettler Apr 17, 2025
a14fcd4
Merge branch 'main' into feat/675-on-chain-ouis-devaddrs
bryzettler May 22, 2025
28629c6
fixed merge issues
bryzettler May 27, 2025
14c93e6
tweaks
bryzettler May 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ flamegraph.*

!/minio/bucket-policy.json
*.bak
*settings.toml
47 changes: 24 additions & 23 deletions Cargo.lock

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

17 changes: 7 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ helium-crypto = { version = "0.9.2", features = ["multisig", "sqlx-postgres"] }
hextree = { git = "https://github.com/jaykickliter/HexTree", branch = "main", features = [
"disktree",
] }
helium-proto = { git = "https://github.com/helium/proto", branch = "master", features = [
"services",
] }
helium-proto = { git = "https://github.com/helium/proto", branch = "master", features = ["services"] }
beacon = { git = "https://github.com/helium/proto", branch = "master" }
reqwest = { version = "0", default-features = false, features = [
"gzip",
Expand Down Expand Up @@ -119,13 +117,12 @@ anchor-lang = { git = "https://github.com/madninja/anchor.git", branch = "madnin

# When attempting to test proto changes without needing to push a branch you can
# patch the github url to point to your local proto repo.
#
#
# Patching for beacon must point directly to the crate, it will not look in the
# repo for sibling crates.
#
# [patch.'https://github.com/helium/proto']
# helium-proto = { path = "../proto" }
# beacon = { path = "../proto/beacon" }
#
#[patch.'https://github.com/helium/proto']
#helium-proto = { path = "../proto" }

# [patch.'https://github.com/helium/proto']
# helium-proto = { git = "https://www.github.com/helium/proto.git", branch = "bbalser/deprecate-radio-reward-v1" }
#[patch.'https://github.com/helium/helium-wallet-rs']
#helium-lib = { path = "../helium-wallet-rs/helium-lib" }
5 changes: 2 additions & 3 deletions file_store/src/traits/msg_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@ impl_msg_verify!(LoraStreamSessionInitV1, signature);
impl_msg_verify!(DataTransferSessionReqV1, signature);
impl_msg_verify!(CoverageObjectReqV1, signature);
impl_msg_verify!(ServiceProviderBoostedRewardsBannedRadioReqV1, signature);
impl_msg_verify!(iot_config::OrgCreateHeliumReqV1, signature);
impl_msg_verify!(iot_config::OrgCreateRoamerReqV1, signature);
impl_msg_verify!(iot_config::OrgUpdateReqV1, signature);
impl_msg_verify!(iot_config::OrgDisableReqV1, signature);
impl_msg_verify!(iot_config::OrgEnableReqV1, signature);
impl_msg_verify!(iot_config::OrgDisableResV1, signature);
impl_msg_verify!(iot_config::OrgEnableResV1, signature);
impl_msg_verify!(iot_config::OrgResV1, signature);
impl_msg_verify!(iot_config::OrgListResV1, signature);
impl_msg_verify!(iot_config::OrgResV2, signature);
impl_msg_verify!(iot_config::OrgListResV2, signature);
impl_msg_verify!(iot_config::RouteStreamReqV1, signature);
impl_msg_verify!(iot_config::RouteListReqV1, signature);
impl_msg_verify!(iot_config::RouteGetReqV1, signature);
Expand Down
1 change: 1 addition & 0 deletions iot_config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ tracing-subscriber = { workspace = true }
triggered = { workspace = true }

custom-tracing = { path = "../custom_tracing", features = ["grpc"] }
solana = { path = "../solana" }
db-store = { path = "../db_store" }
file-store = { path = "../file_store" }
poc-metrics = { path = "../metrics" }
Expand Down
9 changes: 9 additions & 0 deletions iot_config/migrations/20241203190903_solana_net_ids.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Migration here solely for testing purposes
Copy link
Contributor

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?

Copy link
Author

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.

-- 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 iot_config/migrations/20241203190910_solana_organizations.sql
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();
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
)
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
);
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 iot_config/migrations/20241203193310_add_organization_locks.sql
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;
$$;
2 changes: 1 addition & 1 deletion iot_config/pkg/settings-template.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# log settings for the application (RUST_LOG format). Default below
#
#
# log = "iot-config=debug,poc_store=info"


Expand Down
Loading
Loading