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

Fix storage snapshot sync #898

Merged

Conversation

cschuchardt88
Copy link
Member

Change Log

  • Fixed sync order

Note: DO NOT need to resync

Closes #897

superboyiii
superboyiii previously approved these changes Apr 12, 2024
Copy link
Member

@superboyiii superboyiii left a comment

Choose a reason for hiding this comment

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

Good job. Correct now.

Jim8y
Jim8y previously approved these changes Apr 12, 2024
src/ApplicationLogs/LogReader.cs Outdated Show resolved Hide resolved
src/ApplicationLogs/Store/NeoStore.cs Outdated Show resolved Hide resolved
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

The fix itself looks legit, let me test it.

vncoelho
vncoelho previously approved these changes Apr 12, 2024
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.

Good job,@cschuchardt88

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Fixed for the events with different triggers, but still not fixed for events with the same trigger. The updated code gives wrong hash for the Neo and Gas initial supply Transfer events (they have Management's hash in the contract field):
image
Here's the full updated getapplicationlog result for the genesis block:

anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "getapplicationlog", "params": ["0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15"] }' localhost:10332 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2725    0  2583  100   142   613k  34558 --:--:-- --:--:-- --:--:--  887k
{
   "id" : 1,
   "jsonrpc" : "2.0",
   "result" : {
      "blockhash" : "0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15",
      "executions" : [
         {
            "gasconsumed" : "0",
            "notifications" : [
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Deploy",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "ByteString",
                           "value" : "/aP6Q0bqUyolj8SX3a3bZDfJ/f8="
                        }
                     ]
                  }
               },
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Deploy",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "ByteString",
                           "value" : "wO85zuDk6SXGwqBqeeFEDdhvzqw="
                        }
                     ]
                  }
               },
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Deploy",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "ByteString",
                           "value" : "G/V1qxGJaIQTYQo1oSiGzeC2bHI="
                        }
                     ]
                  }
               },
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Deploy",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "ByteString",
                           "value" : "vvIEMUA2KnfBUJnH5kwS9wC2Zdo="
                        }
                     ]
                  }
               },
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Transfer",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "Any"
                        },
                        {
                           "type" : "ByteString",
                           "value" : "axI92L7HGGSIUrvHhZXjU2oFj58="
                        },
                        {
                           "type" : "Integer",
                           "value" : "100000000"
                        }
                     ]
                  }
               },
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Deploy",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "ByteString",
                           "value" : "9WPqQLwoPU0OBcSOowWz8qBzQO8="
                        }
                     ]
                  }
               },
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Transfer",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "Any"
                        },
                        {
                           "type" : "ByteString",
                           "value" : "axI92L7HGGSIUrvHhZXjU2oFj58="
                        },
                        {
                           "type" : "Integer",
                           "value" : "5200000000000000"
                        }
                     ]
                  }
               },
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Deploy",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "ByteString",
                           "value" : "z3bii9AGLEpHjuNVYQETGfPPpNI="
                        }
                     ]
                  }
               },
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Deploy",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "ByteString",
                           "value" : "e8aBwKH3HVQ0V7aLuo1fn91OXsw="
                        }
                     ]
                  }
               },
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Deploy",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "ByteString",
                           "value" : "4pXjkVRMF4rZTwPsTc3/eFNOz0k="
                        }
                     ]
                  }
               },
               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Deploy",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "ByteString",
                           "value" : "WIcXEX4KqBByr6tx0t2J/nxLkv4="
                        }
                     ]
                  }
               }
            ],
            "stack" : [],
            "trigger" : "OnPersist",
            "vmstate" : "HALT"
         },
         {
            "gasconsumed" : "0",
            "notifications" : [
               {
                  "contract" : "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                  "eventname" : "Transfer",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "Any"
                        },
                        {
                           "type" : "ByteString",
                           "value" : "lpSe1ILnxgqu7GkVUPGz1ZkUYZQ="
                        },
                        {
                           "type" : "Integer",
                           "value" : "50000000"
                        }
                     ]
                  }
               }
            ],
            "stack" : [],
            "trigger" : "PostPersist",
            "vmstate" : "HALT"
         }
      ]
   }
}

@AnnaShaleva
Copy link
Member

Good job. Correct now.

@superboyiii, am I doing something wrong? Are you sure you've got the correct result?

@superboyiii
Copy link
Member

Good job. Correct now.

@superboyiii, am I doing something wrong? Are you sure you've got the correct result?

My fault, wrong data was compared in test. Yes, the transfer event in OnPersist trigger should be for GAS and NEO, but not for 0xfffdc93764dbaddd97c48f252a53ea4643faa3fd(contract management) itself. @cschuchardt88
b07128561a78e300118a27a4fb9fcf1

@superboyiii superboyiii self-requested a review April 22, 2024 06:08
@cschuchardt88
Copy link
Member Author

@AnnaShaleva @superboyiii

All check out but the block with hash of 0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15 and index of 0.

The reason for this is because NeoSystem gets initialized before any Plugins get loaded.

For example block with hash of 0x8e1db6017a1205501a8689ff1657ff81d264bca2e4afba12f673a8e4bad6bad2 checks out valid.

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "blockhash": "0x8e1db6017a1205501a8689ff1657ff81d264bca2e4afba12f673a8e4bad6bad2",
        "executions": [
            {
                "trigger": "OnPersist",
                "vmstate": "HALT",
                "gasconsumed": "0",
                "stack": [],
                "notifications": [
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "axI92L7HGGSIUrvHhZXjU2oFj58="
                                },
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "Integer",
                                    "value": "17589000"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "UDiCgEgZdLrr634iF9YNyKdJeLo="
                                },
                                {
                                    "type": "Integer",
                                    "value": "7611220"
                                }
                            ]
                        }
                    }
                ]
            },
            {
                "trigger": "PostPersist",
                "vmstate": "HALT",
                "gasconsumed": "0",
                "stack": [],
                "notifications": [
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "lpSe1ILnxgqu7GkVUPGz1ZkUYZQ="
                                },
                                {
                                    "type": "Integer",
                                    "value": "50000000"
                                }
                            ]
                        }
                    }
                ]
            }
        ]
    }
}

@AnnaShaleva
Copy link
Member

All check out but the block with hash of 0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15 and index of 0.
The reason for this is because NeoSystem gets initialized before any Plugins get loaded.

@cschuchardt88, we need ApplicationLogs plugin to work correctly even for genesis block, it's important.

@cschuchardt88
Copy link
Member Author

cschuchardt88 commented Apr 22, 2024

@AnnaShaleva

This seems to be a problem with NeoSystem; the way plugins are loaded. I don't think genesis block requests block information from the network. What i see is happening; is that genesis block is initialized already before plugins get loaded and started. Maybe @Jim8y @shargon can you confirm?

@superboyiii @AnnaShaleva
notifyItem.ScriptHash is valid and i get 0xfffdc93764dbaddd97c48f252a53ea4643faa3fd. That data is coming from straight from BlockChain.OnCommitting event; IReadOnlyList<Blockchain.ApplicationExecuted> applicationExecutedList parameter.

var notifyItem = appExecution.Notifications[i];
logStore.PutContractState(notifyItem.ScriptHash, block.Timestamp, i, ContractLogState.Create(appExecution, notifyItem, stackItemStateIds));

@shargon
Copy link
Member

shargon commented Apr 22, 2024

What i see is happening; is that genesis block is initialized already before plugins get loaded and started.

foreach (var plugin in Plugin.Plugins)
    plugin.OnSystemLoaded(this);
Blockchain.Ask(new Blockchain.Initialize()).Wait();

It seems that the plugin is called before it

@cschuchardt88
Copy link
Member Author

cschuchardt88 commented Apr 22, 2024

@shargon any reason why 0xfffdc93764dbaddd97c48f252a53ea4643faa3fd ContractManagement contract would be the hash for OnPersist trigger?

@shargon
Copy link
Member

shargon commented Apr 23, 2024

@shargon any reason why 0xfffdc93764dbaddd97c48f252a53ea4643faa3fd ContractManagement contract would be the hash for OnPersist trigger?

