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

Malformed getapplicationlog RPC request result #897

Closed
AnnaShaleva opened this issue Apr 11, 2024 · 1 comment · Fixed by #898
Closed

Malformed getapplicationlog RPC request result #897

AnnaShaleva opened this issue Apr 11, 2024 · 1 comment · Fixed by #898
Assignees
Labels
bug Something isn't working

Comments

@AnnaShaleva
Copy link
Member

Describe the bug
While testing the nspcc-dev/neo-go#3402, I discovered that ApplicationLogs plugin returns improper result of getapplicationlog RPC call. The result contains wrong contract field value of notifications section. For example, getapplicationlog for genesis block of mainnet has exactly the same notification's contract hash for all notificaitons (for both OnPersist and PostPersist triggers), 0xd2a4cff31913016155e38e474a2c06d08be276cf (native GasToken). While I'd expect contract hashes of notifications to have proper values.

This bug was introduced in master after 20th of March, because in that day I successfully built neo-modules master and checked genesis block notifications within the scope of neo-project/neo#2834 (comment). I'm suspecting that this bug was introduced by #865, because this PR was merged 21th of March and makes a lot of changes in ApplicationLogs plugin, but we need to check.

To Reproduce
Steps to reproduce the behavior:

  1. Build fresh neo-modules master and fresh NeoCLI;
  2. Run NeoCLI with RPCServer and ApplicationLogs plugin enabled and start mainnet sync from genesis;
  3. Send getapplicationlog RPC request to RPC server with genesis block hash;
  4. Check the result.

The result from the fresh master is:

anna@kiwi:~/Documents/GitProjects/neo-project/neo/src/Neo.CLI/bin/Release/net8.0/linux-x64$ 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  49590   2726 --:--:-- --:--:-- --:--:-- 52403
{
   "id" : 1,
   "jsonrpc" : "2.0",
   "result" : {
      "blockhash" : "0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15",
      "executions" : [
         {
            "gasconsumed" : "0",
            "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="
                        }
                     ]
                  }
               }
            ],
            "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"
         }
      ]
   }
}

Expected behavior
The expected result is mentioned in neo-project/neo#2834 (comment), it should have proper contract hashes for all genesis notifications:

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   644k  36298 --:--:-- --:--:-- --:--:--  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" : "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="
                        }
                     ]
                  }
               }
            ],
            "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"
         }
      ]
   }
}

Platform:

  • Version:
    • core: 3a12f3dd4d1400e842d58a12f0057607627e511e
    • modules: 66573ed

(Optional) Additional context

This bug is critical for 3.7, should be solved before the release.

@AnnaShaleva AnnaShaleva changed the title New ApplicationLogs plugin implementation returns malformed contract hashes Malformed getapplicationlog RPC request result Apr 11, 2024
@AnnaShaleva AnnaShaleva added the bug Something isn't working label Apr 11, 2024
@cschuchardt88 cschuchardt88 self-assigned this Apr 11, 2024
@cschuchardt88
Copy link
Member

The cache is getting overwritten when using IStore.GetSnapshot with leveldb. Ill get a workaround going...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants