Skip to content

smartcontract: add bgp_status, last_bgp_up_at, last_bgp_reported_at to User#3467

Merged
juan-malbeclabs merged 6 commits into
mainfrom
jo/3465-2
Apr 7, 2026
Merged

smartcontract: add bgp_status, last_bgp_up_at, last_bgp_reported_at to User#3467
juan-malbeclabs merged 6 commits into
mainfrom
jo/3465-2

Conversation

@juan-malbeclabs
Copy link
Copy Markdown
Contributor

@juan-malbeclabs juan-malbeclabs commented Apr 6, 2026

Solves: #3465

Summary of Changes

  • Adds three new fields to the onchain User struct: bgp_status (BGPStatus enum: Unknown/Up/Down, 1 byte), last_bgp_up_at (slot number of the most recent BGP up event, 8 bytes), and last_bgp_reported_at (slot number of the most recent BGP status report, 8 bytes)
  • Old accounts without these bytes deserialize with zero/Unknown defaults (unwrap_or_default in TryFrom), preserving backward compatibility
  • Propagates the new fields to all read-only SDKs: internal Go SDK (smartcontract/sdk/go/serviceability), external Go SDK (sdk/serviceability/go), TypeScript SDK, and Python SDK — each with BGPStatus type/enum and updated deserializers
  • Updates the AIRDROP_USER_RENT_LAMPORTS_BYTES constant (723 → 774) to account for the larger User account size (241 → 258 bytes per account)

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 8 +180 / -18 +162
Scaffolding 23 +201 / -1 +200
Tests 5 +69 / -12 +57
Fixtures 5 +34 / -7 +27
Total 41 +485 / -38 +447

Most of the diff is mechanical scaffolding (struct initializations across activator, client, CLI, and SDK commands); the meaningful changes are concentrated in the state definition and SDK deserializers.

Key files (click to expand)
  • smartcontract/programs/doublezero-serviceability/src/state/user.rs — adds the three new fields to the User struct, updates TryFrom<&[u8]> with unwrap_or_default, updates backward-compat test to strip 18 bytes, adds assertions for new fields
  • activator/src/process/user.rs — 19 User struct initializations updated with new fields
  • smartcontract/cli/src/user/list.rs — 18 User struct initializations updated
  • sdk/serviceability/go/state.go — adds BGPStatus type with String(), adds BgpStatus, LastBgpUpAt, LastBgpReportedAt to User struct
  • sdk/serviceability/typescript/serviceability/state.ts — adds BGP_STATUS_* constants, bgpStatusString(), and new fields to the User interface and deserializer
  • sdk/serviceability/python/serviceability/state.py — adds BGPStatus(IntEnum) and new fields to the User dataclass and from_bytes()
  • smartcontract/programs/doublezero-serviceability/src/processors/accesspass/set.rs — updates AIRDROP_USER_RENT_LAMPORTS_BYTES (258×3=774) and size assertions in the test
  • sdk/serviceability/testdata/fixtures/generate-fixtures/src/main.rs — fixture generator sets bgp_status: BGPStatus::Up, last_bgp_up_at: 1_700_000_000, last_bgp_reported_at: 1_700_000_100

Testing Verification

  • make rust-test passes (230+ tests across serviceability program, all SDK crates, activator, client, CLI)
  • make rust-lint clean
  • Backward-compat test in state/user.rs verifies that truncating the last 18 bytes of a serialized User deserializes tunnel_flags, bgp_status, last_bgp_up_at, and last_bgp_reported_at all as zero/Unknown
  • All three external SDK fixture tests (Go, TypeScript, Python) assert the new fields against the regenerated user.bin fixture (258 bytes), plus backward-compat tests using a truncated binary

RFC: rfcs/rfc19-user-bgp-status.md

@juan-malbeclabs juan-malbeclabs linked an issue Apr 6, 2026 that may be closed by this pull request
@juan-malbeclabs juan-malbeclabs enabled auto-merge (squash) April 6, 2026 19:37
Comment thread sdk/serviceability/testdata/fixtures/user.json Outdated
Comment thread sdk/serviceability/go/state.go Outdated
…o User

Adds three new fields to the User struct (1+8+8 = 17 bytes):
- bgp_status: BGPStatus enum (Unknown/Up/Down), defaults to Unknown
- last_bgp_up_at: slot number of the most recent BGP up event
- last_bgp_reported_at: slot number of the most recent BGP status report

Old accounts without these bytes deserialize with zero/Unknown defaults
(backward-compatible via unwrap_or_default in TryFrom).

Updates all User struct initializations across activator, client,
controlplane, smartcontract programs, cli, and sdk/rs. Regenerates
fixtures (user.bin now 258 bytes, up from 241).
@juan-malbeclabs juan-malbeclabs merged commit 3be9358 into main Apr 7, 2026
49 of 69 checks passed
@juan-malbeclabs juan-malbeclabs deleted the jo/3465-2 branch April 7, 2026 19:28
@juan-malbeclabs juan-malbeclabs linked an issue Apr 8, 2026 that may be closed by this pull request
@juan-malbeclabs juan-malbeclabs linked an issue Apr 8, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PR 2 - Account changes & SDK updates

2 participants