Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Revert some checks for 2.x #140

Merged
merged 5 commits into from
Apr 29, 2019

Conversation

shargon
Copy link
Member

@shargon shargon commented Apr 22, 2019

Version 2.10.1 have differences with the storages, so i think that we should revert all of these new verifications that not exists previously on 2.9.x

TODO: We should test if the problem is solved with these patch

@codecov-io
Copy link

codecov-io commented Apr 22, 2019

Codecov Report

Merging #140 into master-2.x will decrease coverage by 0.14%.
The diff coverage is 100%.

Impacted file tree graph

@@              Coverage Diff               @@
##           master-2.x     #140      +/-   ##
==============================================
- Coverage       80.54%   80.39%   -0.15%     
==============================================
  Files              45       45              
  Lines            4580     4545      -35     
==============================================
- Hits             3689     3654      -35     
  Misses            891      891
Impacted Files Coverage Δ
src/neo-vm/ExecutionEngine.cs 99.56% <100%> (-0.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb5d6c9...4ba0cde. Read the comment docs.

@vncoelho
Copy link
Member

@shargon and @jsolman, give me some couple of days.
I am currently checking the master2.x against 2.9.5 for testnet.

@vncoelho
Copy link
Member

Current branch 2.x still has problems, I will check this one now.

@vncoelho
Copy link
Member

In addition, @shargon, we are also going to include comparison of application logs.

@erikzhang
Copy link
Member

@RavenXce
Copy link

RavenXce commented Apr 23, 2019

May I know which storages (mainnet/testnet) are being checked for consistency, and how?

Because storage isolation and interop name hashing will likely cause the mainnet storages to not be exactly the same when re-synced from beginning.

For example, we ran some functions on mainnet assuming that the name hashing feature is enabled before it actually was. This means that a full re-resync will never be able to get back the same storage state (previously fail, now pass), unless some sort of start-block flag is for these features. The same goes for NEP-8 op-codes.

We abandoned addresses and contracts that used these features before they were actually running on consensus nodes, to minimize actual application issues.

@igormcoelho
Copy link
Contributor

igormcoelho commented Apr 23, 2019

@RavenXce you are correct in this point, but we are testing over the time where these features were included to the chain, so these past events will actually pass, like you explained. So, the changes we are looking for now are much more subtle, related to very recent updates on vm limits checking and similar stuff.
The final solution will come in short term with the adoption of Merkle Patricia to handle storage and application hashes, so that after this point, hashes will rule the definitive state of these side storages. We are already discussing this here: neo-project/neo#528

NeoResearch "official" database regarding storage is this one: https://github.com/neoresearch/neo-storage-audit
This one has never changed since we started creating the audits.

@RavenXce
Copy link

RavenXce commented Apr 23, 2019

@igormcoelho okay sure, saw this issue and just wanted to make sure that you guys aren't wasting time looking at the wrong things. Thanks for making sure the vm changes are non-breaking! 👍

vncoelho
vncoelho previously approved these changes Apr 23, 2019
Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shargon, this surely allows some failed storage persistence to happen again.
I did not investigate if that would be right or not, since it is a revert that covers from 2.10.0 to 2.10.1.

Historically, even if we compare different versions, such as 2.9.4 to 2.9.10, there might differences somewhere.

@vncoelho vncoelho dismissed their stale review April 23, 2019 19:43

I am still afraid this is reverting more than necessary

@vncoelho
Copy link
Member

Here is the first storage diff on Testnet:
This patch:
image

Client 2.9.4 (the same in 2.10.0):
image

@shargon
Copy link
Member Author

shargon commented Apr 26, 2019

After a lot of hours of research, we found that PICKITEM previously doesn't accept integers neither byteArrays, we introduce this feature on shargon@e615bf5#diff-76ae2659301a783b97ae4c99999464ccR1269

This produce a difference with the block (testnet) {{ "block": 460271, "size": 1, "storage": [ { "state": "Added", "key": "26b16223ae5418cd0d01b8f20ae51022fa13c0e3696e666c6174696f6e5261746500000003", "value": "00010200" } ] }} because the TX (0x836487ae75e331fa53ccd4bc2a1674fbbd4d732143d2fe43648ffa753e66a1ea) in 2.9.4 cause a FAULT, without storage changes, and with 2.10.1 we store a new value.

image

Previously the code was like this: https://github.com/shargon/neo-vm/blob/663e9c8583e9919adbdb88896e42711e8715a69e/src/neo-vm/ExecutionEngine.cs#L1253

Thanks @vncoelho for your amazing work :)

@shargon
Copy link
Member Author

shargon commented Apr 26, 2019

There are more differences

image

2.10.1 [FAULT]

{{
  "block": 1568312,
  "size": 2,
  "storage": [
    {
      "state": "Changed",
      "key": "1bc123aa6ac42f73075ffda3da7c396263d5f5d723c73353261ed22a9a8766d0b1bbd68d0072a80c3f0000000000000000000000000c",
      "value": "0005009699000200"
    },
    {
      "state": "Added",
      "key": "1bc123aa6ac42f73075ffda3da7c396263d5f5d71cbca158f62258e7f79004c275e25ea700369fca9d0000000000000000000000000c",
      "value": "000400ca9a3b00"
    }
  ]
}}

2.9.4

