Package version implements Oasis protocol and runtime versioning.

For a more detailed explanation of Oasis Core's versioning, see:



View Source
const VersionUndefined = "undefined"

VersionUndefined represents an undefined version.


View Source
var (
	// SoftwareVersion represents the Oasis Core's version and should be set
	// by the linker.
	SoftwareVersion = "0.0-unset"

	// GitBranch is the name of the git branch of Oasis Core.
	// This is mostly used for reporting and metrics.
	GitBranch = ""

	// ConsensusProtocol versions all data structures and processing used by
	// the epochtime, beacon, registry, roothash, etc. modules that are
	// backend by consensus.
	// NOTE: Consensus protocol version compatibility is currently not directly
	// checked in Oasis Core.
	// It is converted to TendermintAppVersion whose compatibility is checked
	// via Tendermint's version checks.
	ConsensusProtocol = Version{Major: 4, Minor: 0, Patch: 0}

	// RuntimeHostProtocol versions the protocol between the Oasis node(s) and
	// the runtime.
	// NOTE: This version must be synced with runtime/src/common/
	RuntimeHostProtocol = Version{Major: 2, Minor: 0, Patch: 0}

	// RuntimeCommitteeProtocol versions the P2P protocol used by the runtime
	// committee members.
	RuntimeCommitteeProtocol = Version{Major: 2, Minor: 0, Patch: 0}

	// TendermintAppVersion is Tendermint ABCI application's version computed by
	// masking non-major consensus protocol version segments to 0 to be
	// compatible with Tendermint's version checks.
	// NOTE: Tendermint's version checks compare the whole version uint64
	// directly. For example:
	TendermintAppVersion = ConsensusProtocol.MaskNonMajor().ToU64()

	// Toolchain is the version of the Go compiler/standard library.
	Toolchain = parseSemVerStr(strings.TrimPrefix(runtime.Version(), "go"))

Versions are current protocol versions.


func ConvertGoModulesVersion

func ConvertGoModulesVersion(goModVersion string) string

Convert Go Modules compatible version to Oasis Core's canonical version.


type ProtocolVersions

type ProtocolVersions struct {
	ConsensusProtocol        Version `json:"consensus_protocol"`
	RuntimeHostProtocol      Version `json:"runtime_host_protocol"`
	RuntimeCommitteeProtocol Version `json:"runtime_committee_protocol"`

ProtocolVersions are the protocol versions.

func (*ProtocolVersions) Compatible

func (pv *ProtocolVersions) Compatible(other ProtocolVersions) bool

Compatible returns if the two protocol versions are compatible.

func (ProtocolVersions) PrettyPrint

func (pv ProtocolVersions) PrettyPrint(ctx context.Context, prefix string, w io.Writer)

PrettyPrint writes a pretty-printed representation of ProtocolVersions to the given writer.

func (ProtocolVersions) PrettyType

func (pv ProtocolVersions) PrettyType() (interface{}, error)

PrettyType returns a representation of ProtocolVersions that can be used for pretty printing.

func (ProtocolVersions) String

func (pv ProtocolVersions) String() string

String returns the protocol versions as a string.

func (*ProtocolVersions) ValidateBasic

func (pv *ProtocolVersions) ValidateBasic() error

ValidateBasic does basic validation checks of the protocol versions.

type Version

type Version struct {
	Major uint16 `json:"major,omitempty"`
	Minor uint16 `json:"minor,omitempty"`
	Patch uint16 `json:"patch,omitempty"`

Version is a protocol version.

func FromU64

func FromU64(v uint64) Version

FromU64 returns the version from platform-dependent uint64.

func (Version) MaskNonMajor

func (v Version) MaskNonMajor() Version

MaskNonMajor masks all non-major version segments to 0 and returns a new protocol version.

This is useful for comparing protocol versions for backward-incompatible changes.

func (Version) String

func (v Version) String() string

String returns the protocol version as a string.

func (Version) ToU64

func (v Version) ToU64() uint64

ToU64 returns the version as platform-dependent uint64.

func (Version) ValidateBasic

func (v Version) ValidateBasic() error

ValidateBasic does basic validation of a protocol version.

Source Files