I don't understand you, could you explain it? the hash for OnPersist?

@cschuchardt88
Copy link
Member Author

cschuchardt88 commented Apr 23, 2024

@shargon When I receive applicationExecutedList from on Blockchain.Committing event I get the NotifyEventArgs and when accessing NotifyEventArgs.ScriptHash I am getting 0xfffdc93764dbaddd97c48f252a53ea4643faa3fd not 0xd2a4cff31913016155e38e474a2c06d08be276cf. Any thoughts?

Correct response

                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "axI92L7HGGSIUrvHhZXjU2oFj58="
                                },
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "Integer",
                                    "value": "17589000"
                                }
                            ]
                        }
                    }

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

This is ready for merge.

I don't think so. #898 (review) and #898 (comment) is still not fixed.

@cschuchardt88
Copy link
Member Author

cschuchardt88 commented Apr 24, 2024

@AnnaShaleva @superboyiii Test again should be fixed now. There was a memory leak because the project isn't marked as nullable so when using a null ? and not making it ! after you get an object will have it keep overwriting/copying the same variable pointer when using out or ref.

Now I get:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "blockhash": "0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15",
        "executions": [
            {
                "trigger": "OnPersist",
                "vmstate": "HALT",
                "gasconsumed": "0",
                "stack": [],
                "notifications": [
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "/aP6Q0bqUyolj8SX3a3bZDfJ/f8="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "wO85zuDk6SXGwqBqeeFEDdhvzqw="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "G/V1qxGJaIQTYQo1oSiGzeC2bHI="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "vvIEMUA2KnfBUJnH5kwS9wC2Zdo="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "axI92L7HGGSIUrvHhZXjU2oFj58="
                                },
                                {
                                    "type": "Integer",
                                    "value": "100000000"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "9WPqQLwoPU0OBcSOowWz8qBzQO8="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "axI92L7HGGSIUrvHhZXjU2oFj58="
                                },
                                {
                                    "type": "Integer",
                                    "value": "5200000000000000"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "z3bii9AGLEpHjuNVYQETGfPPpNI="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "e8aBwKH3HVQ0V7aLuo1fn91OXsw="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "4pXjkVRMF4rZTwPsTc3/eFNOz0k="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "WIcXEX4KqBByr6tx0t2J/nxLkv4="
                                }
                            ]
                        }
                    }
                ]
            },
            {
                "trigger": "PostPersist",
                "vmstate": "HALT",
                "gasconsumed": "0",
                "stack": [],
                "notifications": [
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "lpSe1ILnxgqu7GkVUPGz1ZkUYZQ="
                                },
                                {
                                    "type": "Integer",
                                    "value": "50000000"
                                }
                            ]
                        }
                    }
                ]
            }
        ]
    }
}

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Now I get:

Your result is still not correct. All Deploy notifications have invalid contract hash, and also one Transfer notification has invalid contract hash. The expected result is attached in the "Expected behaviour" section of #897.

@superboyiii
Copy link
Member

superboyiii commented Apr 25, 2024

@cschuchardt88 You could always check original one by v3.6.2 RPC:

curl -X POST http://seed1.neo.org:10332 -d '{"jsonrpc":"2.0","method":"getapplicationlog","params":["0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15"],"id":1}'

Your current result mistakenly got wrong contract hash for NEO(Not GAS). As we all know 100000000 NEO and 52000000 GAS has been transferred into consensus multisig address in genesis block. That's where these 2 transfer events from.

@cschuchardt88
Copy link
Member Author

@AnnaShaleva @superboyiii

My bad forgot to commit.

http://seed1.neo.org:10332

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "blockhash": "0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15",
        "executions": [
            {
                "trigger": "OnPersist",
                "vmstate": "HALT",
                "gasconsumed": "0",
                "stack": [],
                "notifications": [
                    {
                        "contract": "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "axI92L7HGGSIUrvHhZXjU2oFj58="
                                },
                                {
                                    "type": "Integer",
                                    "value": "100000000"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "axI92L7HGGSIUrvHhZXjU2oFj58="
                                },
                                {
                                    "type": "Integer",
                                    "value": "5200000000000000"
                                }
                            ]
                        }
                    }
                ]
            },
            {
                "trigger": "PostPersist",
                "vmstate": "HALT",
                "gasconsumed": "0",
                "stack": [],
                "notifications": [
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "lpSe1ILnxgqu7GkVUPGz1ZkUYZQ="
                                },
                                {
                                    "type": "Integer",
                                    "value": "50000000"
                                }
                            ]
                        }
                    }
                ]
            }
        ]
    }
}

