Giter Club home page Giter Club logo

Comments (2)

bingen avatar bingen commented on July 23, 2024

I really like this idea, removing those queues would simplify things a lot. My main concern is the gas cost, but I can give it a try and compare.
About the other downsides, I hope with work around them, worst case we could still enforce that drafting occurs within the term.

from aragon-court.

bingen avatar bingen commented on July 23, 2024

Some numbers from my first tests:

Gas comparison

inserts one node

Without Checkpointing With Checkpointing
Tree depth: 1

Tree next key: 1
Tree total sum: 10
Insert gas: 85,080
Sortition 5 gas: 23,565

Tree depth: 1

Tree next key: 1
Tree total sum: 10
Insert gas: 129,270
Sortition 5 gas: 24,990

inserts a few consecutive nodes

Without Checkpointing With Checkpointing
Tree depth: 3

Tree next key: 270
Tree total sum: 2,700
Inserts
Size: 270

Total - 21k
Min 55,080 34,080
Max 122,379 101,379
Average 62,076 41,076

Sortition 2605 gas: 27,299

Tree depth: 3

Tree next key: 270
Tree total sum: 2,700
Inserts
Size: 270

Total - 21k
Min 100,599 79,599
Max 213,596 192,596
Average 130,308 109,308

Sortition 2605 gas: 34,011

lots of activity

Without Checkpointing With Checkpointing
Tree depth: 3

Tree next key: 2,304
Tree total sum: 20,880
Inserts
Size: 2304

Total - 21k
Min 55,080 34,080
Max 122,379 101,379
Average 67,001 46,001

Removes
Size: 216

Total - 21k
Min 25,226 4,226
Max 31,160 10,160
Average 30,507 9,507

Sortitions
Size: 216

Total - 21k
Min 25,206 4,206
Max 44,778 23,778
Average 32,684 11,684
Tree depth: 3

Tree next key: 2,304
Tree total sum: 20,880
Inserts
Size: 2304

Total - 21k
Min 100,599 79,599
Max 213,596 192,596
Average 155,630 134,630

Removes
Size: 216

Total - 21k
Min 109,260 88,260
Max 138,144 117,144
Average 134,941 113,941

Sortitions
Size: 216

Total - 21k
Min 28,889 7,889
Max 76,328 55,328
Average 47,259 26,259

lots of activity, batched

Without Checkpointing With Checkpointing
Tree depth: 4

Tree next key: 4,160
Tree total sum: 37,700
Inserts
Size: 65

Total - 21k
Min 39,544 39,216
Max 52,813 52,484
Average 45,943 45,615

Removes
Size: 65

Total - 21k
Min 11,122 7,622
Max 18,878 15,378
Average 13,931 10,431

Sortitions
Size: 195

Total - 21k
Min 26,774 5,774
Max 48,684 27,684
Average 34,454 13,454
Tree depth: 4

Tree next key: 4,160
Tree total sum: 37,700
Inserts
Size: 65

Total - 21k
Min 68,952 68,624
Max 89,742 89,414
Average 79,308 78,979

Removes
Size: 65

Total - 21k
Min 58,129 54,629
Max 82,549 79,049
Average 70,652 67,152

Sortitions
Size: 195

Total - 21k
Min 32,726 11,726
Max 85,477 64,477
Average 51,546 30,546

forcing (fake) big tree

Without Checkpointing With Checkpointing
Tree depth: 8

Tree next key: 268,435,726
Tree total sum: 2,640
Inserts
Size: 270

Total - 21k
Min 92,379 71,379
Max 125,631 104,631
Average 96,847 75,847

Sortition 2605 gas: 30,907

Tree depth: 8

Tree next key: 268,435,726
Tree total sum: 2,640
Inserts
Size: 270

Total - 21k
Min 204,054 183,054
Max 334,778 313,778
Average 301,971 280,971

Sortition 2605 gas: 42,113

inserts a lot of times into the first node

Without Checkpointing With Checkpointing
Tree depth: 1

Tree next key: 1
Tree total sum: 210
Sets
Size: 200

