Skip to content

[TECHDEBT] Update usages of PersistenceRWContext gov parameter accessors to use the more general GetParameter() function #436

@h5law

Description

@h5law

Objective

Update the different instances across Persistence and Utility, and anywhere else the PersistenceRWContext interface is used, to use the general GetParameter(paramName string, height int64) (any, error) function to access gov parameters.

This will include replacing the usages of GetStringParam(), GetIntParam() and GetBytesParam() and replacing them all with GetParameter() where this is appropriate. This is with the aim of reducing the code footprint across the modules affected.

Another part of this issue involves updating the logic of GetParameter() to automatically distinguish between string and []bytes types given the paramName string. This must be done in a way that does not restrict the project from expanding the parameters without breaking the logic of this function.

Origin Document

Since the merge of PR#422 the new generalised getter function GetParameter() has been implemented and has deprecated GetBlocksPerSession() and GetServiceNodesPerSessionAt(). However, all the other parameter accessor functions are not using this new generalised function yet.

Goals

  • Replace all gov parameter accessor functions using GetStringParam(), GetIntParam() or GetBytesParam() to use GetParameter()
  • Update unit tests in persistence/test/gov_test.go and utility/test/gov_test.go to use the GetParameter() function
  • Solve the issue around when to call the []bytes variation of GetParameter() depending on the parameter name string

Deliverable

  • Update gov parameter accessors to use the GetParameter() function
  • Update unit tests in persistence/test/gov_test.go and utility/test/gov_test.go to use the GetParameter() function where appropriate
  • Update the logic of GetParameter() to detect []byte types and distinguish them from string types automatically

Non-goals / Non-deliverables

  • Restrict the expansion of the gov parameters by adding specific type detection rules to GetParameter() that would inhibit parameter additions that don't follow the current patterns.

General issue deliverables

  • Update the appropriate CHANGELOG(s)
  • Update any relevant local/global README(s)
  • Update relevant source code tree explanations
  • Add or update any relevant or supporting mermaid diagrams

Testing Methodology

  • Task specific tests or benchmarks: make ...
  • New tests or benchmarks: make ...
  • All tests: make test_all
  • LocalNet: verify a LocalNet is still functioning correctly by following the instructions at docs/development/README.md

Creator: @h5law

Metadata

Metadata

Assignees

Labels

code healthNice to have code improvementpersistencePersistence specific changes

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions