[#1239] adm/morph: Fix transfer GAS to alphabet nodes
All checks were successful
DCO action / DCO (pull_request) Successful in 7m55s
Vulncheck / Vulncheck (pull_request) Successful in 8m4s
Build / Build Components (1.21) (pull_request) Successful in 10m21s
Build / Build Components (1.22) (pull_request) Successful in 10m21s
Tests and linters / Staticcheck (pull_request) Successful in 11m45s
Tests and linters / Lint (pull_request) Successful in 12m23s
Tests and linters / gopls check (pull_request) Successful in 14m17s
Pre-commit hooks / Pre-commit (pull_request) Successful in 16m26s
Tests and linters / Tests (1.21) (pull_request) Successful in 17m5s
Tests and linters / Tests with -race (pull_request) Successful in 17m17s
Tests and linters / Tests (1.22) (pull_request) Successful in 17m26s

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2024-07-11 18:28:14 +03:00
parent 0308835d48
commit 08953a2f94

View file

@ -26,6 +26,10 @@ const (
initialAlphabetGASAmount = 10_000 * native.GASFactor initialAlphabetGASAmount = 10_000 * native.GASFactor
// initialProxyGASAmount represents the amount of GAS given to a proxy contract. // initialProxyGASAmount represents the amount of GAS given to a proxy contract.
initialProxyGASAmount = 50_000 * native.GASFactor initialProxyGASAmount = 50_000 * native.GASFactor
// alphabetGasRatio is a coefficient that defines the threshold below which
// the balance of the alphabet node is considered not replenished. The value
// of this coefficient is determined empirically.
alphabetGasRatio = 5
) )
func transferFunds(c *helper.InitializeContext) error { func transferFunds(c *helper.InitializeContext) error {
@ -80,7 +84,7 @@ func transferFundsFinished(c *helper.InitializeContext) (bool, error) {
r := nep17.NewReader(c.ReadOnlyInvoker, gas.Hash) r := nep17.NewReader(c.ReadOnlyInvoker, gas.Hash)
res, err := r.BalanceOf(acc.Contract.ScriptHash()) res, err := r.BalanceOf(acc.Contract.ScriptHash())
return res.Cmp(big.NewInt(initialAlphabetGASAmount/2)) == 1, err return res.Cmp(big.NewInt(alphabetGasRatio*native.GASFactor)) == 1, err
} }
func transferGASToProxy(c *helper.InitializeContext) error { func transferGASToProxy(c *helper.InitializeContext) error {