neoneo-go/pkg/core
Anna Shaleva 16bf7c1426 core: adjust contract script check on deploy
Reference implementation doesn't panic if the method offset is out of
the contract script bounds, see:
736c346b9d/src/neo/SmartContract/Helper.cs (L82)
and
a65487fa56/src/Neo.VM/Script.cs (L146).

This commit fixes T5 statediff at block #125000. Neo-go node FAULTed the
deploying transaction:
```
         {
            "version" : 0,
            "sysfee" : "1000106065",
            "validuntilblock" : 130758,
            "script" : "DdMDeyJuYW1lIjoiTmVwMTdUb2tlbiIsImdyb3VwcyI6W10sImZlYXR1cmVzIjp7fSwic3VwcG9ydGVkc3RhbmRhcmRzIjpbIk5FUC0xNyJdLCJhYmkiOnsibWV0aG9kcyI6W3sibmFtZSI6InN5bWJvbCIsInBhcmFtZXRlcnMiOltdLCJyZXR1cm50eXBlIjoiU3RyaW5nIiwib2Zmc2V0IjoyMiwic2FmZSI6dHJ1ZX0seyJuYW1lIjoiZGVjaW1hbHMiLCJwYXJhbWV0ZXJzIjpbXSwicmV0dXJudHlwZSI6IkludGVnZXIiLCJvZmZzZXQiOjIyLCJzYWZlIjp0cnVlfSx7Im5hbWUiOiJ0b3RhbFN1cHBseSIsInBhcmFtZXRlcnMiOltdLCJyZXR1cm50eXBlIjoiSW50ZWdlciIsIm9mZnNldCI6MjIsInNhZmUiOnRydWV9LHsibmFtZSI6ImJhbGFuY2VPZiIsInBhcmFtZXRlcnMiOlt7Im5hbWUiOiJvd25lciIsInR5cGUiOiJIYXNoMTYwIn1dLCJyZXR1cm50eXBlIjoiSW50ZWdlciIsIm9mZnNldCI6MjIsInNhZmUiOnRydWV9LHsibmFtZSI6InRyYW5zZmVyIiwicGFyYW1ldGVycyI6W3sibmFtZSI6ImZyb20iLCJ0eXBlIjoiSGFzaDE2MCJ9LHsibmFtZSI6InRvIiwidHlwZSI6Ikhhc2gxNjAifSx7Im5hbWUiOiJhbW91bnQiLCJ0eXBlIjoiSW50ZWdlciJ9LHsibmFtZSI6ImRhdGEiLCJ0eXBlIjoiQW55In1dLCJyZXR1cm50eXBlIjoiQm9vbGVhbiIsIm9mZnNldCI6MjIsInNhZmUiOmZhbHNlfV0sImV2ZW50cyI6W3sibmFtZSI6IlRyYW5zZmVyIiwicGFyYW1ldGVycyI6W3sibmFtZSI6ImZyb20iLCJ0eXBlIjoiSGFzaDE2MCJ9LHsibmFtZSI6InRvIiwidHlwZSI6Ikhhc2gxNjAifSx7Im5hbWUiOiJhbW91bnQiLCJ0eXBlIjoiSW50ZWdlciJ9XX1dfSwicGVybWlzc2lvbnMiOlt7ImNvbnRyYWN0IjoiKiIsIm1ldGhvZHMiOiIqIn1dLCJ0cnVzdHMiOltdLCJleHRyYSI6eyJlbWFpbCI6ImRldmVsb3BlckBuZW8ub3JnIiwiYXV0aG9yIjoibGF6eW5vZGUiLCJkZXNjcmlwdGlvbiI6IkEgU2ltcGxlIE5lcC0xNyBDb250cmFjdCJ9fQyyTkVGM25lb21sAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABOaHR0cHM6Ly9naXRodWIuY29tL2xhenlub2RlL25lb21sL2Jsb2IvZGV2L2V4YW1wbGVzL2EuZnVuY3Rpb24uc2ltcGxlbmVwMTcueG1sAAAAABYMBU5lb01MQBhAAgDh9QVAATkFQBFAkA456BLAHwwGZGVwbG95DBT9o/pDRupTKiWPxJfdrdtkN8n9/0FifVtS",
            "hash" : "0x40302bcf2021f63a1c24f6009e154c3200f73ad2fe1462d7d599145823dbfa7e",
            "witnesses" : [
               {
                  "verification" : "DCECExn08eznGBdguHbcwI+R2//EtVdDx4qf6CeizHqOJgBBVuezJw==",
                  "invocation" : "DEBtoq+T9NrammQjuYnifco7KHCTk2v+woEJqJCUMr9IscS7PaZaN3FNzSt11yUglIi3T0CJ17KwArBOBvJ8kwq2"
               }
            ],
            "attributes" : [],
            "signers" : [
               {
                  "scopes" : "None",
                  "account" : "0x13a192c56738900f9918d7f1ec07d9d8c278b804"
               }
            ],
            "size" : 1360,
            "nonce" : 1829882407,
            "sender" : "NLLvsqs7AyBNmQT6NThUxYWDFwV5b1evaK",
            "netfee" : "234352"
         }
```
Transaction script contains malformed contract manifest (all methods
offsets are set to be 22, while the contract script lenght is 22):
```
{
   "name" : "Nep17Token",
   "groups" : [],
   "extra" : {
      "description" : "A Simple Nep-17 Contract",
      "email" : "developer@neo.org",
      "author" : "lazynode"
   },
   "permissions" : [
      {
         "contract" : "*",
         "methods" : "*"
      }
   ],
   "features" : {},
   "supportedstandards" : [
      "NEP-17"
   ],
   "abi" : {
      "events" : [
         {
            "parameters" : [
               {
                  "name" : "from",
                  "type" : "Hash160"
               },
               {
                  "type" : "Hash160",
                  "name" : "to"
               },
               {
                  "name" : "amount",
                  "type" : "Integer"
               }
            ],
            "name" : "Transfer"
         }
      ],
      "methods" : [
         {
            "safe" : true,
            "offset" : 22,
            "name" : "symbol",
            "returntype" : "String",
            "parameters" : []
         },
         {
            "returntype" : "Integer",
            "parameters" : [],
            "safe" : true,
            "offset" : 22,
            "name" : "decimals"
         },
         {
            "parameters" : [],
            "returntype" : "Integer",
            "name" : "totalSupply",
            "safe" : true,
            "offset" : 22
         },
         {
            "parameters" : [
               {
                  "name" : "owner",
                  "type" : "Hash160"
               }
            ],
            "returntype" : "Integer",
            "name" : "balanceOf",
            "offset" : 22,
            "safe" : true
         },
         {
            "name" : "transfer",
            "offset" : 22,
            "safe" : false,
            "parameters" : [
               {
                  "type" : "Hash160",
                  "name" : "from"
               },
               {
                  "name" : "to",
                  "type" : "Hash160"
               },
               {
                  "name" : "amount",
                  "type" : "Integer"
               },
               {
                  "name" : "data",
                  "type" : "Any"
               }
            ],
            "returntype" : "Boolean"
         }
      ]
   },
   "trusts" : []
}
```
2022-06-03 11:37:50 +03:00
..
block [#2442] English Check 2022-05-04 19:48:27 +03:00
blockchainer [#2442] English Check 2022-05-04 19:48:27 +03:00
chaindump [#2442] English Check 2022-05-04 19:48:27 +03:00
dao bigint: don't allocate in ToPreallocatedBytes 2022-06-02 15:38:39 +03:00
fee vm: add MODMUL and MODPOW opcodes 2022-05-12 14:25:14 +03:00
interop core: fix native NEO ABI 2022-06-03 11:37:41 +03:00
mempool [#2442] English Check 2022-05-04 19:48:27 +03:00
mempoolevent [#2442] English Check 2022-05-04 19:48:27 +03:00
mpt [#2442] English Check 2022-05-04 19:48:27 +03:00
native core: adjust contract script check on deploy 2022-06-03 11:37:50 +03:00
state state: optimize allocations in (*NEP17Transfer).EncodeBinary 2022-06-02 15:38:39 +03:00
stateroot core, rpc: support [invokefunction, invokescript, invokecontractverify]historic 2022-04-29 16:10:04 +03:00
statesync storage: drop (KeyPrefix).Bytes() API 2022-02-18 15:19:57 +03:00
storage core: avoid concurrent map r/w during SeekAsync 2022-05-16 12:25:15 +03:00
test_data core: refactor helper test contracts generation 2022-03-30 11:46:29 +03:00
transaction core: adjust notary-related attributes encoding 2022-06-01 15:09:06 +03:00
basic_chain_test.go core: adjust noderoles package usages 2022-06-01 15:03:29 +03:00
bench_test.go core: rebase core tests onto neotest 2022-03-30 19:00:53 +03:00
blockchain.go stackitem: reusable serialization context 2022-06-02 15:38:39 +03:00
blockchain_core_test.go core: use dao-binded cache for native contracts 2022-04-29 16:10:04 +03:00
blockchain_neotest_test.go core: adjust noderoles package usages 2022-06-01 15:03:29 +03:00
doc.go core: add Blockchain event subscription mechanism 2020-05-25 00:27:39 +03:00
helper_test.go core: rebase core tests onto neotest 2022-03-30 19:00:53 +03:00
interop_system.go core: rename hardfork HF_2712_FixSyscallFees 2022-05-26 14:20:48 +03:00
interop_system_core_test.go core: fix native NEO ABI 2022-06-03 11:37:41 +03:00
interop_system_neotest_test.go Merge pull request #2508 from nspcc-dev/snapshot-isolation 2022-05-27 12:44:06 +03:00
interops.go core: adjust System.Runtime.GetRandom 2022-05-26 14:20:12 +03:00
interops_test.go core: use dao-binded cache for native contracts 2022-04-29 16:10:04 +03:00
native_contract_test.go core: rebase core tests onto neotest 2022-03-30 19:00:53 +03:00
native_designate_test.go core: rebase core tests onto neotest 2022-03-30 19:00:53 +03:00
native_management_test.go *: refactor TestCreateBasicChain and its dependencies 2022-03-30 11:32:26 +03:00
native_neo_test.go core: rebase core tests onto neotest 2022-03-30 19:00:53 +03:00
native_policy_test.go core: rebase core tests onto neotest 2022-03-30 19:00:53 +03:00
notary_test.go core: adjust noderoles package usages 2022-06-01 15:03:29 +03:00
oracle_test.go [#2442] English Check 2022-05-04 19:48:27 +03:00
prometheus.go stateroot: move state-root related logic to core/stateroot 2021-03-09 13:48:29 +03:00
stateroot_test.go core, rpc: support [invokefunction, invokescript, invokecontractverify]historic 2022-04-29 16:10:04 +03:00
statesync_test.go *: refactor TestCreateBasicChain and its dependencies 2022-03-30 11:32:26 +03:00
util.go core: drop GetStandBy* methods 2022-01-31 23:14:38 +03:00
util_test.go core/block: add Nonce field to header 2021-07-15 15:58:49 +03:00