{{
  "block": 1568312,
  "size": 7,
  "storage": [
    {
      "state": "Changed",
      "key": "218399fea119811f82f8a80a0ce0dd90a65f569d6b5eee56b5e5919c8e15706a9d48b79300719f2dda4a9091137e2026ef04feeeed0081899a37cded1e59000000000000000008",
      "value": "0005f04c3ba40b00"
    },
    {
      "state": "Changed",
      "key": "218399fea119811f82f8a80a0ce0dd90a65f569d6b5eee56b5e5919c8e15706a9d48b79300719f2dda9083b425bf81e44316cc729a005477d34e85535115000000000000000008",
      "value": "0005001a71180200"
    },
    {
      "state": "Changed",
      "key": "218399fea119811f82f8a80a0ce0dd90a65f569d1a1af8a9f46ebcaa47f3b2f967dd7bf60006d893169083b425bf81e44316cc729a005477d34e85535115000000000000000008",
      "value": "0005000c77420300"
    },
    {
      "state": "Changed",
      "key": "218399fea119811f82f8a80a0ce0dd90a65f569d6b5eee56b5e5919c8e15706a9d48b79300719f2ddae72d286979ee6cb1b7e65dfd00dfb2e384100b8d148e7758de42e4168b0071792c600000000000000000000000000c",
      "value": "000460774c7700"
    },
    {
      "state": "Added",
      "key": "218399fea119811f82f8a80a0ce0dd90a65f569d4a9091137e2026ef04feeeed81899a3700cded1e59fc00000000000000000000000b",
      "value": "0010401f000000000000d00700000000000000"
    },
    {
      "state": "Changed",
      "key": "1bc123aa6ac42f73075ffda3da7c396263d5f5d723c73353261ed22a9a8766d0b1bbd68d0072a80c3f0000000000000000000000000c",
      "value": "0005009699000200"
    },
    {
      "state": "Added",
      "key": "1bc123aa6ac42f73075ffda3da7c396263d5f5d71cbca158f62258e7f79004c275e25ea700369fca9d0000000000000000000000000c",
      "value": "000400ca9a3b00"
    }
  ]
}}

@shargon
Copy link
Member Author

shargon commented Apr 27, 2019

The difference for block 1568312 is SUBSTR

image

and before was like:

case OpCode.SUBSTR:
{
int count = (int)context.EvaluationStack.Pop().GetBigInteger();
if (count < 0)
{
State |= VMState.FAULT;
return;
}
int index = (int)context.EvaluationStack.Pop().GetBigInteger();
if (index < 0)
{
State |= VMState.FAULT;
return;
}
byte[] x = context.EvaluationStack.Pop().GetByteArray();
context.EvaluationStack.Push(x.Skip(index).Take(count).ToArray());
}

@shargon
Copy link
Member Author

shargon commented Apr 27, 2019

Whole testnet without issues now! @vncoelho could you confirm?

@vncoelho
Copy link
Member

vncoelho commented Apr 27, 2019

Great job, @shargon's brother.
It was surely and arduous task. Thanks for hunting it with care.
I may need 2 days but I will soon confirm it.

@superboyiii
Copy link
Member

Amazing work! I'll test it, too. @shargon

@erikzhang
Copy link
Member

@vncoelho @superboyiii Did you finish your tests?

@vncoelho
Copy link
Member

Still under evaluation. Some more couple of hours and it will be finished.

@vncoelho
Copy link
Member

vncoelho commented Apr 29, 2019

Compared to 2.9.4 still differs:

In 2.9.4 Testnet we have 1Changed + 3 Added

{"block":759289,"size":4,"storage":[{"state":"Changed","key":"855b8152706e8beb3e3aa4188160a2262a04c85062616c616e63654f700000000000000007","value":"000410460afa00"}
{"state":"Added","key":"855b8152706e8beb3e3aa4188160a2262a04c85070ba03f52af8153d0cc1c781477b8c2600ce05b89c0000000000000000000000000c","value":"0002102700"}
{"state":"Added","key":"855b8152706e8beb3e3aa4188160a2262a04c850746f74616c537570706c79000000000005","value":"0002102700"}
{"state":"Added","key":"855b8152706e8beb3e3aa4188160a2262a04c850747275650000000000000000000000000c","value":"00047472756500"}]}

While in this current branch we also have this storage ( 1Changed + 3 Added + 1 Added):

{"state":"Added","key":"855b8152706e8beb3e3aa4188160a2262a04c85064656661756c7400000000000000000009","value":"001544656661756c7420726573756c742068657265212100"}]}

@vncoelho
Copy link
Member

Compared to 2.10.0 it looks like to be exactly the same. Great job @shargon.
Some more couple of hours and let me double check and I am going to approve.
About 2.9.4 we check later.

@shargon
Copy link
Member Author

shargon commented Apr 29, 2019

could you confirm the 2.9.4 differences?

@vncoelho
Copy link
Member

I posted it above, @shargon.

Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared to 2.10.0 it is exactly the same.
A temporally .zip with the storages for testnet can be download here: https://www.dropbox.com/s/44w5o0k9gpp7ybv/Storage_2.10.2.zip?dl=0
1GB but only 89MB when zipped! O.o

@vncoelho
Copy link
Member

Let's continue the tests on PR138.

@vncoelho vncoelho merged commit 0d13635 into neo-project:master-2.x Apr 29, 2019
@vncoelho
Copy link
Member

vncoelho commented Apr 29, 2019

@jsolman, this current branch may solve any compatibility problem that were experienced in early versions of 2.10.1.
However, we are still going to research further in order to comprehend key historical changes, as a matter of report. But, surely, nothing critical.

@jsolman
Copy link

jsolman commented Apr 30, 2019

I finished syncing MainNet and the results for balances look good after these changes.

@superboyiii
Copy link
Member

The same to mine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants