Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward port from 2.x #1188

Merged
merged 5 commits into from
Jul 17, 2020
Merged

Forward port from 2.x #1188

merged 5 commits into from
Jul 17, 2020

Conversation

roman-khimov
Copy link
Member

Problem

2.x branch has accumulated some useful changes.

Solution

Forward-port them to master.

@roman-khimov roman-khimov added this to the v0.91.0 milestone Jul 16, 2020
@@ -138,6 +138,8 @@ func contractUpdate(ic *interop.Context, v *vm.VM) error {
if len(siMap) != 0 {
return errors.New("old contract shouldn't have storage")
}
} else if !newcontract.ScriptHash().Equals(contract.ScriptHash()) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm now thinking about the necessity of this check. We have the same one just 20 lines above in case if the script of the new contract isn't' nil, and it returns an error if so. It's technically possible that new script is nil, but shouldn't we return an error in this case (although C# does not)? It seemed to me strange that we can process contracts without script.

Or if the original C# idea was to provide either [new script] or [new manifest] or [new script and manifest] and update only provided values, we don't have matching behavior, because createContractStateFromVM assumes that manifest is required (and C# do not, they have two checks for null: for script and manifest, see https://github.com/neo-project/neo/blob/master/src/neo/SmartContract/ApplicationEngine.Contract.cs#L78).

So, could you, please, clarify the way this method should work?

Fixes #1144. It's quite simple approach, we just update balance info right
upon contract migration. It will slow down migration transactions, but it
takes about 1-2 seconds to Seek through balances at mainnet's 3.8M, so the
approach should still work good enough. The other idea was to make lazy
updates (maintaining contract migration map), but it's more complicated to
implement (and implies that a balance get might also do a write).

There also is a concern about memory usage, it can give a spike of some tens
of megabytes, but that also is considered to be acceptable.
We can't lock them (or there will be a deadlock), but we need to fix this:

fatal error: concurrent map iteration and map write

goroutine 1 [running]:
runtime.throw(0xdec086, 0x26)
        /usr/lib64/go/1.12/src/runtime/panic.go:617 +0x72 fp=0xc02fec2bf8 sp=0xc02fec2bc8 pc=0x42d932
runtime.mapiternext(0xc02fec2d40)
        /usr/lib64/go/1.12/src/runtime/map.go:860 +0x597 fp=0xc02fec2c80 sp=0xc02fec2bf8 pc=0x40efe7
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Shutdown(0xc0000fc160)
        /home/rik/dev/neo-go2/pkg/network/server.go:194 +0x238 fp=0xc02fec2db0 sp=0xc02fec2c80 pc=0xa89da8
github.com/nspcc-dev/neo-go/cli/server.startServer(0xc0000fcc60, 0x0, 0x0)
        /home/rik/dev/neo-go2/cli/server/server.go:399 +0x7a9 fp=0xc02fec3820 sp=0xc02fec2db0 pc=0xae2079
...
@codecov
Copy link

codecov bot commented Jul 17, 2020

Codecov Report

Merging #1188 into master will decrease coverage by 0.08%.
The diff coverage is 42.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1188      +/-   ##
==========================================
- Coverage   67.00%   66.92%   -0.09%     
==========================================
  Files         199      199              
  Lines       16919    16971      +52     
==========================================
+ Hits        11336    11357      +21     
- Misses       4978     5005      +27     
- Partials      605      609       +4     
Impacted Files Coverage Δ
pkg/network/server.go 26.85% <0.00%> (ø)
pkg/core/dao/cacheddao.go 66.91% <34.04%> (-17.54%) ⬇️
pkg/core/interop_neo.go 73.33% <100.00%> (+0.22%) ⬆️
pkg/rpc/request/param.go 92.36% <100.00%> (+0.27%) ⬆️
pkg/rpc/server/server.go 79.18% <100.00%> (ø)

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 3f2f0be...432cef5. Read the comment docs.

@roman-khimov roman-khimov merged commit 1154e18 into master Jul 17, 2020
@roman-khimov roman-khimov deleted the forward-port-from-2.x branch July 17, 2020 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants