hypercore-one / go-zenon

GNU General Public License v3.0
3 stars 0 forks source link

Allow hardcoded spork IDs and liquidity admin address to be configurable #2

Open georgezgeorgez opened 1 year ago

georgezgeorgez commented 1 year ago

Is your feature request related to a problem? Please describe. HyperCore.One is spinning up a testnet. While existing sporks can be specified in genesis config, we will not be able to create sporks with the same IDs as on mainnet. The initial liquidity admin address is also hardcoded, and we need to be able to configure it.

Describe the solution you'd like Allow the definition of constant overrides in config.json and make sporkIds and and initial liquidity admin address to look for those overrides before using the existing hardcoded values as defaults.

Describe alternatives you've considered We could have a custom binary for testnets with tesnet-specific code patches. But this seems inferior in all regards.

Additional context n/a

georgezgeorgez commented 1 year ago

I have an initial implementation at https://github.com/hypercore-one/go-zenon/tree/feature/configure-hardcoded It uses a simple map of strings to strings in config.json, and by setting predefined keys, you can override certain behavior the implementation doesn't scale well right now and might need some refactoring in the future

georgezgeorgez commented 1 year ago

cryptofish did a quick test on the bridge/liquidity admin override by calling the rpc on the info methods

for the spork id overrides: just did a test

created a new devnet without the htlc spork id in genesis created a spork called htlcs added the following to config.json Overrides: HtlcSpork:

activated the spork successful activation

created a new random spork and activated (with no implementation / override) and got failure the node shut itself down

this should mean that the spork overrides in working

georgezgeorgez commented 1 year ago

Long term I think I have a better solution in mind to put all constants into database state This would allow for migration scripts including an "init" migration script to seed the initial values

sol-znn commented 1 year ago

Great work, George! Here's an updated copy of the testnet config. config.testnet.json.txt