Skip to content

Add emission functions & fixes to alpha precompile (0x...0808) #1824

@taomind007

Description

@taomind007

Is your feature request related to a problem? Please describe.

I would like to request the addition of the following functions to the alpha precompile (0x0...0808), as both tao_in_emission and alpha_in_emission are critical variables for working with the subnet pool:

  • getTaoInEmission(uint16 netuid)
  • getAlphaInEmission(uint16 netuid)
  • getAlphaOutEmission(unit16 netuid)

Describe the solution you'd like

precompiles/src/solidity/alpha.sol

/// @dev Returns the amount of tao emission into the pool per block for a subnet.
/// @param netuid The subnet identifier.
/// @return The tao-in emission per block.
function getTaoInEmission(uint16 netuid) external view returns (uint256);

/// @dev Returns the amount of alpha emission into the pool per block for a subnet.
/// @param netuid The subnet identifier.
/// @return The alpha-in emission per block.
function getAlphaInEmission(uint16 netuid) external view returns (uint256);

/// @dev Returns the amount of alpha emission outside the pool per block for a subnet.
/// @param netuid The subnet identifier.
/// @return The alpha-out emission per block.
function getAlphaOutEmission(uint16 netuid) external view returns (uint256);

precompiles/src/alpha.rs

#[precompile::public("getTaoInEmission(uint16)")]
#[precompile::view]
fn get_tao_in_emission(_handle: &mut impl PrecompileHandle, netuid: u16) -> EvmResult<u256> {
    Ok(pallet_subtensor::SubnetTaoInEmission::<R>::get(NetUid::from(netuid)))
}

#[precompile::public("getAlphaInEmission(uint16)")]
#[precompile::view]
fn get_alpha_in_emission(_handle: &mut impl PrecompileHandle, netuid: u16) -> EvmResult<u256> {
    Ok(pallet_subtensor::SubnetAlphaInEmission::<R>::get(NetUid::from(netuid)))
}

#[precompile::public("getAlphaOutEmission(uint16)")]
#[precompile::view]
fn get_alpha_out_emission(_handle: &mut impl PrecompileHandle, netuid: u16) -> EvmResult<u256> {
    Ok(pallet_subtensor::SubnetAlphaOutEmission::<R>::get(NetUid::from(netuid)))
}

Describe alternatives you've considered

No response

Additional context

Additionally, I have noticed a few unrelated issues with the current alpha precompile:

  • Some functions (e.g., getAlphaPrice, getMovingAlphaPrice) fetch values directly from the chain without additional processing, so small fractional values (e.g., alpha prices) are returned as zero (uint256).
  • The precompile seems to be deployed only on testnet; calls on mainnet do not work.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions