Commit Graph

6908 Commits

Author SHA1 Message Date
y
63a6856ccd timekeeper: restore 0 check for slot 2023-09-18 15:46:05 +00:00
y
f67fc3df29 Add checks on TimeKeeperSafe methods 2023-09-18 15:46:05 +00:00
y
f85cd257a0 fix mistake in TimeKeeperSafe::current 2023-09-18 15:46:05 +00:00
y
6308a7e123 fix comments 2023-09-18 15:46:05 +00:00
y
5d62a10855 Add TimeKeeperSafe struct
Instead of checking if one of the TimeKeeper fields is 0 on every
operation (which adds overhead and protects only in the case of an
incoherent instantiation of the struct), add a new struct TimeKeeperSafe
that panics when created with bad values.

It is still possible that a developer can make a mistake and manually
initialize a TimeKeeper with bad values or else set its fields to bad
values. For now, we will accept this risk as it is not present in the
codebase.
2023-09-18 15:46:05 +00:00
y
c7814711e0 fmt 2023-09-18 15:46:05 +00:00
y
2f45588f57 util: fix division-by-zero panics
Added simple checks for division by zero in arithmetic operations in
util/time.rs
Added a unit test to check that a TimeKeeper with values of 0 in its
fields can call its methods without panicking.
2023-09-18 15:46:05 +00:00
y
0a61ec37fb zkas: fix panic occurring in nested function calls
This issue was discovered by fuzzing.

Change the `unimplemented()!` panic macro to error handling that informs
the user that using Literals and Functions in nested function calls is
not yet supported. This should be a slightly more friendly developer
experience. Changing this from a panic to an error allows us to continue
with further fuzzing.
2023-09-18 11:04:20 +00:00
y
3b52ed4e27 zkas: formatting, typos, clippy 2023-09-18 11:04:20 +00:00
y
8a333100ef zkas: fix panic in Analyzer
This issue was discovered with fuzzing.

Panic 1: It was possible to assign a variable to a function/opcode with
no return type. This caused a index-out-of-bounds panic when the
analyzer attempted to access the first element of an empty vector of
return types. The analyzer now presents an error when a .zk author
attempts to assign a variable to an opcode that has no return types.

Panic 2: There was an index-out-of-bounds panic when performing
verification on Literals that were passed to Opcodes that use Array
types as their arguments. This was fixed by pasting the validation code
from the Variable verfication section which handles Arrays properly.
(Refactoring should be done to reduce duplication here.)
2023-09-18 11:04:20 +00:00
x
01a1ade3b6 doc: split SUMMARY.md into sections 2023-09-17 14:25:22 +02:00
y
827ddbb9a0 zkas: fix more panics in Parser
These issues were found via fuzzing

Panic 1: If the size of the vector of tokens passed to
`check_section_structure` is less than 2, the parser tells
the author that there are not enough valid tokens in the section.

Panic 2: Very large values of k will result in integer overflow when the
value is larger than the type's MAX_SIZE. This causes the existing k <=
16 check to succeed but it actually shouldn't. In debug/fuzzing
   contexts, Rust panics. In production, this will not occur.

Panic 3: If invalid/unimplemented characters appear in an argument to a function, the
parser panicked when it hit `unimplemented!()`. Now it tells the author
that this character cannot be used in an argument to a function.
2023-09-17 00:18:15 +00:00
y
d7816326fb zkas: fix panics in Parser
Add error handling for the parser logic. Both of these issues were found
via fuzzing.

Fix Panic 1: instead of panicking via unwrap() when analyzing the namespace,
the parser displays an error message informing the .zk file author
that they need to add a namespace.

Fix Panic 2: if the length of the `tokens` vector is 0, the parser
now displays an error saying so.
2023-09-16 23:14:31 +00:00
y
c669ba4696 fuzz: fix old code comment in script 2023-09-16 23:00:24 +00:00
y
f9ed0b825c fuzz: add script to generate .zk file corpus 2023-09-16 23:00:24 +00:00
y
9d97aebf50 fuzz: Add fuzz harness for zkas compilation
Create a fuzz harness to test the ./zkas binary compilation process. The
whole pipeline is tested: Lexer, Parser, Compiler, Analyzer. This is
performed by copying the relevant code from bin/zkas/src/main.rs.

Testing the entire pipeline like this is not very efficient in terms of
fuzzing cycles but on the other hand it is a quick-and-dirty way to find
results. It also benefits from testing the actual inputs to the binary
in the way it's expecting, rather than checking each of the components
in a piecemeal way using interfaces that aren't expected to be exposed
anyway.
2023-09-16 23:00:24 +00:00
greptile
94d101a8ae zkas: Fix compiler panic when semicolons are missing (#220)
* zkas: Add error for missing semicolons

Fixed a parser bug where it would pass invalid statements to the
compiler which resulted in a panic.

Added error handling in the parser when a semicolon is missing. The
error message suggest to the dev to add a semicolon.

Also added more detail to the unreachable()! statement in the compiler
so that a darkfi dev can see what the erroneous StatementType was that
caused the panic.

Example errror cases:

```
<statement> <statement>;
```

and
```
<statement>
<statement>;
```

To test: remove a semicolon from example/simple.zk and run ./zkas
example/simple.zk

* add code comment to explain

---------

Co-authored-by: y <y>
2023-09-16 18:55:41 +00:00
aggstam
4d5e779e28 contract/money/tests/pow_reward: use proper producer tx validation 2023-09-15 01:27:37 +03:00
aggstam
01fac53e39 validator: properly test producer txs 2023-09-15 00:51:37 +03:00
aggstam
ade055d3db validator/validation,verification: perform validations based on block version 2023-09-15 00:51:37 +03:00
aggstam
45d6ffea71 validator/verification: proper producer tx handling 2023-09-15 00:51:37 +03:00
aggstam
0d0740d331 blockchain/Block: removed slots vector, and handle storing based on block version.
With these changes, BlockInfo now represents a wrapper over Block, as it becomes constant/final in terms of structure. All extra data based on block versions go to BlockInfo, and their storage is handled accordingly.
2023-09-15 00:51:37 +03:00
aggstam
eca2c7e175 blockchain/Block: moved producer tx at last position of blocks' txs vec 2023-09-15 00:51:37 +03:00
aggstam
dba13ebef6 blockchain/Block: removed producer structure 2023-09-15 00:51:37 +03:00
x
1a863ef8d8 doc/book: chmod +x remove_chapter_nav_js.py, to fix github action failing 2023-09-14 15:42:51 +02:00
ertosns
6fe2897fc9 [research/bulletproof-mpc] comment code 2023-09-14 14:59:50 +03:00
aggstam
b8e612138d validator/blockchain: consolidate all blockchain structures validation at src/validator/validation.rs 2023-09-14 14:39:20 +03:00
ertosns
ceff2a8420 [research/bulletproof] add bulletproof ipp 2023-09-13 23:37:56 +03:00
ertosns
586c283557 [research/mpc] upgrade mpc, for ipp compatibility 2023-09-13 23:37:56 +03:00
ertosns
687ff6538a [research/mpc] naive msm over ec mpc 2023-09-13 23:37:56 +03:00
aggstam
8d7a2bde7c validator: preperation cleanup for PoW blocks integration 2023-09-13 19:22:56 +03:00
aggstam
4700e85e4b contract/money: decoupled GenesisMintV1 and PoWRewardV1 from TokenMintV1 2023-09-13 16:20:05 +03:00
aggstam
91e2b0b916 contract/consensus: decoupled GenesisStakeV1 from StakeV1 2023-09-13 15:46:17 +03:00
aggstam
bcbc636318 contract/money: new PoWReward call added 2023-09-12 17:48:04 +03:00
x
6b2503ac27 add dkg multisig script 2023-09-12 10:44:52 +02:00
x
215f7cc1e9 doc: update book with key recovery scheme from DKG paper 2023-09-12 08:39:53 +02:00
x
70e5eae6ac book: add makefile step to remove arrow keys from book js 2023-09-12 08:03:35 +02:00
x
b314daafc3 book: hide left/right navigation buttons 2023-09-12 07:17:25 +02:00
parazyd
6661faf8c4 event-graph: DAG sync implementation. 2023-09-11 12:40:58 +02:00
parazyd
4b6d85b340 Makefile: Modify the 'fix' target to also work on tests. 2023-09-11 12:40:36 +02:00
parazyd
6b49fa6560 net/message: Allow packet payloads to be empty.
We should be able to send commands without a payload.
2023-09-11 12:40:06 +02:00
lunar-mining
259ecbc004 script/dnet: implement PEP 8 2023-09-10 16:10:08 +02:00
lunar-mining
3be0e7a757 script/dnet: render slot msgs 2023-09-10 16:10:08 +02:00
lunar-mining
119f593dbf script/dnet: improve model in preparation for events handling 2023-09-10 16:10:08 +02:00
lunar-mining
1c4c32f945 script/dnet: cleanup and re-enable right render 2023-09-10 16:10:08 +02:00
y
bb20e05f0c event_graph2: Add unit tests for Event::validate 2023-09-10 08:54:35 +00:00
y
fb780d73be event_graph2: add basic checks on math
Force panic rather than perform operations that overflow i64
Add explicit check for division by zero
2023-09-10 08:53:44 +00:00
lunar-mining
30327e610f script/dnet: render result of get_info() in View 2023-09-09 21:01:27 +02:00
lunar-mining
291f80b9b0 script/dnet: pass Model data to View 2023-09-09 08:41:39 +02:00
Dastan-glitch
12df4958f5 event_graph: fill blanks in tests 2023-09-08 18:33:01 +03:00