mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
core: restrict maximum gas allow for verification
Disallow costly verification methods. We put this limit in policy contract as it may be a subject to change in future. In fact this value also overrides gas limit for header verification. Close #1202.
This commit is contained in:
parent
a45c160f10
commit
121c9664b4
2 changed files with 13 additions and 0 deletions
|
@ -1305,6 +1305,11 @@ func (bc *Blockchain) verifyHashAgainstScript(hash util.Uint160, witness *transa
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gasPolicy := bc.contracts.Policy.GetMaxVerificationGas(interopCtx.DAO)
|
||||||
|
if gas > gasPolicy {
|
||||||
|
gas = gasPolicy
|
||||||
|
}
|
||||||
|
|
||||||
vm := SpawnVM(interopCtx)
|
vm := SpawnVM(interopCtx)
|
||||||
vm.SetPriceGetter(getPrice)
|
vm.SetPriceGetter(getPrice)
|
||||||
vm.GasLimit = gas
|
vm.GasLimit = gas
|
||||||
|
|
|
@ -25,6 +25,7 @@ const (
|
||||||
defaultMaxBlockSize = 1024 * 256
|
defaultMaxBlockSize = 1024 * 256
|
||||||
defaultMaxTransactionsPerBlock = 512
|
defaultMaxTransactionsPerBlock = 512
|
||||||
defaultFeePerByte = 1000
|
defaultFeePerByte = 1000
|
||||||
|
defaultMaxVerificationGas = 50000000
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -51,6 +52,7 @@ type Policy struct {
|
||||||
maxTransactionsPerBlock uint32
|
maxTransactionsPerBlock uint32
|
||||||
maxBlockSize uint32
|
maxBlockSize uint32
|
||||||
feePerByte int64
|
feePerByte int64
|
||||||
|
maxVerificationGas int64
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ interop.Contract = (*Policy)(nil)
|
var _ interop.Contract = (*Policy)(nil)
|
||||||
|
@ -149,6 +151,7 @@ func (p *Policy) Initialize(ic *interop.Context) error {
|
||||||
p.maxTransactionsPerBlock = defaultMaxTransactionsPerBlock
|
p.maxTransactionsPerBlock = defaultMaxTransactionsPerBlock
|
||||||
p.maxBlockSize = defaultMaxBlockSize
|
p.maxBlockSize = defaultMaxBlockSize
|
||||||
p.feePerByte = defaultFeePerByte
|
p.feePerByte = defaultFeePerByte
|
||||||
|
p.maxVerificationGas = defaultMaxVerificationGas
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -221,6 +224,11 @@ func (p *Policy) GetFeePerByteInternal(dao dao.DAO) int64 {
|
||||||
return p.getInt64WithKey(dao, feePerByteKey)
|
return p.getInt64WithKey(dao, feePerByteKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMaxVerificationGas returns maximum gas allowed to be burned during verificaion.
|
||||||
|
func (p *Policy) GetMaxVerificationGas(_ dao.DAO) int64 {
|
||||||
|
return p.maxVerificationGas
|
||||||
|
}
|
||||||
|
|
||||||
// getBlockedAccounts is Policy contract method and returns list of blocked
|
// getBlockedAccounts is Policy contract method and returns list of blocked
|
||||||
// accounts hashes.
|
// accounts hashes.
|
||||||
func (p *Policy) getBlockedAccounts(ic *interop.Context, _ []stackitem.Item) stackitem.Item {
|
func (p *Policy) getBlockedAccounts(ic *interop.Context, _ []stackitem.Item) stackitem.Item {
|
||||||
|
|
Loading…
Reference in a new issue