Skip to content

feat: transfer ownership best-effort datastore lookup#2194

Open
chris-de-leon-cll wants to merge 7 commits into
mainfrom
feat/transfer-ownership-best-effort-ds-lookup
Open

feat: transfer ownership best-effort datastore lookup#2194
chris-de-leon-cll wants to merge 7 commits into
mainfrom
feat/transfer-ownership-best-effort-ds-lookup

Conversation

@chris-de-leon-cll

@chris-de-leon-cll chris-de-leon-cll commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Reduce datastore lookups in TransferOwnership / AcceptOwnership

Background

TransferOwnershipChangeset and AcceptOwnershipChangeset accept a list of ContractRef entries per chain. Before executing the ownership sequence, each ref was passed through FindAndFormatRef — a datastore lookup that resolves a partial ref into a fully-populated AddressRef (with Type, Version, and Qualifier filled in from stored metadata). This was a hard failure: if the ref was not present in the datastore, the changeset would error out even when the caller had already supplied the contract address directly.

The only field the downstream ownership sequence actually needs from a ref is Address. ContractType is used in a single log line to identify the contract being operated on; Version and Qualifier are not consumed at all.

What this PR does

The FindAndFormatRef call is demoted from required to best-effort when Address is already set on the ref. The datastore is still consulted first — a hit produces a richer ref that improves log output. A miss emits a warning and the caller-supplied ref is passed through unchanged; the ownership transfer proceeds either way. When Address is not set, the datastore lookup remains mandatory and returns a hard error on failure, preserving the original behavior for callers that rely on the DS to resolve partial refs.

Design choices

DS as cache, not gatekeeper (when address is known). The datastore enrichment is purely additive here — it provides Type for a log message, nothing more. Making a successful log line a precondition for an on-chain ownership transfer is a stronger requirement than the operation actually needs. The revised behavior matches how ResolveTokenPoolRef treats the datastore throughout the rest of the codebase: try it, fall back gracefully on a miss.

Hard-fail preserved for address-less refs. If a caller provides a ref with no Address, the DS lookup must succeed — silently proceeding with an empty address would pass Address="" into the ownership sequence and produce a confusing failure downstream. The Address != "" guard makes the two code paths explicit.

Backwards compatible. No interface changes. Callers that already populate full refs (DS hit path) see identical behavior. Callers that pass type/version-only refs (DS must resolve path) see identical behavior. Only callers that provide an address but whose ref is absent from the DS see a change: hard error → warn and proceed.

Normalization is still required. TryNormalizeAddressRef runs unconditionally before the DS attempt, so address formatting (e.g. EVM checksumming) is always applied regardless of whether the DS lookup succeeds.

Copilot AI 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.

Pull request overview

This PR changes ownership-transfer changesets to treat datastore contract-ref enrichment (FindAndFormatRef) as best-effort, allowing the ownership sequences to proceed when callers provide an address-only datastore.AddressRef that is not present in the datastore.

Changes:

  • In acceptOwnershipApply, normalize refs, attempt datastore enrichment, and fall back to the caller-provided ref on lookup failure.
  • In transferOwnershipApply, apply the same best-effort enrichment behavior for contract refs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread deployment/deploy/transfer_ownership.go Outdated
Comment thread deployment/deploy/transfer_ownership.go Outdated
Comment thread deployment/deploy/transfer_ownership.go Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread deployment/deploy/transfer_ownership.go Outdated
Comment thread deployment/deploy/transfer_ownership.go Outdated
Comment thread chains/evm/deployment/v1_0_0/adapters/transfer_ownership_test.go
Comment thread chains/evm/deployment/v1_0_0/adapters/transfer_ownership_test.go

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread deployment/deploy/transfer_ownership.go Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread chains/evm/deployment/v1_0_0/adapters/transfer_ownership_test.go
Comment thread chains/evm/deployment/v1_0_0/adapters/transfer_ownership_test.go
Comment thread chains/evm/deployment/v1_0_0/adapters/transfer_ownership_test.go Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@github-actions

Copy link
Copy Markdown
Metric feat/transfer-ownership-best-effort-ds-lookup main
Coverage 69.7% 69.5%

@chris-de-leon-cll chris-de-leon-cll marked this pull request as ready for review July 15, 2026 20:06
@chris-de-leon-cll chris-de-leon-cll requested review from a team as code owners July 15, 2026 20:06
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.

2 participants