http://127.0.0.1:10332

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "blockhash": "0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15",
        "executions": [
            {
                "trigger": "OnPersist",
                "vmstate": "HALT",
                "gasconsumed": "0",
                "stack": [],
                "notifications": [
                    {
                        "contract": "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "/aP6Q0bqUyolj8SX3a3bZDfJ/f8="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "wO85zuDk6SXGwqBqeeFEDdhvzqw="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "G/V1qxGJaIQTYQo1oSiGzeC2bHI="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "vvIEMUA2KnfBUJnH5kwS9wC2Zdo="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "axI92L7HGGSIUrvHhZXjU2oFj58="
                                },
                                {
                                    "type": "Integer",
                                    "value": "100000000"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "9WPqQLwoPU0OBcSOowWz8qBzQO8="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "axI92L7HGGSIUrvHhZXjU2oFj58="
                                },
                                {
                                    "type": "Integer",
                                    "value": "5200000000000000"
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "z3bii9AGLEpHjuNVYQETGfPPpNI="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "e8aBwKH3HVQ0V7aLuo1fn91OXsw="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "4pXjkVRMF4rZTwPsTc3/eFNOz0k="
                                }
                            ]
                        }
                    },
                    {
                        "contract": "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                        "eventname": "Deploy",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "ByteString",
                                    "value": "WIcXEX4KqBByr6tx0t2J/nxLkv4="
                                }
                            ]
                        }
                    }
                ]
            },
            {
                "trigger": "PostPersist",
                "vmstate": "HALT",
                "gasconsumed": "0",
                "stack": [],
                "notifications": [
                    {
                        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                        "eventname": "Transfer",
                        "state": {
                            "type": "Array",
                            "value": [
                                {
                                    "type": "Any"
                                },
                                {
                                    "type": "ByteString",
                                    "value": "lpSe1ILnxgqu7GkVUPGz1ZkUYZQ="
                                },
                                {
                                    "type": "Integer",
                                    "value": "50000000"
                                }
                            ]
                        }
                    }
                ]
            }
        ]
    }
}


namespace ApplicationLogs.Store.Models
{
public class BlockchainEventModel
{
public UInt160 ScriptHash { get; private init; } = UInt160.Zero;
public UInt160 ScriptHash { get; private init; } = new();
Copy link
Member

Choose a reason for hiding this comment

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

Why create a new empty instance if we have one in memory?

Copy link
Member Author

@cschuchardt88 cschuchardt88 Apr 30, 2024

Choose a reason for hiding this comment

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

Its a memory leak. That's the reason why we had this problem with different addresses in the state. It uses the class instance of UInt160.Zero when doing ScriptHash.Deserialize(). It will keep writing to the same buffer; overwriting the previous value. So i need a new instance either way.

Copy link
Member

Choose a reason for hiding this comment

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

If we reuse the same instance, how can be a memory leak?

Copy link
Member Author

@cschuchardt88 cschuchardt88 May 2, 2024

Choose a reason for hiding this comment

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

@shargon we are using the same instance. That was the problem. The instance being UInt160.Zero; overwriting it for each method call.

@cschuchardt88
Copy link
Member Author

@AnnaShaleva @superboyiii any update on testing the state?

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Checked the updated version, seems to work correctly now.

Copy link
Member

@superboyiii superboyiii left a comment

Choose a reason for hiding this comment

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

Looks good from my local results.

@superboyiii superboyiii merged commit d1b03b6 into neo-project:master May 6, 2024
4 checks passed
@cschuchardt88 cschuchardt88 deleted the getapplicationLog-rpc-fix branch May 6, 2024 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Malformed getapplicationlog RPC request result
6 participants