diff --git a/Makefile b/Makefile index 22d0dc0..121fb74 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ sidechain: alphabet morph nns alphabet_sc = alphabet morph_sc = audit balance container neofsid netmap proxy reputation subnet -mainnet_sc = neofs processing +mainnet_sc = frostfs processing nns_sc = nns define sc_template diff --git a/neofs/config.yml b/frostfs/config.yml similarity index 98% rename from neofs/config.yml rename to frostfs/config.yml index cfeb49e..07c56ef 100644 --- a/neofs/config.yml +++ b/frostfs/config.yml @@ -1,4 +1,4 @@ -name: "NeoFS" +name: "FrostFS" safemethods: ["alphabetList", "alphabetAddress", "innerRingCandidates", "config", "listConfig", "version"] permissions: - methods: ["update", "transfer"] diff --git a/neofs/doc.go b/frostfs/doc.go similarity index 75% rename from neofs/doc.go rename to frostfs/doc.go index 29b2203..99690d6 100644 --- a/neofs/doc.go +++ b/frostfs/doc.go @@ -1,21 +1,21 @@ /* -NeoFS contract is a contract deployed in NeoFS mainchain. +FrostFS contract is a contract deployed in FrostFS mainchain. -NeoFS contract is an entry point to NeoFS users. This contract stores all NeoFS +FrostFS contract is an entry point to FrostFS users. This contract stores all FrostFS related GAS, registers new Inner Ring candidates and produces notifications to control the sidechain. While mainchain committee controls the list of Alphabet nodes in native -RoleManagement contract, NeoFS can't change more than 1\3 keys at a time. -NeoFS contract contains the actual list of Alphabet nodes in the sidechain. +RoleManagement contract, FrostFS can't change more than 1\3 keys at a time. +FrostFS contract contains the actual list of Alphabet nodes in the sidechain. -Network configuration is also stored in NeoFS contract. All changes in +Network configuration is also stored in FrostFS contract. All changes in configuration are mirrored in the sidechain with notifications. # Contract notifications Deposit notification. This notification is produced when user transfers native -GAS to the NeoFS contract address. The same amount of NEOFS token will be +GAS to the FrostFS contract address. The same amount of FROSTFS token will be minted in Balance contract in the sidechain. Deposit: @@ -29,7 +29,7 @@ minted in Balance contract in the sidechain. type: Hash256 Withdraw notification. This notification is produced when a user wants to -withdraw GAS from the internal NeoFS balance and has paid fee for that. +withdraw GAS from the internal FrostFS balance and has paid fee for that. Withdraw: - name: user @@ -39,7 +39,7 @@ withdraw GAS from the internal NeoFS balance and has paid fee for that. - name: txHash type: Hash256 -Cheque notification. This notification is produced when NeoFS contract +Cheque notification. This notification is produced when FrostFS contract has successfully transferred assets back to the user after withdraw. Cheque: @@ -81,7 +81,7 @@ contains public keys of new alphabet nodes. type: Array SetConfig notification. This notification is produced when Alphabet nodes update -NeoFS network configuration value. +FrostFS network configuration value. SetConfig - name: id @@ -91,4 +91,4 @@ NeoFS network configuration value. - name: value type: ByteArray */ -package neofs +package frostfs diff --git a/neofs/neofs_contract.go b/frostfs/frostfs_contract.go similarity index 93% rename from neofs/neofs_contract.go rename to frostfs/frostfs_contract.go index cd62469..ca654ad 100644 --- a/neofs/neofs_contract.go +++ b/frostfs/frostfs_contract.go @@ -1,4 +1,4 @@ -package neofs +package frostfs import ( "github.com/TrueCloudLab/frostfs-contract/common" @@ -85,7 +85,7 @@ func _deploy(data interface{}, isUpdate bool) { storage.Put(ctx, notaryDisabledKey, args.notaryDisabled) if args.notaryDisabled { common.InitVote(ctx) - runtime.Log("neofs contract notary disabled") + runtime.Log("frostfs contract notary disabled") } ln := len(args.config) @@ -100,7 +100,7 @@ func _deploy(data interface{}, isUpdate bool) { setConfig(ctx, key, val) } - runtime.Log("neofs: contract initialized") + runtime.Log("frostfs: contract initialized") } // Update method updates contract source code and manifest. It can be invoked @@ -114,7 +114,7 @@ func Update(script []byte, manifest []byte, data interface{}) { contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, common.AppendVersion(data)) - runtime.Log("neofs contract updated") + runtime.Log("frostfs contract updated") } // AlphabetList returns an array of alphabet node keys. It is used in sidechain notary @@ -205,7 +205,7 @@ func InnerRingCandidateRemove(key interop.PublicKey) { // It can be invoked only by the candidate itself. // // This method transfers fee from a candidate to the contract account. -// Fee value is specified in NeoFS network config with the key InnerRingCandidateFee. +// Fee value is specified in FrostFS network config with the key InnerRingCandidateFee. func InnerRingCandidateAdd(key interop.PublicKey) { ctx := storage.GetContext() @@ -231,7 +231,7 @@ func InnerRingCandidateAdd(key interop.PublicKey) { // OnNEP17Payment is a callback for NEP-17 compatible native GAS contract. // It takes no more than 9000.0 GAS. Native GAS has precision 8, and -// NeoFS balance contract has precision 12. Values bigger than 9000.0 can +// FrostFS balance contract has precision 12. Values bigger than 9000.0 can // break JSON limits for integers when precision is converted. func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) { rcv := data.(interop.Hash160) @@ -264,13 +264,13 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) { runtime.Notify("Deposit", from, amount, rcv, tx.Hash) } -// Withdraw initializes gas asset withdraw from NeoFS. It can be invoked only +// Withdraw initializes gas asset withdraw from FrostFS. It can be invoked only // by the specified user. // // This method produces Withdraw notification to lock assets in the sidechain and // transfers withdraw fee from a user account to each Alphabet node. If notary // is enabled in the mainchain, fee is transferred to Processing contract. -// Fee value is specified in NeoFS network config with the key WithdrawFee. +// Fee value is specified in FrostFS network config with the key WithdrawFee. func Withdraw(user interop.Hash160, amount int) { if !runtime.CheckWitness(user) { panic("you should be the owner of the wallet") @@ -317,7 +317,7 @@ func Withdraw(user interop.Hash160, amount int) { } // Cheque transfers GAS back to the user from the contract account, if assets were -// successfully locked in NeoFS balance contract. It can be invoked only by +// successfully locked in FrostFS balance contract. It can be invoked only by // Alphabet nodes. // // This method produces Cheque notification to burn assets in sidechain. @@ -363,7 +363,7 @@ func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) { runtime.Notify("Cheque", id, user, amount, lockAcc) } -// Bind method produces notification to bind the specified public keys in NeoFSID +// Bind method produces notification to bind the specified public keys in FrostFSID // contract in the sidechain. It can be invoked only by specified user. // // This method produces Bind notification. This method panics if keys are not @@ -383,7 +383,7 @@ func Bind(user []byte, keys []interop.PublicKey) { runtime.Notify("Bind", user, keys) } -// Unbind method produces notification to unbind the specified public keys in NeoFSID +// Unbind method produces notification to unbind the specified public keys in FrostFSID // contract in the sidechain. It can be invoked only by the specified user. // // This method produces Unbind notification. This method panics if keys are not @@ -407,7 +407,7 @@ func Unbind(user []byte, keys []interop.PublicKey) { // public keys. It can be invoked only by alphabet nodes. // // This method is used in notary disabled sidechain environment. In this case, -// the actual alphabet list should be stored in the NeoFS contract. +// the actual alphabet list should be stored in the FrostFS contract. func AlphabetUpdate(id []byte, args []interop.PublicKey) { ctx := storage.GetContext() notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool) @@ -460,14 +460,14 @@ func AlphabetUpdate(id []byte, args []interop.PublicKey) { runtime.Log("alphabet list has been updated") } -// Config returns configuration value of NeoFS configuration. If the key does +// Config returns configuration value of FrostFS configuration. If the key does // not exists, returns nil. func Config(key []byte) interface{} { ctx := storage.GetReadOnlyContext() return getConfig(ctx, key) } -// SetConfig key-value pair as a NeoFS runtime configuration value. It can be invoked +// SetConfig key-value pair as a FrostFS runtime configuration value. It can be invoked // only by Alphabet nodes. func SetConfig(id, key, val []byte) { ctx := storage.GetContext() @@ -507,7 +507,7 @@ func SetConfig(id, key, val []byte) { } // ListConfig returns an array of structures that contain a key and a value of all -// NeoFS configuration records. Key and value are both byte arrays. +// FrostFS configuration records. Key and value are both byte arrays. func ListConfig() []record { ctx := storage.GetReadOnlyContext() @@ -542,7 +542,7 @@ func getAlphabetNodes(ctx storage.Context) []interop.PublicKey { return []interop.PublicKey{} } -// getConfig returns the installed neofs configuration value or nil if it is not set. +// getConfig returns the installed frostfs configuration value or nil if it is not set. func getConfig(ctx storage.Context, key interface{}) interface{} { postfix := key.([]byte) storageKey := append(configPrefix, postfix...) @@ -550,7 +550,7 @@ func getConfig(ctx storage.Context, key interface{}) interface{} { return storage.Get(ctx, storageKey) } -// setConfig sets a neofs configuration value in the contract storage. +// setConfig sets a frostfs configuration value in the contract storage. func setConfig(ctx storage.Context, key, val interface{}) { postfix := key.([]byte) storageKey := append(configPrefix, postfix...) diff --git a/tests/neofs_test.go b/tests/frostfs_test.go similarity index 83% rename from tests/neofs_test.go rename to tests/frostfs_test.go index 334d93f..1edab3b 100644 --- a/tests/neofs_test.go +++ b/tests/frostfs_test.go @@ -6,7 +6,7 @@ import ( "sort" "testing" - "github.com/TrueCloudLab/frostfs-contract/neofs" + "github.com/TrueCloudLab/frostfs-contract/frostfs" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/neotest" @@ -18,9 +18,9 @@ import ( "github.com/stretchr/testify/require" ) -const neofsPath = "../neofs" +const frostfsPath = "../frostfs" -func deployNeoFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint160, +func deployFrostFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint160, pubs keys.PublicKeys, config ...interface{}) util.Uint160 { args := make([]interface{}, 5) args[0] = false @@ -33,12 +33,12 @@ func deployNeoFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint16 args[2] = arr args[3] = append([]interface{}{}, config...) - c := neotest.CompileFile(t, e.CommitteeHash, neofsPath, path.Join(neofsPath, "config.yml")) + c := neotest.CompileFile(t, e.CommitteeHash, frostfsPath, path.Join(frostfsPath, "config.yml")) e.DeployContract(t, c, args) return c.Hash } -func newNeoFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.ContractInvoker, neotest.Signer, keys.PublicKeys) { +func newFrostFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.ContractInvoker, neotest.Signer, keys.PublicKeys) { e := newExecutor(t) accounts := make([]*wallet.Account, n) @@ -66,7 +66,7 @@ func newNeoFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.Contr } alphabet := neotest.NewMultiSigner(accounts...) - h := deployNeoFSContract(t, e, util.Uint160{}, pubs, config...) + h := deployFrostFSContract(t, e, util.Uint160{}, pubs, config...) gasHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Gas) require.NoError(t, err) @@ -79,10 +79,10 @@ func newNeoFSInvoker(t *testing.T, n int, config ...interface{}) (*neotest.Contr return e.CommitteeInvoker(h).WithSigners(alphabet), alphabet, pubs } -func TestNeoFS_AlphabetList(t *testing.T) { +func TestFrostFS_AlphabetList(t *testing.T) { const alphabetSize = 4 - e, _, pubs := newNeoFSInvoker(t, alphabetSize) + e, _, pubs := newFrostFSInvoker(t, alphabetSize) arr := make([]stackitem.Item, len(pubs)) for i := range arr { arr[i] = stackitem.NewStruct([]stackitem.Item{ @@ -93,8 +93,8 @@ func TestNeoFS_AlphabetList(t *testing.T) { e.Invoke(t, stackitem.NewArray(arr), "alphabetList") } -func TestNeoFS_InnerRingCandidate(t *testing.T) { - e, _, _ := newNeoFSInvoker(t, 4, neofs.CandidateFeeConfigKey, int64(10)) +func TestFrostFS_InnerRingCandidate(t *testing.T) { + e, _, _ := newFrostFSInvoker(t, 4, frostfs.CandidateFeeConfigKey, int64(10)) const candidateCount = 3