[#1654] adm: Make 'morph-init' idempotent
All checks were successful
DCO action / DCO (pull_request) Successful in 34s
Vulncheck / Vulncheck (pull_request) Successful in 53s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m24s
Build / Build Components (pull_request) Successful in 1m28s
Tests and linters / Run gofumpt (pull_request) Successful in 1m58s
Tests and linters / Staticcheck (pull_request) Successful in 2m11s
Tests and linters / Tests (pull_request) Successful in 2m26s
Tests and linters / Lint (pull_request) Successful in 2m52s
Tests and linters / Tests with -race (pull_request) Successful in 3m2s
Tests and linters / gopls check (pull_request) Successful in 3m39s

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2025-02-24 12:28:02 +03:00
parent 02f3a7f65c
commit 1c43fcdda9
Signed by: achuprov
GPG key ID: 2D916FFD803B0EDD

View file

@ -27,6 +27,8 @@ const (
initialAlphabetGASAmount = 10_000 * native.GASFactor
// initialProxyGASAmount represents the amount of GAS given to a proxy contract.
initialProxyGASAmount = 50_000 * native.GASFactor
// InitialGASSupply contains value from https://github.com/nspcc-dev/neo-go/blob/0d8c751e50951ad84cec8b89cf6ea1a9e0f4f878/config/protocol.mainnet.yml#L4
InitialGASSupply = 52000000 * native.GASFactor
)
func initialCommitteeGASAmount(c *helper.InitializeContext) int64 {
@ -83,11 +85,9 @@ func transferFunds(c *helper.InitializeContext) error {
// transferFundsFinished checks balances of accounts we transfer GAS to.
// The stage is considered finished if the balance is greater than the half of what we need to transfer.
func transferFundsFinished(c *helper.InitializeContext) (bool, error) {
acc := c.Accounts[0]
r := nep17.NewReader(c.ReadOnlyInvoker, gas.Hash)
res, err := r.BalanceOf(acc.Contract.ScriptHash())
if err != nil || res.Cmp(big.NewInt(initialAlphabetGASAmount/2)) != 1 {
res, err := r.BalanceOf(c.ConsensusAcc.ScriptHash())
if err != nil || res.Cmp(big.NewInt(InitialGASSupply)) != -1 {
return false, err
}