netmap

package
v0.0.0-...-4f3c08f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2023 License: GPL-3.0 Imports: 10 Imported by: 2

Documentation

Overview

Netmap contract is a contract deployed in FrostFS sidechain.

Netmap contract stores and manages FrostFS network map, Storage node candidates and epoch number counter. In notary disabled environment, contract also stores a list of Inner Ring node keys.

Contract notifications

AddPeer notification. This notification is produced when a Storage node sends a bootstrap request by invoking AddPeer method.

AddPeer
  - name: nodeInfo
    type: ByteArray

UpdateState notification. This notification is produced when a Storage node wants to change its state (go offline) by invoking UpdateState method. Supported states: (2) -- offline.

UpdateState
  - name: state
    type: Integer
  - name: publicKey
    type: PublicKey

NewEpoch notification. This notification is produced when a new epoch is applied in the network by invoking NewEpoch method.

NewEpoch
  - name: epoch
    type: Integer

Index

Constants

View Source
const (

	// DefaultSnapshotCount contains the number of previous snapshots stored by this contract.
	// Must be less than 255.
	DefaultSnapshotCount = 10
)

Variables

This section is empty.

Functions

func AddPeer

func AddPeer(nodeInfo []byte)

AddPeer accepts information about the network map candidate in the FrostFS binary protocol format, identifies the caller and behaves depending on different conditions listed below.

Contract settings:

(1) notary-enabled
(2) notary-disabled

Callers:

(a) candidate himself, if node's public key corresponds to the signer
(b) Alphabet member
(c) others

AddPeer case-by-case behavior:

(1a) does nothing
(1b) panics. Notice that AddPeerIR MUST be used for this purpose.
(2a) throws AddPeer notification with the provided BLOB
(2b) accepts Alphabet vote. If the threshold of votes is reached, adds
new element to the candidate set, and throws AddPeerSuccess notification.
(c) panics

Candidate MUST call AddPeer with "online" state in its descriptor. Alphabet members MUST NOT call AddPeer with any other states.

func AddPeerIR

func AddPeerIR(nodeInfo []byte)

AddPeerIR accepts Alphabet calls in the notary-enabled contract setting and behaves similar to AddPeer in the notary-disabled one.

AddPeerIR MUST NOT be called in notary-disabled contract setting. AddPeerIR MUST be called by the Alphabet member only.

func Config

func Config(key []byte) interface{}

Config returns configuration value of FrostFS configuration. If key does not exists, returns nil.

func Epoch

func Epoch() int

Epoch method returns the current epoch number.

func InnerRingList

func InnerRingList() []common.IRNode

InnerRingList method returns a slice of structures that contains the public key of an Inner Ring node. It should be used in notary disabled environment only.

If notary is enabled, look to NeoFSAlphabet role in native RoleManagement contract of the sidechain.

func LastEpochBlock

func LastEpochBlock() int

LastEpochBlock method returns the block number when the current epoch was applied.

func ListConfig

func ListConfig() []record

ListConfig returns an array of structures that contain key and value of all FrostFS configuration records. Key and value are both byte arrays.

func NewEpoch

func NewEpoch(epochNum int)

NewEpoch method changes the epoch number up to the provided epochNum argument. It can be invoked only by Alphabet nodes. If provided epoch number is less than the current epoch number or equals it, the method throws panic.

When epoch number is updated, the contract sets storage node candidates as the current network map. The contract also invokes NewEpoch method on Balance and Container contracts.

It produces NewEpoch notification.

func SetConfig

func SetConfig(id, key, val []byte)

SetConfig key-value pair as a FrostFS runtime configuration value. It can be invoked only by Alphabet nodes.

func Update

func Update(script []byte, manifest []byte, data interface{})

Update method updates contract source code and manifest. It can be invoked only by committee.

func UpdateInnerRing

func UpdateInnerRing(keys []interop.PublicKey)

UpdateInnerRing method updates a list of Inner Ring node keys. It should be used only in notary disabled environment. It can be invoked only by Alphabet nodes.

