DotnsCostModelRegistry
Inherits: IDotnsCostModelRegistry
Title: dotNS Cost Model Registry
Keeps every registered cost model addressable by version and tracks the current one.
Holds only pointers, so it is not upgradeable. PopRules resolves it through
DotnsConstants.COST_MODEL and prices the current version for fresh reads and a specific
version for in-flight registrations. Governed by Root, or by the bootstrap owner of its
protocol registry while one is set, with the same rules as
Notes:
-
contract: ProtocolOwnedUpgradeable: it keeps no owner of its own, and
msg.senderis read only when the caller is not Root. -
security-contact: admin@parity.io
Constants
protocolRegistry
The protocol registry that holds the bootstrap owner.
IDotnsProtocolRegistry public immutable protocolRegistry
State Variables
modelOf
mapping(uint256 version => IDotnsPricing model) public override modelOf
currentVersion
Returns the version currently serving fresh pricing.
uint256 public override currentVersion
Functions
onlyRootOrOwner
Restricts a call to Root, or to the bootstrap owner while one is set.
modifier onlyRootOrOwner() ;
constructor
Binds the registry to the protocol registry that holds its bootstrap owner.
constructor(IDotnsProtocolRegistry registry) ;
Parameters
| Name | Type | Description |
|---|---|---|
registry | IDotnsProtocolRegistry | Protocol registry of this deployment. |
owner
Returns the bootstrap owner, read from the protocol registry.
function owner() public view returns (address owner_);
Returns
| Name | Type | Description |
|---|---|---|
owner_ | address | The protocol registry's owner, or zero once it is renounced. |
register
Registers a model and makes it current.
Root or the bootstrap owner. 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 override onlyRootOrOwner;
Parameters
| Name | Type | Description |
|---|---|---|
model | IDotnsPricing | The cost model to register. |
setCurrentVersion
Points the current version at an already-registered model.
Root or the bootstrap owner. Reverts to a previously registered version without redeploying it, so governance can roll fresh pricing back to an earlier curve.
Notes:
-
reverts: UnknownVersion when no model is registered for
version. Emits -
emits: CurrentModelSet.
function setCurrentVersion(uint256 version) external override onlyRootOrOwner;
Parameters
| Name | Type | Description |
|---|---|---|
version | uint256 | The already-registered version to make current. |
current
Returns the current model.
function current() external view override returns (IDotnsPricing model);
Returns
| Name | Type | Description |
|---|---|---|
model | IDotnsPricing | The model serving the current version. |
priceForBaseLength
Prices a base length at the current version.
function priceForBaseLength(uint256 baseLength)
external
view
override
returns (uint256 weiPrice);
Parameters
| Name | Type | Description |
|---|---|---|
baseLength | uint256 | Base length of the label being priced: its length as written, less a device name's suffix. |
Returns
| Name | Type | Description |
|---|---|---|
weiPrice | uint256 | Registration 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
override
returns (uint256 weiPrice);
Parameters
| Name | Type | Description |
|---|---|---|
version | uint256 | The version to price against. |
baseLength | uint256 | Base length of the label being priced: its length as written, less a device name's suffix. |
Returns
| Name | Type | Description |
|---|---|---|
weiPrice | uint256 | Registration cost in wei at that version. |
Errors
OwnableUnauthorizedAccount
Thrown when the caller is neither Root nor the bootstrap owner.
error OwnableUnauthorizedAccount(address account);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The caller. |
ZeroProtocolRegistry
Thrown by the constructor for a zero protocol registry.
error ZeroProtocolRegistry();