Skip to content

#830 [Contracts] Implement Keep-Alive Ping Ledger Updates FIXED#890

Merged
ONEONUORA merged 1 commit into
Fracverse:masterfrom
Kappa16:#830--Contracts]-Implement-Keep-Alive-Ping-Ledger-Updates-FIX
Jun 29, 2026
Merged

#830 [Contracts] Implement Keep-Alive Ping Ledger Updates FIXED#890
ONEONUORA merged 1 commit into
Fracverse:masterfrom
Kappa16:#830--Contracts]-Implement-Keep-Alive-Ping-Ledger-Updates-FIX

Conversation

@Kappa16

@Kappa16 Kappa16 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Findings

After reviewing the InheritX codebase, the issue was located in the Soroban smart contract:

contracts/inheritance-contract/src/lib.rs

The project is building a Stellar/Soroban-based digital inheritance protocol where a plan owner locks assets and periodically sends a proof-of-life ping. That ping keeps the inheritance plan alive by resetting the inactivity timer.

The existing ping function already did most of the required work:

pub fn ping(env: Env, owner: Address) -> Result<(), Error> {
    owner.require_auth();

    let key = DataKey::Plan(owner.clone());
    if !env.storage().persistent().has(&key) {
        return Err(Error::PlanNotFound);
    }

    let mut plan: Plan = env.storage().persistent().get(&key).unwrap();
    plan.last_ping = env.ledger().timestamp();

    env.storage().persistent().set(&key, &plan);
    Self::extend_plan_ttl(&env, &key);

    Ok(())
}

It already:

  • Required authorization from the owner using owner.require_auth().
  • Checked that the inheritance plan exists.
  • Updated the last_ping field.
  • Saved the updated plan.
  • Extended the plan storage TTL.

However, the issue acceptance criteria also required:

Emits a contract event detailing the keep-alive ping.

That event emission was missing.


Fix Features Added

The fix adds a Soroban event after a successful keep-alive ping.

Updated implementation:

let mut plan: Plan = env.storage().persistent().get(&key).unwrap();
let current_timestamp = env.ledger().timestamp();
plan.last_ping = current_timestamp;

env.storage().persistent().set(&key, &plan);
Self::extend_plan_ttl(&env, &key);
env.events()
    .publish((symbol_short!("ping"), owner), current_timestamp);

Feature 1 — Keeps Owner Authorization

The ping still requires the plan owner to authorize the call:

owner.require_auth();

This means unauthorized addresses cannot successfully ping another user’s inheritance plan.


Feature 2 — Updates last_ping Correctly

The function now captures the ledger timestamp once:

let current_timestamp = env.ledger().timestamp();

Then uses that exact value to update the plan:

plan.last_ping = current_timestamp;

This ensures the persisted last_ping matches the event timestamp exactly.


Feature 3 — Preserves Plan TTL Bump

The existing TTL extension behavior is preserved:

Self::extend_plan_ttl(&env, &key);

So each successful ping keeps the plan’s persistent storage entry alive.


Feature 4 — Emits Keep-Alive Event

The fix adds the missing contract event:

env.events()
    .publish((symbol_short!("ping"), owner), current_timestamp);

The emitted event contains:

Event Part Value
Topic 1 ping
Topic 2 plan owner address
Data updated last_ping timestamp

This allows off-chain services, indexers, monitoring tools, or frontend components to track proof-of-life activity.


Feature 5 — Added Regression Tests

I added tests in:

contracts/inheritance-contract/src/test.rs

The tests verify that:

  1. Calling ping updates last_ping.
  2. Calling ping emits the expected contract event.
  3. Calling ping without owner authorization is rejected.

Summary

The root issue was that the ping entrypoint did not emit a keep-alive event. The fix adds that event while preserving the existing authorization, timestamp update, and TTL bump behavior. This fully satisfies the issue acceptance criteria.

CLOSE #830

@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@Kappa16 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Kappa16

Kappa16 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

PLEASE REVIEW

@ONEONUORA ONEONUORA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @Kappa16
Thank you for your contribution

@ONEONUORA ONEONUORA merged commit 3ca4038 into Fracverse:master Jun 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Contracts] Implement Keep-Alive Ping Ledger Updates

2 participants