IDotnsCostModelRegistry

Git Source

Title: DotNS Cost Model Registry

Holds every cost model the protocol has run and names the current one.

The address registered under DotnsConstants.COST_MODEL points here, set once and never repointed. Changing the live curve registers a new model, which adds its version and moves the current pointer. Prior models stay live and priceable by version, so a registration committed against an earlier curve settles at the amount it committed to.

Note: security-contact: admin@parity.io

Functions

register

Registers a model and makes it current.

Owner-only. Keys the model by its own version, so a version can be registered once; a repeat triggers @custom:reverts AlreadyRegistered. Moves the current pointer to the new version and emits @custom:emits CostModelRegistered.

function register(IDotnsPricing model) external;

Parameters

NameTypeDescription
modelIDotnsPricingThe cost model to register.

setCurrentVersion

Points the current version at an already-registered model.

Owner-only. Reverts to a previously registered version without redeploying it, so governance can roll fresh pricing back to an earlier curve. @custom:reverts UnknownVersion when no model is registered for version. Emits @custom:emits CurrentModelSet.

function setCurrentVersion(uint256 version) external;

Parameters

NameTypeDescription
versionuint256The already-registered version to make current.

modelOf

Returns the model registered for a version, or the zero address when none.

function modelOf(uint256 version) external view returns (IDotnsPricing model);

Parameters

NameTypeDescription
versionuint256The version to look up.

Returns

NameTypeDescription
modelIDotnsPricingThe model registered for that version.

currentVersion

Returns the version currently serving fresh pricing.

function currentVersion() external view returns (uint256 version);

Returns

NameTypeDescription
versionuint256The current version identifier.

current

Returns the current model.

function current() external view returns (IDotnsPricing model);

Returns

NameTypeDescription
modelIDotnsPricingThe model serving the current version.

priceForBaseLength

Prices a base length at the current version.

function priceForBaseLength(uint256 baseLength) external view returns (uint256 weiPrice);

Parameters

NameTypeDescription
baseLengthuint256Digit-stripped length of the label being priced.

Returns

NameTypeDescription
weiPriceuint256Registration cost in wei at the current version.

priceForBaseLengthAtVersion

Prices a base length at a specific version.

@custom:reverts UnknownVersion when no model is registered for version.

function priceForBaseLengthAtVersion(
    uint256 version,
    uint256 baseLength
)
    external
    view
    returns (uint256 weiPrice);

Parameters

NameTypeDescription
versionuint256The version to price against.
baseLengthuint256Digit-stripped length of the label being priced.

Returns

NameTypeDescription
weiPriceuint256Registration cost in wei at that version.

Events

CostModelRegistered

Emitted when a model is registered and becomes current.

event CostModelRegistered(uint256 indexed version, address indexed model);

Parameters

NameTypeDescription
versionuint256The model's version identifier.
modeladdressThe model address now serving that version.

CurrentModelSet

Emitted when the current version is pointed at an already-registered model.

event CurrentModelSet(uint256 indexed version);

Parameters

NameTypeDescription
versionuint256The version now serving fresh pricing.

Errors

AlreadyRegistered

Thrown when registering a model whose version is already held.

error AlreadyRegistered(uint256 version);

Parameters

NameTypeDescription
versionuint256The version already registered.

UnknownVersion

Thrown when pricing against a version that was never registered.

error UnknownVersion(uint256 version);

Parameters

NameTypeDescription
versionuint256The version with no registered model.

ZeroVersion

Thrown when registering a model whose version is zero, which is the sentinel for an unregistered version and so cannot name a real model.

error ZeroVersion();

PricingVersionMismatch

Thrown when a registration reveals at a different version than it committed to.

Raised where a commit-reveal flow binds a version at commit and checks it at reveal, so the version a name prices at cannot move after the commitment is made.

error PricingVersionMismatch(uint256 committed, uint256 revealed);

Parameters

NameTypeDescription
committeduint256The version bound when the commitment was made.
revealeduint256The version supplied at reveal.