Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ All notable changes to this project will be documented in this file.
- Client
- Add multicast publisher heartbeat sender — sends periodic UDP packets to each multicast group to keep PIM (S,G) mroute state alive on devices
- Fix panic in heartbeat sender when concurrent teardown requests race on close
- Onchain programs
- Add `doublezero-geolocation` program with 3 account types, 12 instructions, and foundation allowlist integration via serviceability CPI
- E2E tests
- Add daily devnet QA test for device provisioning lifecycle (RFC12) — deletes/recreates device and links, restarts daemons with new pubkey via Ansible

Expand Down
16 changes: 16 additions & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"smartcontract/programs/doublezero-record",
"smartcontract/programs/doublezero-serviceability",
"smartcontract/programs/doublezero-telemetry",
"smartcontract/programs/doublezero-geolocation",
"smartcontract/programs/common",
"e2e/docker/ledger/fork-accounts",
]
Expand Down Expand Up @@ -109,3 +110,7 @@ features = ["no-entrypoint"]
[workspace.dependencies.doublezero-telemetry]
path = "smartcontract/programs/doublezero-telemetry"
features = ["no-entrypoint"]

[workspace.dependencies.doublezero-geolocation]
path = "smartcontract/programs/doublezero-geolocation"
features = ["no-entrypoint"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ rust-build-programs:
.PHONY: rust-lint
rust-lint: rust-fmt-check
@cargo install cargo-hack
cargo hack clippy --workspace --all-targets --exclude doublezero-telemetry --exclude doublezero-serviceability --exclude doublezero-program-common --exclude doublezero-record -- -Dclippy::all -Dwarnings
cargo hack clippy --workspace --all-targets --exclude doublezero-telemetry --exclude doublezero-serviceability --exclude doublezero-program-common --exclude doublezero-record --exclude doublezero-geolocation -- -Dclippy::all -Dwarnings
cd smartcontract && $(MAKE) lint-programs

.PHONY: rust-fmt
Expand All @@ -94,7 +94,7 @@ rust-fmt-check:

.PHONY: rust-test
rust-test:
cargo test --workspace --exclude doublezero-telemetry --exclude doublezero-serviceability --exclude doublezero-program-common --exclude doublezero-record --all-features
cargo test --workspace --exclude doublezero-telemetry --exclude doublezero-serviceability --exclude doublezero-program-common --exclude doublezero-record --exclude doublezero-geolocation --all-features
cd smartcontract && $(MAKE) test-programs
$(MAKE) rust-program-accounts-compat

Expand Down
8 changes: 6 additions & 2 deletions smartcontract/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ test-programs: test-sbf
-p doublezero-program-common \
-p doublezero-record \
-p doublezero-telemetry \
-p doublezero-serviceability
-p doublezero-serviceability \
-p doublezero-geolocation

.PHONY: test-sbf
test-sbf:
cargo test --lib \
-p doublezero-program-common \
-p doublezero-record \
-p doublezero-telemetry \
-p doublezero-serviceability
-p doublezero-serviceability \
-p doublezero-geolocation

.PHONY: lint
lint: lint-programs
Expand All @@ -48,6 +50,7 @@ lint-programs:
-p doublezero-record \
-p doublezero-telemetry \
-p doublezero-serviceability \
-p doublezero-geolocation \
$(CLIPPY_FLAGS)

.PHONY: build
Expand All @@ -60,3 +63,4 @@ build-programs:
cd programs/doublezero-record && cargo build-sbf
cd programs/doublezero-serviceability && cargo build-sbf
cd programs/doublezero-telemetry && cargo build-sbf --features $(env)
cd programs/doublezero-geolocation && cargo build-sbf
35 changes: 35 additions & 0 deletions smartcontract/programs/doublezero-geolocation/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "doublezero-geolocation"

# clippy ignores rust-version.toml
rust-version = "1.84.1" # cargo build-sbf --version

# Workspace inherited keys
version.workspace = true
authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
repository.workspace = true

[lib]
crate-type = ["cdylib", "lib"]

[dependencies]
borsh.workspace = true
borsh-incremental.workspace = true
serde = { workspace = true, optional = true }
serde_bytes = { workspace = true, optional = true }
solana-program.workspace = true
doublezero-program-common.workspace = true
doublezero-serviceability.workspace = true
thiserror.workspace = true

[dev-dependencies]
solana-sdk.workspace = true
solana-program-test.workspace = true

[features]
default = []
no-entrypoint = []
serde = ["dep:serde", "dep:serde_bytes"]
69 changes: 69 additions & 0 deletions smartcontract/programs/doublezero-geolocation/src/entrypoint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
use crate::{
instructions::GeolocationInstruction,
processors::{
geo_probe::{
add_parent_device::process_add_parent_device, create::process_create_geo_probe,
delete::process_delete_geo_probe, remove_parent_device::process_remove_parent_device,
update::process_update_geo_probe,
},
geolocation_user::{
add_target::process_add_target, create::process_create_geolocation_user,
delete::process_delete_geolocation_user, remove_target::process_remove_target,
update::process_update_geolocation_user,
update_payment_status::process_update_payment_status,
},
program_config::init::process_init_program_config,
},
};

use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg, pubkey::Pubkey};

#[cfg(not(feature = "no-entrypoint"))]
solana_program::entrypoint!(process_instruction);

pub fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
data: &[u8],
) -> ProgramResult {
let instruction = GeolocationInstruction::unpack(data)?;

msg!("Instruction: {:?}", instruction);

match instruction {
GeolocationInstruction::InitProgramConfig(args) => {
process_init_program_config(program_id, accounts, &args)?
}
GeolocationInstruction::CreateGeoProbe(args) => {
process_create_geo_probe(program_id, accounts, &args)?
}
GeolocationInstruction::UpdateGeoProbe(args) => {
process_update_geo_probe(program_id, accounts, &args)?
}
GeolocationInstruction::DeleteGeoProbe => process_delete_geo_probe(program_id, accounts)?,
GeolocationInstruction::AddParentDevice(args) => {
process_add_parent_device(program_id, accounts, &args)?
}
GeolocationInstruction::RemoveParentDevice(args) => {
process_remove_parent_device(program_id, accounts, &args)?
}
GeolocationInstruction::CreateGeolocationUser(args) => {
process_create_geolocation_user(program_id, accounts, &args)?
}
GeolocationInstruction::UpdateGeolocationUser(args) => {
process_update_geolocation_user(program_id, accounts, &args)?
}
GeolocationInstruction::DeleteGeolocationUser => {
process_delete_geolocation_user(program_id, accounts)?
}
GeolocationInstruction::AddTarget(args) => process_add_target(program_id, accounts, &args)?,
GeolocationInstruction::RemoveTarget(args) => {
process_remove_target(program_id, accounts, &args)?
}
GeolocationInstruction::UpdatePaymentStatus(args) => {
process_update_payment_status(program_id, accounts, &args)?
}
};

Ok(())
}
Loading
Loading