-
Notifications
You must be signed in to change notification settings - Fork 76
Add op_sha256tree #632
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
Open
matt-o-how
wants to merge
111
commits into
main
Choose a base branch
from
op_sha256tree
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add op_sha256tree #632
Changes from all commits
Commits
Show all changes
111 commits
Select commit
Hold shift + click to select a range
c4b88fe
initial commit
matt-o-how d1e93df
bring the cache over
matt-o-how 4ff94fc
more functionality
matt-o-how 850e5d5
separate treehash into own file and further correctness
matt-o-how 790cc9b
test test
matt-o-how 8144780
fix testing and add new tests
matt-o-how b02106f
add more tests
matt-o-how feb2f0f
adjust costs
matt-o-how 0c023d9
add 0x
matt-o-how f340214
cache cost
matt-o-how 0925c41
no TreeHash type
matt-o-how ed42080
remove duplicate precomputed_hashes
matt-o-how 056abac
make treeop private
matt-o-how 3142cd6
add malloc_cost_per_byte
matt-o-how 1cfa204
comment fixes
matt-o-how 94aa383
generate random tests and fix subtle costing bug
matt-o-how 8b569fb
add treecache tests
matt-o-how 27c57c0
clippy fixes
matt-o-how 0976bc3
fmt again
matt-o-how f777a13
add negative tests and more atom tests
matt-o-how 7efd8d4
test fix
matt-o-how c676a34
pass ref into pair
matt-o-how 52fb0ba
add sha256tree to bechmarker
matt-o-how 90acc78
add flag to wheel
matt-o-how 5191545
use Pathlib for python code
matt-o-how c8d71da
export ENABLE_SHA256_TREE in lib
matt-o-how 9c70ecf
fmt
matt-o-how 42a28fe
add benching for shatree
matt-o-how ca2fea5
make treehash pub
matt-o-how 27642b2
fmt
matt-o-how f726ca8
larger range of samples
matt-o-how af06b6d
add cost scaling in line with benchmark-clvm-costs
matt-o-how 3473df7
clippy fix
matt-o-how ba6ce50
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how 68fdb8f
call max() on values to stop negatives
matt-o-how 4907172
remove per-arg-time comment
matt-o-how 2552dc4
revert to original base_call_time with max(100.0) added
matt-o-how 4b529e8
re-add time_per_arg
matt-o-how 9fa2495
new per-byte cost measuring
matt-o-how 4cbd477
reformat list timings
matt-o-how 8e58fa8
dialect expansions
matt-o-how 6f316d1
increment extension on unknown extension test now extension is known
matt-o-how d597e26
fix bug
matt-o-how 59afd68
remove debugging
matt-o-how 3a96d38
new costs and new costings based on benchmarks
matt-o-how 5d1b629
32 byte blocks calculated per hash instead of in total
matt-o-how b8cb31e
max cost not slope
matt-o-how 972bb92
integrate into benchmark-clvm-cost
matt-o-how 928afac
finish integration
matt-o-how 8cab362
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how 1696f7d
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how d6806f5
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how 17abaf4
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how 628fe37
a.one()
matt-o-how 1e3ba49
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how 94c1b34
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how 77dab85
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how b21cf6e
Merge branch 'op_sha256tree' of github.com:Chia-Network/clvm_rs into …
matt-o-how d2aad70
add comments
matt-o-how 5793717
fix formatting and errors
matt-o-how 5b2ee2d
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how a613348
re-add 32byte tag to output
matt-o-how 2994383
Revert "dialect expansions"
matt-o-how c8c54b4
revert test change in softfork
matt-o-how 498915a
checkpoint
matt-o-how e119aab
fix error
matt-o-how dc568c3
rename to list
matt-o-how 4810478
print cost
matt-o-how 52df508
assert equal outputs
matt-o-how 3744787
use non-cached
matt-o-how 745927e
update values
matt-o-how a4e2e36
update costing and tests for shatree
matt-o-how c3ffba1
remove cached treehash
matt-o-how bdbf557
cleanups and better benching
matt-o-how ad5daaf
ignore many arguments
matt-o-how fe62f3a
gitignore DS_Store
matt-o-how 55bfbed
update comments and text output for clarity
matt-o-how 0eed06b
update tests for new costs
matt-o-how b27f794
no longer add high cost per node, only calculate cost based on hash o…
matt-o-how a28ce54
add comments
matt-o-how 7fa2819
add more comments
matt-o-how a9fcdcd
remove cost_per_node and add base cost equal to sha256
matt-o-how 73deeee
add further comments and remove per_node calculations from benchmark-…
matt-o-how 46478d2
update costing to more closely reflect the sha256 operator
matt-o-how 0f62718
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how 2d0bc2d
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how 2823b16
Update tools/src/bin/benchmark-clvm-cost.rs
matt-o-how 3ac31f7
fmt
matt-o-how dd4c4a9
add new cost_factor calculator into benchmark-clvm-cost.rs
matt-o-how 0519dc5
bench per type
matt-o-how b992caf
add balanced binary tree
matt-o-how d927993
clippy fix
matt-o-how 92765ad
add percent factor and output its affect on cost
matt-o-how fc17ebe
improve per-node calculation for balanced tree
matt-o-how 1c809d7
clarify sections in terminal output
matt-o-how 9dc6367
fix leaf count calculation
matt-o-how 8045013
subtract out bytes32 chunk hashing in benchmark
matt-o-how f0f54e4
accurately track leaf amount and add missing parenthesis
matt-o-how 8f68bcb
add md file explaining thought process
matt-o-how 6f75406
add windows timings to MD file
matt-o-how baa0e43
extra formatting
matt-o-how a7a6377
fix sentence fragment
matt-o-how ca4f149
remove cost_factor as it was confusing and no longer useful
matt-o-how 47f5f80
Update docs/sha256tree.md
matt-o-how 9f94b89
add explicit warning to cost
matt-o-how 7d52bd3
format i loop to track accurately
matt-o-how c95cfe8
update benching to generate graph for balanced tree and add all graph…
matt-o-how e71d4ed
remove all changes except added comments from benchmark-clvm-cost
matt-o-how 3b40d55
remove unused flag
matt-o-how 2e13d52
fmt
matt-o-how a7088f7
prettier md
matt-o-how File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,6 @@ target/ | |
| # Node.js | ||
| /target | ||
| /node_modules | ||
|
|
||
| # Mac generates these with the benchmarking tools | ||
| .DS_Store | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,107 @@ | ||||||||||||||||||||
| # Information on the new (sha256tree) operator | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Adding `sha256tree` as a native operator made sense as it is one of the most common functions, used in nearly every shipped ChiaLisp puzzle. | ||||||||||||||||||||
| Furthermore it has an innate inefficiency in it's in-language implementation. | ||||||||||||||||||||
| Every internal hash is allocated as an atom in clvm_rs allocator. | ||||||||||||||||||||
| In addition to this, a native operator also opens the door to future optimisations via caching. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Costing Goals | ||||||||||||||||||||
|
|
||||||||||||||||||||
| The matter of how to assign Cost to the new operator was the subject of intense thought and debate. | ||||||||||||||||||||
| It should be costed in proportion to: | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - the time to Cost vs other operators, and especially the `sha256` operator | ||||||||||||||||||||
| - the time to Cost ratio of the ChiaLisp implementation | ||||||||||||||||||||
| - the size of its inputs | ||||||||||||||||||||
|
|
||||||||||||||||||||
| The lattermost being a unique problem with regards to shatree as it is the first operator that parses trees, so utmost care must be taken when assigning cost. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| One final consideration while costing is that we required it to tally the cost during the runtime, rather than afterwards - which would be the most efficient calculation. This is because we want the oepration to fail immediately if `max_cost` is exceeded. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Costing Methodology | ||||||||||||||||||||
|
|
||||||||||||||||||||
| The `BASE_COST` was set to equal the base cost of `sha256`. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| The `COST_PER_BYTES32` was designed as the sha256 operation operates on 32byte chunks. We set the Cost to be on parity with the Cost of `sha256` although sha256 costs `per byte` and `per arg`. | ||||||||||||||||||||
| We can ignore `per arg` as `sha256tree` only takes a single argument, and we benchmarked the `cost-per-bytes32` so that it matches `sha256`'s `cost-per-byte`. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| The calculations for this can be seen in the file `benchmark-clvm-cost.rs`. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Finally the `COST_PER_NODE` was the trickiest to pin down as it is the most unique to this operator. | ||||||||||||||||||||
| The trick to costing was to compare with the "in-language" implementation and deduct the costs of the known hash operations using our previously costed `COST_PER_BYTES32`. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| The calculations for this can be seen in the file `sha256tree-benching.rs`. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Costing Results | ||||||||||||||||||||
|
|
||||||||||||||||||||
| `MacOS M1` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ``` | ||||||||||||||||||||
| Costs based on an increasing atom per bytes32 chunks: | ||||||||||||||||||||
| Native time per bytes32 (ns): 95.1425 | ||||||||||||||||||||
| CLVM time per bytes32 (ns): 94.9895 | ||||||||||||||||||||
| Native implementation takes 100.1611% of the time. | ||||||||||||||||||||
| Native cost per bytes32 : 64.0000 | ||||||||||||||||||||
| CLVM cost per bytes32 : 64.0000 | ||||||||||||||||||||
| 100.1611% of the CLVM cost is: : 64.1031 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Costs based on growing a balanced binary tree: | ||||||||||||||||||||
| Native time per node (ns): 203.8718 | ||||||||||||||||||||
| CLVM time per node (ns): 517.8038 | ||||||||||||||||||||
| Native implementation takes 39.3724% of the time. | ||||||||||||||||||||
| Native cost per node : 564.0000 | ||||||||||||||||||||
| CLVM cost per node : 1463.0000 | ||||||||||||||||||||
| 39.3724% of the CLVM cost is: : 576.0185 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Costs based on growing a list: | ||||||||||||||||||||
| Native time per node (ns): 115.0891 | ||||||||||||||||||||
| CLVM time per node (ns): 397.1927 | ||||||||||||||||||||
|
Comment on lines
+57
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the two different ways you measure time-per-node seem to disagree quite a lot.
I see a similar pattern on RPi 5.
I think this suggests there's something fishy about the assumptions in those measurements. |
||||||||||||||||||||
| Native implementation takes 28.9756% of the time. | ||||||||||||||||||||
| Native cost per node : 500.0000 | ||||||||||||||||||||
| CLVM cost per node : 1399.0000 | ||||||||||||||||||||
| 28.9756% of the CLVM cost is: : 405.3693 | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| `Windows` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ``` | ||||||||||||||||||||
| Costs based on an increasing atom per bytes32 chunks: | ||||||||||||||||||||
| Native time per bytes32 (ns): 10.4049 | ||||||||||||||||||||
| CLVM time per bytes32 (ns): 10.2604 | ||||||||||||||||||||
| Native implementation takes 101.4084% of the time. | ||||||||||||||||||||
| Native cost per bytes32 : 64.0000 | ||||||||||||||||||||
| CLVM cost per bytes32 : 64.0000 | ||||||||||||||||||||
| 101.4084% of the CLVM cost is: : 64.9014 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Costs based on growing a balanced binary tree: | ||||||||||||||||||||
| Native time per node (ns): 62.6417 | ||||||||||||||||||||
| CLVM time per node (ns): 1350.7339 | ||||||||||||||||||||
| Native implementation takes 4.6376% of the time. | ||||||||||||||||||||
| Native cost per node : 564.0000 | ||||||||||||||||||||
| CLVM cost per node : 1463.0000 | ||||||||||||||||||||
| 4.6376% of the CLVM cost is: : 67.8481 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Costs based on growing a list: | ||||||||||||||||||||
| Native time per node (ns): 61.1526 | ||||||||||||||||||||
| CLVM time per node (ns): 608.9923 | ||||||||||||||||||||
| Native implementation takes 10.0416% of the time. | ||||||||||||||||||||
| Native cost per node : 500.0000 | ||||||||||||||||||||
| CLVM cost per node : 1399.0000 | ||||||||||||||||||||
| 10.0416% of the CLVM cost is: : 140.4821 | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Costing Graphs | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Below are the generated benchmarking graphs (PNG) from running `sha256tree-benching.rs` on Macbook M1. | ||||||||||||||||||||
|
|
||||||||||||||||||||
|  | ||||||||||||||||||||
|
|
||||||||||||||||||||
|  | ||||||||||||||||||||
|
|
||||||||||||||||||||
|  | ||||||||||||||||||||
|
|
||||||||||||||||||||
|  | ||||||||||||||||||||
|
|
||||||||||||||||||||
|  | ||||||||||||||||||||
|
|
||||||||||||||||||||
|  | ||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| ; This file was generated by tools/generate-sha256tree-tests.py | ||
|
|
||
| sha256tree (((((0 . 0x1f7061813451ffb2830d0aab69351d593dab69e339835167) . (0 . 0xd09ba26eb2ba7592a67659ca19fc923a1631b38cd5aebb0b53baa7c68d2d89faad5c2f8e2d9ffeb9714f50a59a21ab4e)) . 0x02) . (((0x177ba5f23f0e140f805254e78fac8c2bee4fe850fc37ead18cb51314c9181e31 . 0x666f6f626172) . (0x02 . 0x666f6f626172)) . 0)) . (((0xc4c6b5a3bc74be71b5631a1dfd4cc0aae3ee363ecbb0214d . (0x01 . 0)) . (0x06d17ae983679967e26dd593cf637c98951adb3e90f349ec421212eaa30109e51b12120fc9ac3d6e527e383aaad939ae . (0 . 0x5c8b34f9fac0f365af055ef59678414793a7a5859715ea8f76bfa5ea13ff7c49))) . (0x01 . 0))) => 0x6768523ba0f32733a54551b101688a6300311e0b10e212049226d98bcd7f869d | 22579 | ||
| sha256tree (0xcdbe2cffebfda5b5dfe499e05894967d10d0e55d5bd0c9d3 . (0x16f905cd314124664cf8070035bff4faa40fdea48447770a . (0x01 . 0))) => 0x157c1e83a68a2c6cbbd92aa7ff82552b0cb2679885858695f85ed9404126ac80 | 4739 | ||
| sha256tree 0xc3041da8237d1d10610210bbad12e483fcce196c80cd189f650e6d86fda57f92 => 0x291b0356fa82ec28b5db8254c56f368273478de1fc6c8d7b85ca80706958cfa0 | 1035 | ||
| sha256tree ((0xfac7754adb5942ea853a150bbfe72c4165d7a36b35bf125240b81e5764cf52b04c6ec11682626aa49e3872e68979808a . 0) . (0x666f6f626172 . 0x666f6f626172)) => 0x9ff9d9c782362027084f4ef5ce131621d35ecde7e9cf5320b36ad7e45cf1c7e1 | 4803 | ||
| sha256tree (((0 . 0x02) . (0x18dd1f6517ae25cf64f9ddc232b7a756c3dfe0b60221d62d . 0x02)) . 0) => 0x591fbedc01c82c80596e03d4dcd75532e40520577008c6d5c6764ac2a984aa27 | 5995 | ||
| sha256tree ((0x666f6f626172 . 0x02) . 0x2a7776815b9b83c9c9049b6f5218739552e0dba6937b5e69943776aef44c9dff78f688d40641dddf52bf6818417523df) => 0xfd2359fd4190f1424be253889a1604cf8e106f0b1b791165e262dd8a652d0a05 | 3547 | ||
| sha256tree 0x68ed3d3389d15111a797fdf9434045841b3a3753d93310d593cd3c80ff27e2213e1faf566c4565ffede6bc89ec96bf89 => 0x8c9d292643d2b79627b488e277710209b0bf33e2526f96ba64019d17faf0e7d8 | 1035 | ||
| sha256tree (((0 . 0x119c26c141c87f1359bbfb2a82afd7a060043f446760e7f60229a485388eaa68) . (0x01 . 0x02)) . (0xdcc048db813648ccb794f644e9cafc6094bbe1bea5ef388f . (0x02 . 0x9c7483847dc6e351081a37c527bbda1e24b015e31f60d353b96370b77f26530d))) => 0xdec44a4d2d8752c305825b09d9e0b24031628f33f041354ccb2fc457131e750c | 8635 | ||
| sha256tree ((0 . (((0 . 0xa5c8efe9fc85db1b35d96edf0d1fef862c30fea73d1c5318de02dd1504cb88e8fded7f1ef8479b9f37204f368ac8e379) . (0x02 . 0x0df17fa06f30f7429162e282f00722e520e0a2676c69cfd2b92f678b28729524)) . 0x666f6f626172)) . (0x02 . (((0x8302df3c2a02bcca20648da3a1aa96d3f9dbd47960d90a53 . 0) . (0x01 . 0x02)) . ((0xa31acd511f4560b50be8bf18d47c1f422bab6bcdda0e69ea0152ad49c28833a78c2d4613ec8aa512cdf3a948eadcd7b9 . 0x02) . (0x6b3b39ef6fe8fb41a13a495599cadb2ded8da6ddd25518b1 . 0x01))))) => 0x7f6f3a1dd8af7087774438b0ab2770dcaacf3f42d632f3544a9f5b63c7378212 | 18747 | ||
| sha256tree 0x51cde38bba7b68ba39903e1e83c152969d896608efde132ce9f9f4bcdc6833e5fa3d21238a6cf5cceb132adf1d371a60 => 0xa2d4a03a19d0ed8bf52df8a7e26433e98c672be16ffc2137ceb7209be333c98b | 1035 | ||
| sha256tree (((0x02 . 0xa21186440ff93ecba8304bfee4997e3618b0c84c31b21533) . (0 . 0x28b70cdb54d9cc014c6aea054082229d47ea269a9b280770)) . ((0xa8dc249448c80f5004f13abd6401ad4bcb6b52a97c5a359b . 0x0f0df3479340a2d5a7d7c47cb0ea209f60953c9f85a423b5) . (0x02 . 0x666f6f626172))) => 0x1ba6e28d4eb3b955faa2d6f348261a6be3a5427d44489647ab06e366de0b2479 | 9763 | ||
| sha256tree (0x104e55ad9b1db96359ed05d6ed3ec4c207c3b6213b46b974 . 0x01) => 0xeaadf0be76b05cbbdaaae7f3d805e678039814c0a5620794ae8961052f123400 | 2227 | ||
| sha256tree (((0x6f815e4db56a306afba86916d4b29b194ceed7f492fc8a33a85d9a15cfe0536d . 0x01) . 0x95199b2f16397b23a2a70704c656f51b28e3d3d22680823d76ae4029ec4eb71a12760c82b4441a9d39b5baec010f6b7d) . 0x3c370f10cd9ec3d572cfa6a8724856b6c68a0e60912fa563f0a182323bcd6d31) => 0x4c71c2c6b8d98390697a61bd228bf1113b685f835e97552cf62feeef0d7069d1 | 4931 | ||
| sha256tree 0x7a9aa9d0946b816656299f1bd609cd0692602ce26f2f124649955b4ba54b9e8d16dcf5b392bed7189da48020f79c5bbd => 0x28a2096bc8056d3b3287a605b2dd183489e4eeb4113093d841243c2a08d83719 | 1035 | ||
| sha256tree ((((0xb941c50724b5c81213f40b621efbec33d30d2b1839ca80c81a7728bde1ba73fa . 0x8bd83d18af286870a712bb04d61d4b7fe29489cd0c7fced8dec078b631a9b0d9) . (0x02 . 0x02)) . (0x02 . 0x02)) . (((0x01 . 0x01) . (0 . 0x666f6f626172)) . ((0x01 . 0x02) . (0x01 . 0x666f6f626172)))) => 0x883633e181c8d3aee1667d530d4a2807ef242c4f961678f301b0b40ee55ab948 | 17427 | ||
| sha256tree ((0 . 0x01) . 0x01) => 0x9b28d247c983abca94e6961e6cfe6623cb9e9415d0f9e0cb04a46b3ae43369bd | 3483 | ||
| sha256tree (0x02 . 0xd6af8d56786198cde353189f35566ece010a122c7c6f181991803d7cff673b7f) => 0x938ba2209eb55f5daa22c51677f94adbbdf84566c6fb3b89ff0fa8d08d5905f2 | 2291 | ||
| sha256tree (((0 . (0xa79fbde48fc3ddeccdd64774441ab7bbd6a34f5ad1a6d78e3a3a960eea3dfbf0 . 0x666f6f626172)) . ((0xe02c71ebcfdfef147f01ed578a0844726265fb0e86cf091f93308866491f72d2 . 0x50e86350e1ddae6f2289626bd722568991a62b94f9f9ef1d4e19aa9cf5c8aee7) . (0xe98e1cfcff183a5637969e9ae20e07acb20bd662fa4262b9 . 0x02))) . (0xbb9437c1ba52ab7ca465599c57ab6d71991fca001d67274028407a245406f34f . ((0xb9a4001e4d6b805d3a3d8b6b7976ef91810056bbaca737739b8e0bda6fd5b661 . 0x02) . (0x01 . 0x666f6f626172)))) => 0xca1aa87e0b15e86b3cf1a975bb61440b607d3ded9a6d95300b19c59765d575c5 | 15107 | ||
| sha256tree ((0 . 0x02) . 0x882d2f48ed804484d9f23d38053f523e3574119071b3a7f6) => 0xb64c99c57ce8bac8cd73351de0eae02473271755f053504a7270fe02921d1a0e | 3483 | ||
| sha256tree (((0x666f6f626172 . 0x02) . (0 . 0x666f6f626172)) . 0x3d2f00fbfd0278404cd508c4afb460f55b116e5733240c4f4a30a5a790beed1c) => 0x3f6498812d3a5d119db27f679b938558e7d74c9cd921bc28bb6245823ca1f7fe | 6059 | ||
| sha256tree 0x57afc714e65003547db455176d5f85cc6594b88e5d28f87bf49ec82135fa791b09d6a102c34787fec98544486b888023 => 0xbc6c9852407944ab4bd3749b61216e3ab64c1d1e11b56be0cc30fd0344e34085 | 1035 | ||
| sha256tree ((0x3e9be38550994f6fa12c2ba30bc582ceda9f715d5a3a4af06d3a4f35d1b5d242a0b825d74a3b7e3086590b22172f5eeb . 0x02) . 0) => 0xc8d024ec5e8b001598920071454558cd6a2831742829cb507e744d79b0dbb09c | 3547 | ||
| sha256tree (0 . 0x51e7d76d53afdbbe486df4f6eb42197aa985154283ed028c) => 0xbc02de5bb1e9feccc7adc78cdc6ca567c0311df0543e46434dc795edebc67dbf | 2227 | ||
| sha256tree 0x666f6f626172 => 0xf03942eca4827c93931fee97f117479ef474c9aaa449655ddffb48886bde58ad | 971 | ||
| sha256tree (0x934128806851cb5eba9d244dfce1734a41c190bde679560a22fe90a87a4f775c . (0x02 . ((0 . 0x02) . (0x62e282852844353b813fd3a967e9af12b596a2ba912236363ed6869f2669546e . 0x02)))) => 0x9063f5dcb016de08e12d1f8b4c893a9f1c008d08cd0c543c5707a2a328feb6c9 | 7379 | ||
| sha256tree (((((0x02 . 0x02) . (0 . 0x01)) . (0xd69626fe507014737c49d9b7cf950721c7142ce1b217d2c4c654b2274615129a2374a9a5700d37188047b55ecf1d55dd . (0x4dca4553f9115e233dda1e184759e201f1de5fe11d3f2dc0 . 0xbb2aa251bf2f429ddf6a48a0d70ca6ceeb9dda50428cabde))) . (((0x02 . 0) . 0x01) . (0x16f07f1f29699553d8064284a6a324b906ff081a195075e5a9d0c6c399b2492a2e13aa69bd7a236ae2de60a2a7725306 . 0xfc7fd2354396ab20b07d6f07259c8691456ef7989feee44a04f2d87c96d7b4cecfc039e2ba04f86da20b062bc9ccda38))) . 0x1e122d35a2ac075a48dc607a8a428586a3a06591f6e20e71c95bb94dcaaf95a6165d97a7d8f90e8ae5517468cba60afc) => 0xcf43ccb9fdabc87ac031c3f372addd99e91103ef5d89e389a186e0215a620be0 | 16299 | ||
| sha256tree ((0x4295ead455b30626cd3dc0aed97dd4be40f4fe965f337484092ba6650c1e5fb0 . ((0x666f6f626172 . 0x01) . (0x231bcedef942bcc4b1c99f8b26382a7433866dc96cd617f59d39ebd5f10fe23b . 0x02))) . (((0xa27954b60506b8f2cb4c56398797eb9d640ca976b9c21126a39e14af0fdb94ac . 0x01) . 0x67a0ad6c4e30c5e702cc723d57b00ff3bf818fc553093b1970aa6a9c2698f87098fbf322ee3047d144c266b2f425da32) . 0)) => 0xa0bf50e2536ab240ad5e55d8ff761722a87fef03f1d57eb13566cb7a41185db0 | 11275 | ||
| sha256tree (0x0fb2228f690832f6f2d1f08afeeaf00352b182d49a7db18c5bc335b95609d9503ba3f97054599526ae316a63a4d72fed . 0x64acfa2fd1990e8b55989a4ff9544b7368e9eccfe3c98716a1c330db640be65b) => 0xef13a74e8149d647e668f323049257a5f0ae16ec6d1f64a2ca2404cb670f233a | 2355 | ||
| sha256tree 0x01 => 0x9dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2 | 971 | ||
| sha256tree (0x02 . (0 . 0x666f6f626172)) => 0xfd1c831b92f4ca52591d92502f97d00dbe004f454873c989bd1161978cb06ab6 | 3483 |
|
arvidn marked this conversation as resolved.
arvidn marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| sha256tree 1 => 0x9dcf97a184f32623d11a73124ceb99a5709b083721e878a16d78f596718ba7b2 | 971 | ||
| sha256tree 0x00cafef00d => 0x60bc5062a80c4363cbe881815300d349c5524d98e3502a016466d14d1f3f25d9 | 971 | ||
| sha256tree () => 0x4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a | 971 | ||
| sha256tree (() . ()) => 0x52db9ef97986e7382ef78b8eae2dacdbb2ce823ed1396a0fb2f7f120a2b40a63 | 2227 | ||
| sha256tree (0x00cafe . 0x00f00d) => 0x005b24012b958cc8fc19b7d45438f82fb9034c24b2a77d219250316f482ba6b6 | 2227 | ||
| sha256tree (202 254 240 13) => 0xb5e2a23ac2de5105c72b9658428a3d389a9f909012eedd4b641504d981f81ac5 | 5995 | ||
| sha256tree (202 254 (240 13)) => 0x5edd993092c97418933750dc25add55a84ac9f07b2067d537d38f0044bd317ae | 7251 | ||
| sha256tree 10 20 => FAIL | ||
| sha256tree (10 . 20) 30 => FAIL | ||
| sha256tree (10 . 20) (20 . 30) => FAIL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| use crate::allocator::{Allocator, NodePtr}; | ||
| use crate::cost::Cost; | ||
| use crate::op_utils::get_args; | ||
| use crate::reduction::Response; | ||
| use crate::treehash::*; | ||
|
|
||
| pub fn op_sha256_tree(a: &mut Allocator, input: NodePtr, max_cost: Cost) -> Response { | ||
| let [n] = get_args::<1>(a, input, "sha256tree")?; | ||
| // let mut cache = TreeCache::default(); | ||
| tree_hash_costed(a, n, max_cost) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you mind including the relevant plots of the measurements also, to demonstrate that this model matches reality? Specifically, that CPU cost grows proportional to CLVM cost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plots added