From b66bc33cf92945d328c4ae47da8568bbb064d928 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 22 Sep 2021 10:50:26 +0300 Subject: [PATCH] native: short-circuit successive GAS distributions GAS can only be distributed once in a block for particular address, so it makes little sense trying to calculate it again and again. This fixes neo-bench for NEO voter, because without it we get ~2500 TPS for single-address test and with it it jumps 13-fold to normal values like ~33500. --- pkg/core/native/native_neo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index 133870c54..9df6e468b 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -434,7 +434,7 @@ func (n *NEO) balanceFromBytes(si *state.StorageItem) (*big.Int, error) { } func (n *NEO) distributeGas(ic *interop.Context, h util.Uint160, acc *state.NEOBalance) error { - if ic.Block == nil || ic.Block.Index == 0 { + if ic.Block == nil || ic.Block.Index == 0 || ic.Block.Index == acc.BalanceHeight { return nil } gen, err := n.calculateBonus(ic.DAO, acc.VoteTo, &acc.Balance, acc.BalanceHeight, ic.Block.Index)