From 336a2dab566af5bc123819227beff28b2ddea646 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 24 Jul 2025 12:51:20 +0200 Subject: [PATCH] params: fix param value decoding --- params/config2.go | 8 ++++++-- params/registry.go | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/params/config2.go b/params/config2.go index f53438d032..bf38396ecf 100644 --- a/params/config2.go +++ b/params/config2.go @@ -23,6 +23,7 @@ import ( "fmt" "maps" "math/big" + "reflect" "slices" "strconv" "strings" @@ -171,7 +172,10 @@ func (cfg *Config2) UnmarshalJSON(input []byte) error { return fmt.Errorf("expected JSON object for chain configuration") } // Now we're in the object. - newcfg := Config2{activation: Activations{}} + newcfg := Config2{ + activation: make(Activations), + param: make(map[int]any), + } for { tok, err = dec.Token() if tok == json.Delim('}') { @@ -227,7 +231,7 @@ func (cfg *Config2) decodeParameter(key string, dec *json.Decoder) error { if err := dec.Decode(v); err != nil { return err } - cfg.param[id] = v + cfg.param[id] = reflect.ValueOf(v).Elem().Interface() return nil } diff --git a/params/registry.go b/params/registry.go index c1203246fd..074a198c99 100644 --- a/params/registry.go +++ b/params/registry.go @@ -101,8 +101,7 @@ func Define[V any](def T[V]) Parameter[V] { optional: def.Optional, defaultValue: def.Default, new: func() any { - var z V - return z + return new(V) }, validate: func(v any, cfg *Config2) error { if def.Validate == nil {