If notary is enabled, update NeoFSAlphabet role in native RoleManagement contract of the sidechain. Use notary service to collect multisignature.

func UpdateSnapshotCount

func UpdateSnapshotCount(count int)

UpdateSnapshotCount updates the number of the stored snapshots. If a new number is less than the old one, old snapshots are removed. Otherwise, history is extended with empty snapshots, so `Snapshot` method can return invalid results for `diff = new-old` epochs until `diff` epochs have passed.

Count MUST NOT be negative.

func UpdateState

func UpdateState(state NodeState, publicKey interop.PublicKey)

UpdateState accepts new state to be assigned to network map candidate identified by the given public key, identifies the signer and behaves depending on different conditions listed below.

Contract settings:

(1) notary-enabled
(2) notary-disabled

Signers:

(a) candidate himself only, if provided public key corresponds to the signer
(b) Alphabet member only
(ab) both candidate and Alphabet member
(c) others

UpdateState case-by-case behavior:

(1a) panics
(1b) like (1a)
(1ab) updates candidate's state in the contract storage (*), and throws
UpdateStateSuccess with the provided key and new state
(2a) throws UpdateState notification with the provided key and new state
(2b) accepts Alphabet vote. If the threshold of votes is reached, behaves
like (1ab).
(c) panics

(*) Candidate is removed from the candidate set if state is NodeStateOffline. Any other state is written into candidate's descriptor in the contract storage. If requested candidate is missing, panic occurs. Throws UpdateStateSuccess notification on success.

State MUST be from the NodeState enum. Public key MUST be interop.PublicKeyCompressedLen bytes.

func UpdateStateIR

func UpdateStateIR(state NodeState, publicKey interop.PublicKey)

UpdateStateIR accepts Alphabet calls in the notary-enabled contract setting and behaves similar to UpdateState, but does not require candidate's signature presence.

UpdateStateIR MUST NOT be called in notary-disabled contract setting. UpdateStateIR MUST be called by the Alphabet member only.

func Version

func Version() int

Version returns the version of the contract.

Types

type Node

type Node struct {
	// Information about the node encoded according to the FrostFS binary
	// protocol.
	BLOB []byte

	// Current node state.
	State NodeState
}

Node groups data related to FrostFS storage nodes registered in the FrostFS network. The information is stored in the current contract.

func Netmap

func Netmap() []Node

Netmap returns set of information about the storage nodes representing a network map in the current epoch.

Current state of each node is represented in the State field. It MAY differ with the state encoded into BLOB field, in this case binary encoded state MUST NOT be processed.

func NetmapCandidates

func NetmapCandidates() []Node

NetmapCandidates returns set of information about the storage nodes representing candidates for the network map in the coming epoch.

Current state of each node is represented in the State field. It MAY differ with the state encoded into BLOB field, in this case binary encoded state MUST NOT be processed.

func Snapshot

func Snapshot(diff int) []Node

Snapshot returns set of information about the storage nodes representing a network map in (current-diff)-th epoch.

Diff MUST NOT be negative. Diff MUST be less than maximum number of network map snapshots stored in the contract. The limit is a contract setting, DefaultSnapshotCount by default. See UpdateSnapshotCount for details.

Current state of each node is represented in the State field. It MAY differ with the state encoded into BLOB field, in this case binary encoded state MUST NOT be processed.

func SnapshotByEpoch

func SnapshotByEpoch(epoch int) []Node

SnapshotByEpoch returns set of information about the storage nodes representing a network map in the given epoch.

Behaves like Snapshot: it is called after difference with the current epoch is calculated.

type NodeState

type NodeState int

NodeState is an enumeration for node states.

const (

	// NodeStateOnline stands for nodes that are in full network and
	// operational availability.
	NodeStateOnline NodeState

	// NodeStateOffline stands for nodes that are in network unavailability.
	NodeStateOffline

	// NodeStateMaintenance stands for nodes under maintenance with partial
	// network availability.
	NodeStateMaintenance
)

Various Node states

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL