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

Add role designation history #2007

Merged
merged 28 commits into from
Nov 3, 2020

Conversation

ZhangTao1596
Copy link
Contributor

@ZhangTao1596 ZhangTao1596 commented Oct 15, 2020

I make this pr to let DesignateContract record historical role designation. So users can verify old messages.
Changes:

  • DesignateContract add height and nodes when call DesignateAsRole
  • Add GetDesignatedByRoleAndIndex to return designated nodes at specific index

@erikzhang @shargon @Tommo-L Please have a look.

@ZhangTao1596 ZhangTao1596 changed the title Fix role designate history Add role designation history Oct 15, 2020
@shargon
Copy link
Member

shargon commented Oct 15, 2020

Why do you want to verify old messages in the present, if they was verified already in the past?

@ZhangTao1596
Copy link
Contributor Author

ZhangTao1596 commented Oct 15, 2020

Why do you want to verify old messages in the present, if they was verified already in the past?

Not all messages signed by designated nodes saved in block, so these messages will not be sync with blockchain snapshot.
Take StateRoot for example, a node may receive StateRoot with index 100 when it already have sync block at 1000, It can't verify StateRoot with current snapshot. Designated nodes may change.

@shargon
Copy link
Member

shargon commented Oct 15, 2020

Wait for #1988 we need to store the history in different keys.

@roman-khimov
Copy link
Contributor

Take StateRoot for example, a node may receive StateRoot with index 100 when it already have sync block at 1000, It can't verify StateRoot with current snapshot. Designated nodes may change.

Hmm... What if we're to include state root hash in the block header?

@ZhangTao1596
Copy link
Contributor Author

Hmm... What if we're to include state root hash in the block header?

Only considering state root, if we put it into header, we do not need this.

@ProDog
Copy link
Contributor

ProDog commented Oct 19, 2020

If there are two designate transactions in one block, can only get the last one?

@ZhangTao1596
Copy link
Contributor Author

If there are two designate transactions in one block, can only get the last one?

What do you mean the last one?

@ProDog
Copy link
Contributor

ProDog commented Oct 19, 2020

What do you mean the last one?

The last transaction's history.

@ZhangTao1596
Copy link
Contributor Author

What do you mean the last one?

The last transaction's history.

Yes. Because designate transaction decide who are the nodes as specific role of next block. The last designate tx in same block will cover the previous.

@ProDog
Copy link
Contributor

ProDog commented Oct 20, 2020

Tested OK.

neo> designate [{"type":"Integer","value":8},{"type":"Array","value":[{"type":"PublicKey","value":"02a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b"},{"type":"PublicKey","value":"028bd1902c4d1419f002b821e6de653ddfd5358063208e426756398be6ffa3aac8"},{"type":"PublicKey","value":"0222d8515184c7d62ffa99b829aeb4938c4704ecb0dd7e340e842e9df121826343"},{"type":"PublicKey","value":"02a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b"},{"type":"PublicKey","value":"02a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b"}]}] 0xe19de267a37a71734478f512b3e92c79fc3695fa 0xe19de267a37a71734478f512b3e92c79fc3695fa
Invoking script with: 'DCECqepoQswMs7DyMXsHyFDePR4rJDqY7S1Wo/9MpmqvMwsMIQKp6mhCzAyzsPIxewfIUN49HiskOpjtLVaj/0ymaq8zCwwhAiLYUVGEx9Yv+pm4Ka60k4xHBOyw3X40DoQunfEhgmNDDCECi9GQLE0UGfACuCHm3mU939U1gGMgjkJnVjmL5v+jqsgMIQKp6mhCzAyzsPIxewfIUN49HiskOpjtLVaj/0ymaq8zCxXAGBLADA9kZXNpZ25hdGVBc1JvbGUMFGYmxmjw6Aa+yKJodaaguz7P/jp2QWJ9W1I='
VM State: HALT
Gas Consumed: 0.0101553
Result Stack: [{"type":"Boolean","value":true}]
Relay tx(no|yes): yes
Signed and relayed transaction with hash=0xc49bfc15ae51158ce758d334b6b844d5de976a4098e4994d34a1e84a227951e5

neo> designate [{"type":"Integer","value":8},{"type":"Array","value":[{"type":"PublicKey","value":"02a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b"}]}] 0xe19de267a37a71734478f512b3e92c79fc3695fa 0xe19de267a37a71734478f512b3e92c79fc3695fa
Invoking script with: 'DCECqepoQswMs7DyMXsHyFDePR4rJDqY7S1Wo/9MpmqvMwsRwBgSwAwPZGVzaWduYXRlQXNSb2xlDBRmJsZo8OgGvsiiaHWmoLs+z/46dkFifVtS'
VM State: HALT
Gas Consumed: 0.0101481
Result Stack: [{"type":"Boolean","value":true}]
Relay tx(no|yes): yes
Signed and relayed transaction with hash=0x2ff1b554b3412db1e80a06a02005d393dfc366be622861837925ee4f30b0f69a

neo> get designated by index 8 86
Invoking script with: 'AFYYEsAMG2dldERlc2lnbmF0ZWRCeVJvbGVBbmRJbmRleAwUZibGaPDoBr7Iomh1pqC7Ps/+OnZBYn1bUg=='
VM State: HALT
Gas Consumed: 0.0200763
Designated:
02a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b
028bd1902c4d1419f002b821e6de653ddfd5358063208e426756398be6ffa3aac8
0222d8515184c7d62ffa99b829aeb4938c4704ecb0dd7e340e842e9df121826343
02a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b
02a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b

neo> designate [{"type":"Integer","value":8},{"type":"Array","value":[{"type":"PublicKey","value":"0222d8515184c7d62ffa99b829aeb4938c4704ecb0dd7e340e842e9df121826343"}]}] 0xe19de267a37a71734478f512b3e92c79fc3695fa 0xe19de267a37a71734478f512b3e92c79fc3695fa
Invoking script with: 'DCECIthRUYTH1i/6mbgprrSTjEcE7LDdfjQOhC6d8SGCY0MRwBgSwAwPZGVzaWduYXRlQXNSb2xlDBRmJsZo8OgGvsiiaHWmoLs+z/46dkFifVtS'
VM State: HALT
Gas Consumed: 0.0101481
Result Stack: [{"type":"Boolean","value":true}]
Relay tx(no|yes): yes
Signed and relayed transaction with hash=0x2ffc8aeafcdc0b55f3c1964737249742304536a3087ca2292df067cefe94ae24

neo> designate [{"type":"Integer","value":8},{"type":"Array","value":[{"type":"PublicKey","value":"02a9ea6842cc0cb3b0f2317b07c850de3d1e2b243a98ed2d56a3ff4ca66aaf330b"}]}] 0xe19de267a37a71734478f512b3e92c79fc3695fa 0xe19de267a37a71734478f512b3e92c79fc3695fa
Invoking script with: 'DCECqepoQswMs7DyMXsHyFDePR4rJDqY7S1Wo/9MpmqvMwsRwBgSwAwPZGVzaWduYXRlQXNSb2xlDBRmJsZo8OgGvsiiaHWmoLs+z/46dkFifVtS'
VM State: HALT
Gas Consumed: 0.0101481
Result Stack: [{"type":"Boolean","value":true}]
Relay tx(no|yes): yes
Signed and relayed transaction with hash=0x828b8c62600221acce344554d2c1f95dd448e246e25e4c19cabbea85801d8ccd

neo> get designated by index 8 94
Invoking script with: 'AF4YEsAMG2dldERlc2lnbmF0ZWRCeVJvbGVBbmRJbmRleAwUZibGaPDoBr7Iomh1pqC7Ps/+OnZBYn1bUg=='
VM State: HALT
Gas Consumed: 0.0200763
Designated:
0222d8515184c7d62ffa99b829aeb4938c4704ecb0dd7e340e842e9df121826343

shargon
shargon previously approved these changes Oct 27, 2020
shargon
shargon previously approved these changes Nov 1, 2020
shargon
shargon previously approved these changes Nov 2, 2020
@shargon shargon merged commit 1d4db2c into neo-project:master Nov 3, 2020
@ZhangTao1596 ZhangTao1596 deleted the fix-role-designate-history branch November 4, 2020 01:46
roman-khimov added a commit to nspcc-dev/neo-go that referenced this pull request Nov 5, 2020
Follow neo-project/neo#2007. Fix getDesignatedByRole price along the way.
roman-khimov added a commit to nspcc-dev/neo-go that referenced this pull request Nov 6, 2020
Follow neo-project/neo#2007. Fix getDesignatedByRole price along the way.
ShawnYun pushed a commit to ShawnYun/neo that referenced this pull request Jan 8, 2021
* record historical designation

* fix ut

* sort

* Remove sort

* use different key

* fix some

* Store it as BiEndian

* avoid in same block

* Optimize

* use findrange

* optimize index get

* Erik's feedback

* Fix UT

* fix empty sequence

* optimize height

* fix ut

* index

* fix ut

Co-authored-by: Luchuan <luchuan@ngd.neo.org>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Erik Zhang <erik@neo.org>
cloud8little pushed a commit to cloud8little/neo that referenced this pull request Jan 24, 2021
* record historical designation

* fix ut

* sort

* Remove sort

* use different key

* fix some

* Store it as BiEndian

* avoid in same block

* Optimize

* use findrange

* optimize index get

* Erik's feedback

* Fix UT

* fix empty sequence

* optimize height

* fix ut

* index

* fix ut

Co-authored-by: Luchuan <luchuan@ngd.neo.org>
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: Erik Zhang <erik@neo.org>
ixje added a commit to CityOfZion/neo-mamba that referenced this pull request Feb 2, 2021
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.

None yet

6 participants