diff --git a/config/gasSchedule.go b/config/gasSchedule.go index 5d4c19a9f..63eff451d 100644 --- a/config/gasSchedule.go +++ b/config/gasSchedule.go @@ -91,7 +91,7 @@ func checkForZeroUint64Fields(arg interface{}) error { v := reflect.ValueOf(arg) for i := 0; i < v.NumField(); i++ { field := v.Field(i) - if field.Kind() != reflect.Uint64 { + if field.Kind() != reflect.Uint64 && field.Kind() != reflect.Uint32 { continue } if field.Uint() == 0 { diff --git a/config/gasSchedule_test.go b/config/gasSchedule_test.go index c323254f1..23f835e6a 100644 --- a/config/gasSchedule_test.go +++ b/config/gasSchedule_test.go @@ -55,3 +55,23 @@ func TestDecode_ArwenGas(t *testing.T) { fmt.Printf("%+v\n", ethOp) } + +func TestDecode_ZeroGasCostError(t *testing.T) { + gasMap := make(map[string]uint64) + gasMap = FillGasMapWithWASMOpcodeValues(gasMap, 1) + + wasmCosts := &WASMOpcodeCost{} + err := mapstructure.Decode(gasMap, wasmCosts) + assert.Nil(t, err) + + err = checkForZeroUint64Fields(*wasmCosts) + assert.Nil(t, err) + + gasMap["BrIf"] = 0 + wasmCosts = &WASMOpcodeCost{} + err = mapstructure.Decode(gasMap, wasmCosts) + assert.Nil(t, err) + + err = checkForZeroUint64Fields(*wasmCosts) + assert.Error(t, err) +}