Skip to content

Add time-based expiration for tfchain account public keys #2686

Description

@sameh-farouk

Currently ZOS caches tfchain account public keys in two places that could hold stale keys indefinitely making issues with the twin transfer fetaure that replace the twin public key.

Failed to deploy the deployment on node 179. Failed to send request to twinId 6304 with command: zos.deployment.deploy, payload: {"version":0,"metadata":"{\"version\":3,\"type\":\"network\",\"name\":\"nwpnw1v\",\"projectName\":\"fullvm/vmz20n4\"}","description":"","twin_id":21336,"expiration":0,"workloads":[{"version":0,"name":"nwpnw1v","type":"network","data":{"__type":"network","subnet":"10.20.2.0/24","ip_range":"10.20.0.0/16","wireguard_private_key":"5K0yGLda3pvr74s5gpXh+ymGlGYymPtIk27kECp+7qU=","wireguard_listen_port":15091,"node_id":179,"mycelium":{"hex_key":"526207a79dcc26644e3e91721cfe9dee2e2513aa2332715e1102751a8a68caf2","peers":[]},"peers":[]},"metadata":"{\"version\":3,\"user_accesses\":[]}","description":""}],"signature_requirement":{"requests":[{"twin_id":21336,"weight":1,"required":false}],"signatures":[{"twin_id":21336,"signature":"6eace1105e2a8cb80bdf9e80d5acc7ff595b31dbca08b2887f1824110319ba63a3ee5e588f9961381c808ea1456c89b7144c58a7b05b6d626a402d3974f0ed87","signature_type":"sr25519"}],"weight_required":1},"contract_id":263989} 0 failed to verify signature

deployment.Verify() in provisiond uses the SubstrateTwins LRU cache which never expires so new deployments/updates would fail signature verification until provisiond restarts.

if admin, admin ops like rmb call zos/admin/set_public_nic and zos/admin/interfaces will fail until provisiond restarts.

we should either switch to a cache library that supports TTL (e.g. patrickmn/go-cache, or hashicorp/golang-lru/v2/expirable), re maybe the simplest approach would be to follow the same pattern already used in the RMB peer's inMemoryCache store a Timestamp alongside the pk and check expiry on read.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions