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

Emit "Deploy" notification for native contracts #2834

Closed
roman-khimov opened this issue Dec 7, 2022 · 6 comments
Closed

Emit "Deploy" notification for native contracts #2834

roman-khimov opened this issue Dec 7, 2022 · 6 comments
Labels
discussion Initial issue state - proposed but not yet accepted
Milestone

Comments

@roman-khimov
Copy link
Contributor

Summary or problem description
Native contracts are deployed by ContractManagement's OnPersist method, but what this method does is just pushing contract state to the DB. For regular contracts we have events generated as well since #2150, while there are no such events for native contracts. Of course they're not critical as of now, we know these contracts well and they're only changed at the genesis block, however this makes native contracts somewhat inconsistent with the regular ones and also can be a problem if we're to ever use NativeUpdateHistory feature with updates made to native contracts at some non-zero blocks.

Do you have any solution you want to propose?
Emit "Deploy"/"Update" events for native contracts.

Neo Version

  • Neo 3

Where in the software does this update applies to?

  • ContractManagement native contract
@roman-khimov roman-khimov added the discussion Initial issue state - proposed but not yet accepted label Dec 7, 2022
@roman-khimov roman-khimov added this to the v3.7.0 milestone Nov 16, 2023
@roman-khimov
Copy link
Contributor Author

Looks like this was fixed in #2942.

@shargon
Copy link
Member

shargon commented Mar 5, 2024

@roman-khimov close?

@roman-khimov
Copy link
Contributor Author

It'd be perfect if anyone with the current master node and ApplicationLogs (@superboyiii?) could check that the event is indeed present where we expect it (genesis block persist). The code is very convincing to me, but still a quick check before closing won't hurt.

@AnnaShaleva
Copy link
Member

I've checked the current master (b05501af882a0d1f2a1a7841c6ddc4d0504e5fc1), the genesis application log for OnPersist trigger contains required Deploy notifications for all 9 contracts, so it works as expected. It also contains required Transfer events.

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"
         }
      ]
   }
}

Just for the record, here's Base64-encoded hashes of native contracts retrieved from Go script:

ContractManagement: /aP6Q0bqUyolj8SX3a3bZDfJ/f8=
LedgerContract: vvIEMUA2KnfBUJnH5kwS9wC2Zdo=
NeoToken: 9WPqQLwoPU0OBcSOowWz8qBzQO8=
GasToken: z3bii9AGLEpHjuNVYQETGfPPpNI=
PolicyContract: e8aBwKH3HVQ0V7aLuo1fn91OXsw=
OracleContract: WIcXEX4KqBByr6tx0t2J/nxLkv4=
RoleManagement: 4pXjkVRMF4rZTwPsTc3/eFNOz0k=
Notary: O+w1MRGbutdt0ESSCw3mwxlP4cE=
CryptoLib: G/V1qxGJaIQTYQo1oSiGzeC2bHI=
StdLib: wO85zuDk6SXGwqBqeeFEDdhvzqw=

And also if needed, then here's the current application logs (for OnPersist and PostPersist) for the current mainnet genesis block:

anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "getapplicationlog", "params": ["0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15"] }' http://seed1.neo.org:10332 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1150    0  1008  100   142   2424    341 --:--:-- --:--:-- --:--:--  2764
{
   "id" : 1,
   "jsonrpc" : "2.0",
   "result" : {
      "blockhash" : "0x1f4d1defa46faa5e7b9b8d3f79a06bec777d7c26c4aa5f6f5899a291daa87c15",
      "executions" : [
         {
            "gasconsumed" : "0",
            "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"
                        }
                     ]
                  }
               }
            ],
            "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

So this issue can be closed as completed.

@roman-khimov
Copy link
Contributor Author

               {
                  "contract" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
                  "eventname" : "Deploy",
                  "state" : {
                     "type" : "Array",
                     "value" : [
                        {
                           "type" : "ByteString",
                           "value" : "/aP6Q0bqUyolj8SX3a3bZDfJ/f8="
                        }
                     ]
                  }
               },

Contract 0xfffdc93764dbaddd97c48f252a53ea4643faa3fd says it has deployed contract 0xfffdc93764dbaddd97c48f252a53ea4643faa3fd, nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Initial issue state - proposed but not yet accepted
Projects
None yet
Development

No branches or pull requests

3 participants