Commit Graph

116 Commits

Author SHA1 Message Date
y
78196dbdd2 [runtime/merke] Document method merkle_add() 2023-11-22 11:43:41 -05:00
y
d4b8d45b74 [runtime/util] Document methods 2023-11-22 11:15:27 -05:00
ertosns
6e830b386a [src/runtime] add link to open issue unstable cursor_reamining 2023-11-22 00:25:04 +02:00
ertosns
0d05fe6ebe [src/runtime] rename db_handle:u32 2023-11-22 00:25:04 +02:00
y
d70dc7da65 Revert "[validator/verification] Reject massive txs"
This reverts commit a0636984e4.
2023-11-21 17:13:22 -05:00
y
a0636984e4 [validator/verification] Reject massive txs
Add a check in verify_transaction() to reject transactions that have a
number of calls greater than the GAS_LIMIT defined in the runtime.

This prevents a potential denial-of-service vector where an attacker
could submit extremely large transactions that are guaranteed to revert
but still tie up system resources before the revert happens.
2023-11-21 16:24:17 -05:00
y
a649d8f434 [runtime] Handle calls with no return values
This commit handles cases where the wasm functions had no return values.

- The code has been rewritten to avoid potential index out of bounds
errors when the `ret` variable could have had a length of zero
- Added new debug message to signal when a contract has returned no
  values, but this is expected and desirable
- Add code comments
2023-11-21 11:32:26 -05:00
y
d3839ed6fc [runtime] Prevent (unlikely) underflow
This commit explicitly handles a scenario where an underflow could
occur when calculating gas. In practice, this should not occur as the
WASM points budget should be synchronized with the contract's gas usage.
For this reason, the code should panic instead of underflow if this does
somehow happen.
2023-11-21 11:32:26 -05:00
y
889478f561 [runtime] Add clarifying documentation 2023-11-21 11:32:26 -05:00
parazyd
8f46f7b777 lib: Clean up library features. 2023-08-29 13:08:35 +02:00
parazyd
60595e3002 zk: Handle invalid witnesses gracefully in empty_witnesses(). 2023-07-22 15:42:45 +02:00
parazyd
8ac1d17077 Use k param from ZkBinary when building VerifyingKey and ProvingKey. 2023-07-22 12:04:41 +02:00
parazyd
29101c4e02 zk: Pass a ZkBinary reference to ZkCircuit::new instead of cloning. 2023-07-20 14:19:52 +02:00
aggstam
0d00179abd darkfid2: further extend tests foundation | repo: fmt 2023-07-03 16:50:44 +03:00
aggstam
6fa4049a1b Make Repo Great Again 2023-06-29 17:29:23 +03:00
aggstam
feabf5a67a blockchain: rewrite completed
Attention: this commit breaks darkfid/faucetd network functionalities, so nodes can't sync or participate in the protocol. Wait for their rewrite(TM)
2023-06-28 14:42:14 +03:00
aggstam
ec97e969c8 sdk: renamed SlotCheckpoint to Slot 2023-06-24 18:18:08 +03:00
parazyd
33c286f19f contract/dao: Introduce money state snapshotting.
This prevents double-voting in the sense of minting new coins _after_
a proposal was created, meaning only the coins that have existed prior
to creating a certain proposal are able to vote on it.

This is done by marking down the latest Merkle root in the Money state
and attaching it to the proposal's metadata. Then this root is used for
verifying inclusion proofs when voting.
2023-06-14 14:41:24 +02:00
parazyd
7ec7d9244f runtime/merkle: Introduce pointers to latest merkle roots in merkle_add()
Also migrate all the contracts that use merkle_add to this API.

