netmap

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Netmap contract is a contract deployed in NeoFS sidechain.

Netmap contract stores and manages NeoFS 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 (
	OnlineState nodeState
	OfflineState
)
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 method adds a new candidate to the next network map if it was invoked by Alphabet node. If it was invoked by a node candidate, it produces AddPeer notification. Otherwise, the method throws panic.

If the candidate already exists, its info is updated. NodeInfo argument contains a stable marshaled version of netmap.NodeInfo structure.

func AddPeerIR added in v0.15.0

func AddPeerIR(nodeInfo []byte)

AddPeerIR method tries to add a new candidate to the network map. It should only be invoked in notary-enabled environment by the alphabet.

func Config

func Config(key []byte) interface{}

Config returns configuration value of NeoFS 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 added in v0.10.0

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 NeoFS configuration records. Key and value are both byte arrays.

func Netmap

func Netmap() []storageNode

Netmap method returns a list of structures that contain a byte array of a stable marshalled netmap.NodeInfo structure. These structures contain Storage nodes of the current epoch.

func NetmapCandidates added in v0.9.0

func NetmapCandidates() []netmapNode

NetmapCandidates method returns a list of structures that contain the node state and a byte array of a stable marshalled netmap.NodeInfo structure. These structures contain Storage node candidates for the next epoch.

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 NeoFS runtime configuration value. It can be invoked only by Alphabet nodes.

func Snapshot

func Snapshot(diff int) []storageNode

Snapshot method returns a list of structures that contain the node state (online: 1) and a byte array of a stable marshalled netmap.NodeInfo structure. These structures contain Storage nodes of the specified epoch.

Netmap contract contains only two recent network map snapshots: current and previous epoch. For diff bigger than 1 or less than 0, the method throws panic.

func SnapshotByEpoch added in v0.3.1

func SnapshotByEpoch(epoch int) []storageNode

SnapshotByEpoch method returns a list of structures that contain the node state (online: 1) and a byte array of a stable marshalled netmap.NodeInfo structure. These structures contain Storage nodes of the specified epoch.

Netmap contract contains only two recent network map snapshot: current and previous epoch. For all others epoch method throws panic.

func Update added in v0.11.0

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 added in v0.15.1

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.

func UpdateState

func UpdateState(state int, publicKey interop.PublicKey)

UpdateState method updates the state of a node from the network map candidate list. For notary-ENABLED environment, tx must be signed by both storage node and alphabet. To force update without storage node signature, see `UpdateStateIR`.

For notary-DISABLED environment, the behaviour depends on who signed the transaction: 1. If it was signed by alphabet, go into voting. 2. If it was signed by a storage node, emit `UpdateState` notification. 2. Fail in any other case.

The behaviour can be summarized in the following table: | notary \ Signer | Storage node | Alphabet | Both | | ENABLED | FAIL | FAIL | OK | | DISABLED | NOTIFICATION | OK | OK (same as alphabet) | State argument defines node state. The only supported state now is (2) -- offline state. Node is removed from the network map candidate list.

Method panics when invoked with unsupported states.

func UpdateStateIR added in v0.15.0

func UpdateStateIR(state nodeState, publicKey interop.PublicKey)

UpdateStateIR method tries to change the node state in the network map. Should only be invoked in notary-enabled environment by alphabet.

func Version

func Version() int

Version returns the version of the contract.

Types

This section is empty.

Jump to

Keyboard shortcuts

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