Skip to content

[BUG] Oracle Module ConsensusVersion Constant Not Used #256

@catsmile100

Description

@catsmile100

Found inconsistency in the oracle module. The ConsensusVersion constant is defined as 1 but the ConsensusVersion() function returns hardcoded 6.

What's broken?

  • x/oracle/module.go line 31: const ConsensusVersion = 1
  • x/oracle/module.go line 168: func (AppModule) ConsensusVersion() uint64 { return 6 }

Which module?

  • Oracle module (x/oracle)

Why is this a bug?

  • Constant is defined but never used
  • Function returns hardcoded value instead of using constant
  • Other modules in same repo use the constant correctly
  • Makes code maintenance harder and error-prone

Steps to Reproduce

  1. Open x/oracle/module.go
  2. Line 31: const ConsensusVersion = 1
  3. Line 168: func (AppModule) ConsensusVersion() uint64 { return 6 }
  4. Compare with other modules:
    • x/tokenfactory/module.go line 175-176: uses return ConsensusVersion
    • x/rewards/module.go line 174-175: uses return ConsensusVersion
    • x/feeabstraction/module.go line 172: uses return ConsensusVersion

Expected Behavior

Should use the constant like other modules:

// Line 31
const ConsensusVersion = 6

// Line 168
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }

Actual Behavior

Constant defined but not used:

// Line 31
const ConsensusVersion = 1  // UNUSED!

// Line 168
func (AppModule) ConsensusVersion() uint64 { return 6 }  // HARDCODED!

Environment

  • Kiichain version/commit: main branch
  • Network: All networks affected
  • File: x/oracle/module.go lines 31 and 168

Impact Assessment

Code quality issue:

  • Inconsistent with other modules in same codebase
  • Unused constant is confusing for developers
  • Hardcoded value makes version tracking harder
  • Could lead to bugs during future upgrades if developer updates constant but not function

Impact is LOW but this is a code quality/maintainability issue that should be fixed.


Test Case

package oracle_test

import (
	"testing"
	"github.com/stretchr/testify/require"
)

func TestConsensusVersionInconsistency(t *testing.T) {
	// From x/oracle/module.go
	const ConsensusVersion = 1           // Line 31
	functionReturn := uint64(6)          // Line 168 returns 6
	
	// Bug: constant != function return value
	require.NotEqual(t, uint64(ConsensusVersion), functionReturn, 
		"BUG: ConsensusVersion constant (1) != function return (6)")
	
	t.Logf("BUG CONFIRMED: const ConsensusVersion = %d but function returns %d", 
		ConsensusVersion, functionReturn)
}

Test Output:

=== RUN   TestConsensusVersionInconsistency
    module_test.go:15: BUG CONFIRMED: const ConsensusVersion = 1 but function returns 6
--- PASS: TestConsensusVersionInconsistency (0.00s)
PASS

Suggested Fix

// Line 31 - Update constant to correct value
const ConsensusVersion = 6

// Line 168 - Use the constant
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }

Reporter Declaration

By submitting this issue, I confirm that:

  • This report is NOT generated by AI
  • I personally tested and verified this issue
  • I understand that false or low-effort reports are disqualified from rewards

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions