Labels / Complexity: enhancement, contracts · Medium — 4 pts
Problem
The SLAContractAdapter.get_runtime_metadata() method in app/services/contracts/sla_adapter.py returns settings.CONTRACT_EXECUTION_MODE which is read from the environment variable. However, the actual execution path in calculate_sla() always calls the local SLACalculator.calculate(), ignoring the execution mode. The adapter claims to support both "local" and "soroban" modes, but there is no integration with the actual Soroban contract.
Root cause
# app/services/contracts/sla_adapter.py:23-28
@staticmethod
def get_runtime_metadata() -> dict[str, str]:
return {
"contract_address": settings.SLA_CONTRACT_ADDRESS,
"network": settings.STELLAR_NETWORK,
"execution_mode": settings.CONTRACT_EXECUTION_MODE, # <-- Read but not used
}
Why this is architecturally hard
- The Soroban contract uses different data types (Symbol, Address, u32) than the local Python calculator; the translation layer (
translate_contract_result) exists but is not wired to a real Soroban client.
- The backend would need to manage a Soroban RPC connection and handle transaction submission, signing, and confirmation.
- The contract's
calculate_sla function requires an outage_id: Symbol and severity: Symbol, which must be validated and converted from Python strings.
Proposed design
- Add a
SorobanClient class in app/services/contracts/soroban_client.py that wraps the Stellar SDK
- In
SLAContractAdapter.calculate_sla(), check settings.CONTRACT_EXECUTION_MODE and dispatch to either local calculator or Soroban client
- The Soroban client handles transaction building, signing with the pool wallet key, and waiting for confirmation
Downstream impact
Requires coordination with apexchainx-contracts for the contract ABI and entry points. The contract must be deployed and the address configured in SLA_CONTRACT_ADDRESS.
Acceptance criteria
Out of scope
Deploying the contract; assume a deployed contract address is configured.
Getting started
Files in scope:
app/services/contracts/sla_adapter.py
app/services/contracts/soroban_client.py (new file)
app/core/config.py
Build/test commands:
pytest tests/test_contract_parity.py
Good first files to read: app/services/contracts/sla_adapter.py, app/services/contracts/translation.py, docs/STELLAR_INTEGRATION.md.
Labels / Complexity: enhancement, contracts · Medium — 4 pts
Problem
The
SLAContractAdapter.get_runtime_metadata()method inapp/services/contracts/sla_adapter.pyreturnssettings.CONTRACT_EXECUTION_MODEwhich is read from the environment variable. However, the actual execution path incalculate_sla()always calls the localSLACalculator.calculate(), ignoring the execution mode. The adapter claims to support both "local" and "soroban" modes, but there is no integration with the actual Soroban contract.Root cause
Why this is architecturally hard
translate_contract_result) exists but is not wired to a real Soroban client.calculate_slafunction requires anoutage_id: Symbolandseverity: Symbol, which must be validated and converted from Python strings.Proposed design
SorobanClientclass inapp/services/contracts/soroban_client.pythat wraps the Stellar SDKSLAContractAdapter.calculate_sla(), checksettings.CONTRACT_EXECUTION_MODEand dispatch to either local calculator or Soroban clientDownstream impact
Requires coordination with
apexchainx-contractsfor the contract ABI and entry points. The contract must be deployed and the address configured inSLA_CONTRACT_ADDRESS.Acceptance criteria
CONTRACT_EXECUTION_MODE=sorobanroutes SLA calculations to the Soroban contractOut of scope
Deploying the contract; assume a deployed contract address is configured.
Getting started
Files in scope:
app/services/contracts/sla_adapter.pyapp/services/contracts/soroban_client.py(new file)app/core/config.pyBuild/test commands:
Good first files to read:
app/services/contracts/sla_adapter.py,app/services/contracts/translation.py,docs/STELLAR_INTEGRATION.md.