This is the better approach, since it avoids having to run redundant
operations like lots of hashing when we want to retrieve the latest
Merkle root in some tree. It is too expensive to do it directly in WASM,
so doing this through the injected host function allows us to price it
more accordingly.
2023-06-14 13:32:23 +02:00
parazyd
8257d7cdbe sdk: Replace incrementalmerkletree with bridgetree crate. 2023-06-12 14:31:19 +02:00
aggstam
53682169cd sdk: get_verifying_slot_epoch added 2023-06-05 21:59:39 +03:00
parazyd
54225ed4fd runtime: Double the gas limit. 2023-06-05 19:16:49 +02:00
parazyd
9cf3fee6ac runtime: Make all WASM opcodes cost 1 unit, clean up gas_info. 2023-06-05 17:31:19 +02:00
parazyd
c129ab4cb3 runtime: Add sanity_check function for checking WASM bincode. 2023-05-30 11:38:18 +02:00
parazyd
89666c0849 runtime: Add TODO on using sled-overlay for deploy() 2023-05-30 00:29:13 +02:00
aggstam
1bd504eaa0 util/time/TimeKeeper: added verifying slot attribute that can be used by the runtime for validations 2023-05-17 16:03:24 +03:00
aggstam
3943ad27af sdk: replaced db_get_slot_checkpoint with get_slot_checkpoint and moved to util 2023-05-04 21:11:38 +03:00
aggstam
96a834eef5 src/contract/consensus: constrain slot lottery parameters 2023-05-04 21:11:38 +03:00
aggstam
040a5d5604 sdk/util: replaced get_system_time with get_blockchain_time, get_current_epoch and get_current_slot added 2023-04-29 01:52:15 +03:00
aggstam
01dad53892 consensus: created helper struct for all time related calculations, for easier access by the runtime 2023-04-29 00:52:11 +03:00
aggstam
3fb92f5cd7 sdk/util/get_system_time(): set time value as u64 and minor cleanup 2023-04-28 23:28:03 +03:00
aggstam
fc6c6e6551 sdk: implemented get_system_time for use inside wasm 2023-04-28 19:51:10 +03:00
aggstam
cd6dc23598 drk-darkfid: added subscribe to listen for erroneous transactions 2023-03-21 16:24:05 +02:00
parazyd
7fbd8af5b5 runtime/db: Remove spammy error from log. 2023-03-18 21:36:46 +01:00
aggstam
4e305bd69d WIP runtime: remove Batches logic, write directly to overlay 2023-03-16 19:12:58 +02:00
aggstam
9a74979141 WIP runtime: use an overlay over Blockchain
This allows us to use a sled-overlay over the original Blockchain sled db, so we can validate transactions execution without actually writting to it. Tests pass, but its far from ready. Cleaning, some todos and erroneous txs handling still missing.
2023-03-16 02:42:10 +02:00
aggstam
d841ad9fe1 runtime::write_batches: dont' return the mutable env 2023-03-09 20:15:55 +02:00
aggstam
7d3090f1ed runtime: Make all the writes atomic in a transaction over all trees 2023-03-09 19:59:46 +02:00
parazyd
7bfd17b8cf runtime/db: Disallow init/lookup of zkas db. 2023-03-09 11:57:50 +01:00
parazyd
473d2f8707 consensus: Dynamically load VerifyingKey for zkas circuits from sled. 2023-03-06 18:33:53 +01:00
parazyd
740ce9fa52 Move SMART_CONTRACT_ZKAS_DB_NAME constant to the wasm runtime module. 2023-03-06 18:33:52 +01:00
parazyd
c5ad486a09 sdk: Implement zkas_db_set for use inside wasm. 2023-03-06 18:33:52 +01:00
parazyd
6fda2f9142 runtime/db: Implement zkas_db_set
This is used specifically for zkas circuits bundled with the WASM
contracts. If necessary, the functions will also create and serialize
VerifyingKey objects needed to verify proofs using the given circuit
and store them in the database for later reference.

We rely on the assumption that `deploy()` will do the db init or
lookup before running so the zkas db handle is always index zero.
2023-03-06 18:33:52 +01:00
parazyd
fd280c6513 runtime: Initialize or lookup a zkas db when running contract deployment. 2023-03-06 18:33:52 +01:00
parazyd
db1908d07e runtime: Add documentation for metadata function. 2023-02-25 14:20:31 +01:00
parazyd
b30843c12c runtime/db: Move the section restriction to the top of functions. 2023-02-25 14:20:29 +01:00
parazyd
fe11151ba9 rustdoc lints 2023-01-18 12:54:32 +01:00
x
9caa49ffa8 disable cursor checks in db_* since it uses an unstable rust feature 2023-01-05 13:45:25 +01:00
x
4c056ceb86 implement dao::exec() update, and add missing db_del() to runtime 2023-01-05 11:02:55 +01:00
x
acb2131747 fix broken log targets 2023-01-02 15:46:19 +01:00