Skip to content

Commit

Permalink
Merge pull request #96 from nspcc-dev/update
Browse files Browse the repository at this point in the history
Update to the latest API/contracts
  • Loading branch information
roman-khimov authored Jan 31, 2024
2 parents fba34df + 8781a70 commit 968f686
Show file tree
Hide file tree
Showing 17 changed files with 311 additions and 267 deletions.
2 changes: 2 additions & 0 deletions 06-blockchain/02-contracts.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
## NeoFS Smart Contracts

The API described below corresponds to [neofs-contract v0.19.1](https://github.com/nspcc-dev/neofs-contract/releases/tag/v0.19.1).
37 changes: 18 additions & 19 deletions 06-blockchain/03-alphabet.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
### alphabet contract

Alphabet contract is a contract deployed in NeoFS sidechain\.

Alphabet contract is designed to support GAS production and vote for new validators in the sidechain\. NEO token is required to produce GAS and vote for a new committee\. It can be distributed among alphabet nodes of the Inner Ring\. However\, some of them may be malicious\, and some NEO can be lost\. It will destabilize the economic of the sidechain\. To avoid it\, all 100\,000\,000 NEO are distributed among all alphabet contracts\.

To identify alphabet contracts\, they are named with letters of the Glagolitic alphabet\. Names are set at contract deploy\. Alphabet nodes of the Inner Ring communicate with one of the alphabetical contracts to emit GAS\. To vote for a new list of side chain committee\, alphabet nodes of the Inner Ring create multisignature transactions for each alphabet contract\.
Package alphabet contains implementation of Alphabet contract deployed in NeoFS sidechain.

Alphabet contract is designed to support GAS production and vote for new validators in the sidechain. NEO token is required to produce GAS and vote for a new committee. It can be distributed among alphabet nodes of the Inner Ring. However, some of them may be malicious, and some NEO can be lost. It will destabilize the economic of the sidechain. To avoid it, all 100,000,000 NEO are distributed among all alphabet contracts.

To identify alphabet contracts, they are named with letters of the Glagolitic alphabet. Names are set at contract deploy. Alphabet nodes of the Inner Ring communicate with one of the alphabetical contracts to emit GAS. To vote for a new list of side chain committee, alphabet nodes of the Inner Ring create multisignature transactions for each alphabet contract.

#### Contract notifications

Alphabet contract does not produce notifications to process\.
Alphabet contract does not produce notifications to process.

#### Contract methods

Expand All @@ -18,68 +20,65 @@ Alphabet contract does not produce notifications to process\.
func Emit()
```

Emit method produces sidechain GAS and distributes it among Inner Ring nodes and proxy contract\. It can be invoked only by an Alphabet node of the Inner Ring\.
Emit method produces sidechain GAS and distributes it among Inner Ring nodes and proxy contract. It can be invoked only by an Alphabet node of the Inner Ring.

To produce GAS\, an alphabet contract transfers all available NEO from the contract account to itself\. If notary is enabled\, 50% of the GAS in the contract account are transferred to proxy contract\. 43\.75% of the GAS are equally distributed among all Inner Ring nodes\. Remaining 6\.25% of the GAS stay in the contract\.

If notary is disabled\, 87\.5% of the GAS are equally distributed among all Inner Ring nodes\. Remaining 12\.5% of the GAS stay in the contract\.
To produce GAS, an alphabet contract transfers all available NEO from the contract account to itself. 50% of the GAS in the contract account are transferred to proxy contract. 43.75% of the GAS are equally distributed among all Inner Ring nodes. Remaining 6.25% of the GAS stay in the contract.

##### Gas

```go
func Gas() int
```

GAS returns the amount of the sidechain GAS stored in the contract account\.
Gas returns the amount of the sidechain GAS stored in the contract account.

##### Name

```go
func Name() string
```

Name returns the Glagolitic name of the contract\.
Name returns the Glagolitic name of the contract.

##### Neo

```go
func Neo() int
```

NEO returns the amount of sidechain NEO stored in the contract account\.
Neo returns the amount of sidechain NEO stored in the contract account.

##### OnNEP17Payment

```go
func OnNEP17Payment(from interop.Hash160, amount int, data interface{})
func OnNEP17Payment(from interop.Hash160, amount int, data any)
```

OnNEP17Payment is a callback for NEP\-17 compatible native GAS and NEO contracts\.
OnNEP17Payment is a callback for NEP\-17 compatible native GAS and NEO contracts.

##### Update

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

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

##### Version

```go
func Version() int
```

Version returns the version of the contract\.
Version returns the version of the contract.

##### Vote

```go
func Vote(epoch int, candidates []interop.PublicKey)
```

Vote method votes for the sidechain committee\. It requires multisignature from Alphabet nodes of the Inner Ring\.

This method is used when governance changes the list of Alphabet nodes of the Inner Ring\. Alphabet nodes share keys with sidechain validators\, therefore it is required to change them as well\. To do that\, NEO holders \(which are alphabet contracts\) should vote for a new committee\.
Vote method votes for the sidechain committee. It requires multisignature from Alphabet nodes of the Inner Ring.

This method is used when governance changes the list of Alphabet nodes of the Inner Ring. Alphabet nodes share keys with sidechain validators, therefore it is required to change them as well. To do that, NEO holders \(which are alphabet contracts\) should vote for a new committee.

33 changes: 17 additions & 16 deletions 06-blockchain/03-audit.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
### audit contract

Audit contract is a contract deployed in NeoFS sidechain\.

Inner Ring nodes perform audit of the registered containers during every epoch\. If a container contains StorageGroup objects\, an Inner Ring node initializes a series of audit checks\. Based on the results of these checks\, the Inner Ring node creates a DataAuditResult structure for the container\. The content of this structure makes it possible to determine which storage nodes have been examined and see the status of these checks\. Regarding this information\, the container owner is charged for data storage\.

Audit contract is used as a reliable and verifiable storage for all DataAuditResult structures\. At the end of data audit routine\, Inner Ring nodes send a stable marshaled version of the DataAuditResult structure to the contract\. When Alphabet nodes of the Inner Ring perform settlement operations\, they make a list and get these AuditResultStructures from the audit contract\.
Package audit contains implementation of Audit contract deployed in NeoFS sidechain.

Inner Ring nodes perform audit of the registered containers during every epoch. If a container contains StorageGroup objects, an Inner Ring node initializes a series of audit checks. Based on the results of these checks, the Inner Ring node creates a DataAuditResult structure for the container. The content of this structure makes it possible to determine which storage nodes have been examined and see the status of these checks. Regarding this information, the container owner is charged for data storage.

Audit contract is used as a reliable and verifiable storage for all DataAuditResult structures. At the end of data audit routine, Inner Ring nodes send a stable marshaled version of the DataAuditResult structure to the contract. When Alphabet nodes of the Inner Ring perform settlement operations, they make a list and get these AuditResultStructures from the audit contract.

#### Contract notifications

Audit contract does not produce notifications to process\.
Audit contract does not produce notifications to process.

#### Contract methods

Expand All @@ -18,66 +20,65 @@ Audit contract does not produce notifications to process\.
func Get(id []byte) []byte
```

Get method returns a stable marshaled DataAuditResult structure\.
Get method returns a stable marshaled DataAuditResult structure.

The ID of the DataAuditResult can be obtained from listing methods\.
The ID of the DataAuditResult can be obtained from listing methods.

##### List

```go
func List() [][]byte
```

List method returns a list of all available DataAuditResult IDs from the contract storage\.
List method returns a list of all available DataAuditResult IDs from the contract storage.

##### ListByCID

```go
func ListByCID(epoch int, cid []byte) [][]byte
```

ListByCID method returns a list of DataAuditResult IDs generated during the specified epoch for the specified container\.
ListByCID method returns a list of DataAuditResult IDs generated during the specified epoch for the specified container.

##### ListByEpoch

```go
func ListByEpoch(epoch int) [][]byte
```

ListByEpoch method returns a list of DataAuditResult IDs generated during the specified epoch\.
ListByEpoch method returns a list of DataAuditResult IDs generated during the specified epoch.

##### ListByNode

```go
func ListByNode(epoch int, cid []byte, key interop.PublicKey) [][]byte
```

ListByNode method returns a list of DataAuditResult IDs generated in the specified epoch for the specified container by the specified Inner Ring node\.
ListByNode method returns a list of DataAuditResult IDs generated in the specified epoch for the specified container by the specified Inner Ring node.

##### Put

```go
func Put(rawAuditResult []byte)
```

Put method stores a stable marshalled \`DataAuditResult\` structure\. It can be invoked only by Inner Ring nodes\.
Put method stores a stable marshalled \`DataAuditResult\` structure. It can be invoked only by Inner Ring nodes.

Inner Ring nodes perform audit of containers and produce \`DataAuditResult\` structures\. They are stored in audit contract and used for settlements in later epochs\.
Inner Ring nodes perform audit of containers and produce \`DataAuditResult\` structures. They are stored in audit contract and used for settlements in later epochs.

##### Update

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

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

##### Version

```go
func Version() int
```

Version returns the version of the contract\.

Version returns the version of the contract.

Loading

0 comments on commit 968f686

Please sign in to comment.