diff --git a/beacon-chain/rpc/eth/config/BUILD.bazel b/beacon-chain/rpc/eth/config/BUILD.bazel index 293cfb79b3..7c9dabf108 100644 --- a/beacon-chain/rpc/eth/config/BUILD.bazel +++ b/beacon-chain/rpc/eth/config/BUILD.bazel @@ -27,5 +27,7 @@ go_test( "//testing/require:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", + "@com_github_sirupsen_logrus//:go_default_library", + "@com_github_sirupsen_logrus//hooks/test:go_default_library", ], ) diff --git a/beacon-chain/rpc/eth/config/handlers.go b/beacon-chain/rpc/eth/config/handlers.go index c34966ef80..56f1f44fa6 100644 --- a/beacon-chain/rpc/eth/config/handlers.go +++ b/beacon-chain/rpc/eth/config/handlers.go @@ -132,6 +132,10 @@ func convertValueForJSON(v reflect.Value, tag string) interface{} { } return m + // ===== String ===== + case reflect.String: + return v.String() + // ===== Default ===== default: log.WithFields(log.Fields{ diff --git a/beacon-chain/rpc/eth/config/handlers_test.go b/beacon-chain/rpc/eth/config/handlers_test.go index 55cdf51e34..6f0d2664cb 100644 --- a/beacon-chain/rpc/eth/config/handlers_test.go +++ b/beacon-chain/rpc/eth/config/handlers_test.go @@ -8,6 +8,7 @@ import ( "math" "net/http" "net/http/httptest" + "reflect" "testing" "github.com/OffchainLabs/prysm/v6/api/server/structs" @@ -17,6 +18,8 @@ import ( "github.com/OffchainLabs/prysm/v6/testing/require" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + log "github.com/sirupsen/logrus" + logTest "github.com/sirupsen/logrus/hooks/test" ) func TestGetDepositContract(t *testing.T) { @@ -715,3 +718,35 @@ func TestGetSpec_BlobSchedule_NotFulu(t *testing.T) { _, exists := data["BLOB_SCHEDULE"] require.Equal(t, false, exists) } + +func TestConvertValueForJSON_NoErrorLogsForStrings(t *testing.T) { + logHook := logTest.NewLocal(log.StandardLogger()) + defer logHook.Reset() + + stringTestCases := []struct { + tag string + value string + }{ + {"CONFIG_NAME", "mainnet"}, + {"PRESET_BASE", "mainnet"}, + {"DEPOSIT_CONTRACT_ADDRESS", "0x00000000219ab540356cBB839Cbe05303d7705Fa"}, + {"TERMINAL_TOTAL_DIFFICULTY", "58750000000000000000000"}, + } + + for _, tc := range stringTestCases { + t.Run(tc.tag, func(t *testing.T) { + logHook.Reset() + + // Convert the string value + v := reflect.ValueOf(tc.value) + result := convertValueForJSON(v, tc.tag) + + // Verify the result is correct + require.Equal(t, tc.value, result) + + // Verify NO error was logged about unsupported field kind + require.LogsDoNotContain(t, logHook, "Unsupported config field kind") + require.LogsDoNotContain(t, logHook, "kind=string") + }) + } +} diff --git a/changelog/james-prysm_fix-config-parsing.md b/changelog/james-prysm_fix-config-parsing.md new file mode 100644 index 0000000000..c5556b7723 --- /dev/null +++ b/changelog/james-prysm_fix-config-parsing.md @@ -0,0 +1,3 @@ +### Fixed + +- Fixing Unsupported config field kind; value forwarded verbatim errors for type string. \ No newline at end of file