core: restrict GAS available for invocation transactions

There are 10 GAS available for free plus any amount of GAS
attached to a transaction.
This commit is contained in:
Evgenii Stratonikov 2020-01-20 15:31:12 +03:00
parent d72d978a19
commit 4eae55143f
3 changed files with 236 additions and 1 deletions

View file

@ -514,6 +514,11 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
v := bc.spawnVMWithInterops(systemInterop)
v.SetCheckedHash(tx.VerificationHash().BytesBE())
v.LoadScript(t.Script)
v.SetPriceGetter(getPrice)
gasAmount := util.Fixed8FromInt64(10) + t.Gas
v.SetGasLimit(gasAmount)
err := v.Run()
if !v.HasFailed() {
_, err := systemInterop.dao.Persist()
@ -554,7 +559,7 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
TxHash: tx.Hash(),
Trigger: trigger.Application,
VMState: v.State(),
GasConsumed: util.Fixed8(0),
GasConsumed: v.GasConsumed(),
Stack: v.Stack("estack"),
Events: systemInterop.notifications,
}