From 2611e9ab5ccaa86365255280830395a0b9966415 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 25 Oct 2019 11:05:58 +0300 Subject: [PATCH 1/2] smartcontract: fix PropertyState definitions Wrong bits were used to represent flags which is important for contracts created via interop. Fixes contracts failing to store things: WARN[16278] contract invocation failed block=3773025 err="error encountered at instruction 3435 (SYSCALL): failed to invoke syscall: contract c9d870d7857e956d82290d5df19de3133c107815 can't have storage" tx=fa695eea240b7b4dbb6f42ea6335447a764d8b629c40b7812ea3bca16b1f098d WARN[16278] contract invocation failed block=3773025 err="error encountered at instruction 1279 (SYSCALL): failed to invoke syscall: contract 97210e7c98582151ceb37f9748c9a1d27d9ae6fd can't have storage" tx=0144d84038149fa0cf1f7912f7d5854fa5f3670f5b4217789c1441f9fd52d27b --- pkg/smartcontract/param_context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/smartcontract/param_context.go b/pkg/smartcontract/param_context.go index 8f585f86b..f7414f6a0 100644 --- a/pkg/smartcontract/param_context.go +++ b/pkg/smartcontract/param_context.go @@ -23,10 +23,10 @@ type PropertyState byte // List of supported properties. const ( - NoProperties = 0 - HasStorage PropertyState = 1 << iota + HasStorage PropertyState = 1 << iota HasDynamicInvoke IsPayable + NoProperties = 0 ) // Parameter represents a smart contract parameter. From 99bbad331d2823901f15510be6e918e793a78932 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 25 Oct 2019 17:20:12 +0300 Subject: [PATCH 2/2] core: add issue tx processing Count available asset quantity, match C# code. --- pkg/core/blockchain.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 13159122e..f29aaaeda 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -394,6 +394,21 @@ func (bc *Blockchain) storeBlock(block *Block) error { Expiration: bc.BlockHeight() + registeredAssetLifetime, } case *transaction.IssueTX: + for _, res := range bc.GetTransactionResults(tx) { + if res.Amount < 0 { + var asset *AssetState + + asset, ok := assets[res.AssetID] + if !ok { + asset = bc.GetAssetState(res.AssetID) + } + if asset == nil { + return fmt.Errorf("issue failed: no asset %s", res.AssetID) + } + asset.Available -= res.Amount + assets[res.AssetID] = asset + } + } case *transaction.ClaimTX: case *transaction.EnrollmentTX: case *transaction.StateTX: