Skip to content

Conversation

@mkysel
Copy link
Collaborator

@mkysel mkysel commented Sep 26, 2025

Implement AppChain CLI management and refactor blockchain admins to update on-chain state from parameter registries, splitting parameter setting from update operations across app and settlement components

This change replaces setter-style admin methods with Update* operations that read pending values from parameter registries, introduces registry adapters and interfaces to support both AppChain and Settlement registries, and updates the CLI to manage parameters directly and trigger updates separately. It also adds raw parameter get/set and a bridge command for sending parameters from Settlement to App.

  • Refactor blockchain admins to use IParameterAdmin and IParameterRegistry, rename Set* to Update* without explicit values, and read state directly from contracts; adjust payload size getters to return uint32 in app_chain_admin.go and settlement_chain_admin.go
  • Add registry adapters and constructors for AppChain and Settlement parameter registries, plus raw parameter accessors in parameter_registry_admin.go and registry_adapters.go
  • Introduce CLI params subtree for raw parameter get/set and bridging, and convert existing app/settlement admin commands from set to update semantics in commands
  • Update configs and options to include appChainParameterRegistry and CLI flag/env for the AppChain Parameter Registry in blockchain.go, options.go, and validation.go
  • Update tests to write parameters via paramAdmin then call Update* methods, and adjust helpers to construct app/settlement-specific parameter admins across affected test files

📍Where to Start

Start with the admin API changes in IAppChainAdmin and ISettlementChainAdmin in app_chain_admin.go and settlement_chain_admin.go, then review registry abstraction in parameter_registry_admin.go and registry_adapters.go.


Macroscope summarized ee2c284.

@mkysel mkysel requested a review from a team as a code owner September 26, 2025 20:28
@graphite-app
Copy link

graphite-app bot commented Sep 26, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • Queue - adds this PR to the back of the merge queue
  • Hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

if err != nil {
logger.Error("could not setup parameter admin", zap.Error(err))
return err
}
Copy link

Choose a reason for hiding this comment

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

If all provided --key values are empty or whitespace, the command exits successfully without any output, which is confusing and masks invalid input.

The loop skips over empty keys due to the continue on trimmed empty strings, and there’s no check after the loop to ensure at least one valid key was processed.

Consider tracking the number of successfully processed keys and returning an error if none were valid, so users get clear feedback when their input contains only empty or whitespace keys.

+    processed := 0
     for _, k := range opts.Keys {
         k = strings.TrimSpace(k)
         if k == "" {
             continue
         }

+        processed++
+        val, gerr := paramAdmin.GetRawParameter(ctx, k)
         if gerr != nil {
             logger.Error("get parameter failed", zap.String("key", k), zap.Error(gerr))
             return gerr
         }
         logger.Info("parameter",
             zap.String("key", k),
             zap.String("bytes32", "0x"+common.Bytes2Hex(val[:])),
         )
     }

+    if processed == 0 {
+        return fmt.Errorf("no valid --key values provided")
+    }

🚀 Reply to ask Macroscope to explain or update this suggestion.

👍 Helpful? React to give us feedback.

client *ethclient.Client,
signer TransactionSigner,
contractsOptions config.ContractsOptions,
) (IParameterAdmin, error) {
Copy link

Choose a reason for hiding this comment

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

If ParameterRegistryAddress is empty or not a valid hex address, the zero address is used and subsequent parameter registry calls will fail at runtime.

This happens because NewAppChainParameterAdmin passes contractsOptions.AppChain.ParameterRegistryAddress directly into common.HexToAddress without any checks.

Consider validating that contractsOptions.AppChain.ParameterRegistryAddress is non-empty (and optionally a valid hex address via common.IsHexAddress) before calling NewAppChainRegistryAdapter, returning a descriptive error if validation fails.

+    if contractsOptions.AppChain.ParameterRegistryAddress == "" {
+        return nil, fmt.Errorf("app chain parameter registry address is required")
+    }

🚀 Reply to ask Macroscope to explain or update this suggestion.

👍 Helpful? React to give us feedback.

@mkysel mkysel merged commit 5a9ea9b into main Sep 29, 2025
11 checks passed
@mkysel mkysel deleted the mkysel/app-correct branch September 29, 2025 14:18
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.

3 participants