Total - 21k
Min 35,072 14,072
Max 35,072 14,072
Average 35,072 14,072

Sortition 0 gas: 23,501

Tree depth: 1

Tree next key: 1
Tree total sum: 210
Sets
Size: 200

Total - 21k
Min 81,854 60,854
Max 81,854 60,854
Average 81,854 60,854

Sortitions
Size: 200

Total - 21k
Min 25,986 4,986
Max 32,108 11,108
Average 31,881 10,881

inserts a lot of times into a middle node

Without Checkpointing With Checkpointing
Tree depth: 3

Tree next key: 270
Tree total sum: 2,900
Inserts
Size: 270

Total - 21k
Min 55,080 34,080
Max 122,379 101,379
Average 62,076 41,076

Sets
Size: 200

Total - 21k
Min 46,722 25,722
Max 46,722 25,722
Average 46,722 25,722

Sortition 2505 gas: 37,949

Tree depth: 3

Tree next key: 270
Tree total sum: 2,900
Sets
Size: 200

Total - 21k
Min 139,410 118,410
Max 139,410 118,410
Average 139,410 118,410

Inserts
Size: 270

Total - 21k
Min 100,599 79,599
Max 213,596 192,596
Average 130,308 109,308

Sortitions
Size: 200

Total - 21k
Min 84,139 63,139
Max 103,191 82,191
Average 102,646 81,646

inserts a lot of times into a all nodes of a (fake) big tree

Without Checkpointing With Checkpointing
Tree depth: 8

Tree next key: 268,435,473
Tree total sum: 1,810
Inserts
Size: 17

Total - 21k
Min 92,379 71,379
Max 121,344 100,344
Average 100,827 79,827

Sets
Size: 1700

Total - 21k
Min 75,687 54,687
Max 75,751 54,751
Average 75,747 54,747

Sortition 1700 gas: 35,552

Tree depth: 8

Tree next key: 268,435,473
Tree total sum: 1,810
Inserts
Size: 17

Total - 21k
Min 204,054 183,054
Max 334,778 313,778
Average 291,315 270,315

Sets
Size: 1700

Total - 21k
Min 283,141 262,141
Max 283,205 262,205
Average 283,201 262,201

Sortitions
Size: 1700

Total - 21k
Min 48,016 27,016
Max 195,772 174,772
Average 122,074 101,074

multiple random sortition on a (fake) big tree with a lot of updates

Without Checkpointing With Checkpointing
Tree depth: 6

Tree next key: 1,048,591
Tree total sum: 860
Inserts
Size: 15

Total - 21k
Min 84,045 63,045
Max 109,758 88,758
Average 89,754 68,754

Sets
Size: 750

Total - 21k
Min 64,101 43,101
Max 64,165 43,165
Average 64,161 43,161

Sortition of 10 elements gas: 104,045

Tree depth: 6

Tree next key: 1,048,586
Tree total sum: 360
Inserts
Size: 10

Total - 21k
Min 204,054 183,054
Max 277,285 256,285
Average 244,381 223,381

Sets
Size: 300

Total - 21k
Min 225,648 204,648
Max 225,712 204,712
Average 225,706 204,706

Sortitions
Size: 300

Total - 21k
Min 275,676 254,676
Max 1,043,370 1,022,370
Average 885,734 864,734

Debugging storage

Some of these numbers looked kind of weird to me, so I tried with Remix, inserting 1 or 3 nodes. For some reason, Truffle numbers were higher.
For such a small numbers, the extra storage due to the initial slot of the array has big impact. With repeated updated on a node that impact will be diluted, but the difference will be of course higher.

Without Checkpointing

One node

remix_straight_1

Three nodes

remix_straight_3

With Checkpointing

One node

remix_checkpoint_1

Three nodes

remix_checkpoint_3

Other considerations

  • Although most of the time jurors will pay for the extra gas on updating values, it won't be the case when fees are redistributed and balances updated.
  • The higher a node in the tree, the more often it will be updated. For instance, the root node will be updated every single time any balance of any juror is updated. The checkpointing array for these high nodes could grow too big.

from aragon-court.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.