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.
This commit is contained in:
Roman Khimov 2021-09-22 10:50:26 +03:00
parent 6d5fb59f59
commit b66bc33cf9

View file

@ -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)