forked from TrueCloudLab/neoneo-go
core: fix contract manifest unpacking in System.Contract.Create
It's just JSON, io.Serializable is only used for DB storage where the length should be obtained from the stream. Fixes: 2020-06-18T22:14:10.571+0300 WARN contract invocation failed {"tx": "1ffd475a9c246495d6206cb80a9a78e9d14a433ded60cd37aa87d897655606e1", "block": 25893, "error": "error encountered at instruction 3696 (SYSCALL): failed to invoke syscall: invalid character ':' after top-level value"}
This commit is contained in:
parent
90d3bcbdc3
commit
1081791c68
5 changed files with 10 additions and 11 deletions
|
@ -234,7 +234,7 @@ func TestCreateBasicChain(t *testing.T) {
|
||||||
}
|
}
|
||||||
m.ABI.EntryPoint.ReturnType = smartcontract.BoolType
|
m.ABI.EntryPoint.ReturnType = smartcontract.BoolType
|
||||||
m.Features = smartcontract.HasStorage
|
m.Features = smartcontract.HasStorage
|
||||||
bs, err := testserdes.EncodeBinary(m)
|
bs, err := m.MarshalJSON()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
emit.Bytes(script.BinWriter, bs)
|
emit.Bytes(script.BinWriter, bs)
|
||||||
emit.Bytes(script.BinWriter, avm)
|
emit.Bytes(script.BinWriter, avm)
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||||
|
@ -76,10 +75,9 @@ func createContractStateFromVM(ic *interop.Context, v *vm.VM) (*state.Contract,
|
||||||
return nil, errGasLimitExceeded
|
return nil, errGasLimitExceeded
|
||||||
}
|
}
|
||||||
var m manifest.Manifest
|
var m manifest.Manifest
|
||||||
r := io.NewBinReaderFromBuf(manifestBytes)
|
err := m.UnmarshalJSON(manifestBytes)
|
||||||
m.DecodeBinary(r)
|
if err != nil {
|
||||||
if r.Err != nil {
|
return nil, err
|
||||||
return nil, r.Err
|
|
||||||
}
|
}
|
||||||
return &state.Contract{
|
return &state.Contract{
|
||||||
Script: script,
|
Script: script,
|
||||||
|
|
|
@ -19,9 +19,10 @@ import (
|
||||||
// with its metadata and system fee require for this.
|
// with its metadata and system fee require for this.
|
||||||
func CreateDeploymentScript(avm []byte, manif *manifest.Manifest) ([]byte, util.Fixed8, error) {
|
func CreateDeploymentScript(avm []byte, manif *manifest.Manifest) ([]byte, util.Fixed8, error) {
|
||||||
script := io.NewBufBinWriter()
|
script := io.NewBufBinWriter()
|
||||||
w := io.NewBufBinWriter()
|
rawManifest, err := manif.MarshalJSON()
|
||||||
manif.EncodeBinary(w.BinWriter)
|
if err != nil {
|
||||||
rawManifest := w.Bytes()
|
return nil, 0, err
|
||||||
|
}
|
||||||
emit.Bytes(script.BinWriter, rawManifest)
|
emit.Bytes(script.BinWriter, rawManifest)
|
||||||
emit.Bytes(script.BinWriter, avm)
|
emit.Bytes(script.BinWriter, avm)
|
||||||
emit.Syscall(script.BinWriter, "System.Contract.Create")
|
emit.Syscall(script.BinWriter, "System.Contract.Create")
|
||||||
|
|
|
@ -51,7 +51,7 @@ type rpcTestCase struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const testContractHash = "e65ff7b3a02d207b584a5c27057d4e9862ef01da"
|
const testContractHash = "e65ff7b3a02d207b584a5c27057d4e9862ef01da"
|
||||||
const deploymentTxHash = "5ce44eae362d3f81d440cb73cf4e4af71e69851bcd683b076aa08b7346d4e69b"
|
const deploymentTxHash = "b0428600383ec7f7b06734978a24dbe81edc87b781f58c0614f122c735d8cf6a"
|
||||||
|
|
||||||
var rpcTestCases = map[string][]rpcTestCase{
|
var rpcTestCases = map[string][]rpcTestCase{
|
||||||
"getapplicationlog": {
|
"getapplicationlog": {
|
||||||
|
@ -148,7 +148,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Asset: e.chain.UtilityTokenHash(),
|
Asset: e.chain.UtilityTokenHash(),
|
||||||
Amount: "923.96934740",
|
Amount: "923.96937740",
|
||||||
LastUpdated: 6,
|
LastUpdated: 6,
|
||||||
}},
|
}},
|
||||||
Address: testchain.PrivateKeyByID(0).GetScriptHash().StringLE(),
|
Address: testchain.PrivateKeyByID(0).GetScriptHash().StringLE(),
|
||||||
|
|
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
Binary file not shown.
Loading…
Reference in a new issue