limbo/core
Pekka Enberg 1aad1b224a
Merge 'core/io: Make random generation deterministically simulated' from Pedro Muniz
Depends on #3584 to use the most up-to-date implementation of
`ThreadRng`
- Add `fill_bytes` method to `IO`
- use `thread_rng` instead of `getrandom`, as `getrandom` is much slower
and `thread_rng` offers enough security
- modify `exec_randomblob`, `exec_random` and random_rowid generation to
use methods from IO for determinism
- modified simulator IO to implement `fill_bytes`
This the PRNG for sqlite if someone is curious. It is similar to
`thread_rng`:
```c
/* Initialize the state of the random number generator once,
  ** the first time this routine is called.
  */
  if( wsdPrng.s[0]==0 ){
    sqlite3_vfs *pVfs = sqlite3_vfs_find(0);
    static const u32 chacha20_init[] = {
      0x61707865, 0x3320646e, 0x79622d32, 0x6b206574
    };
    memcpy(&wsdPrng.s[0], chacha20_init, 16);
    if( NEVER(pVfs==0) ){
      memset(&wsdPrng.s[4], 0, 44);
    }else{
      sqlite3OsRandomness(pVfs, 44, (char*)&wsdPrng.s[4]);
    }
    wsdPrng.s[15] = wsdPrng.s[12];
    wsdPrng.s[12] = 0;
    wsdPrng.n = 0;
  }

  assert( N>0 );
  while( 1 /* exit by break */ ){
    if( N<=wsdPrng.n ){
      memcpy(zBuf, &wsdPrng.out[wsdPrng.n-N], N);
      wsdPrng.n -= N;
      break;
    }
    if( wsdPrng.n>0 ){
      memcpy(zBuf, wsdPrng.out, wsdPrng.n);
      N -= wsdPrng.n;
      zBuf += wsdPrng.n;
    }
    wsdPrng.s[12]++;
    chacha_block((u32*)wsdPrng.out, wsdPrng.s);
    wsdPrng.n = 64;
  }
  sqlite3_mutex_leave(mutex);
```

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #3799
2025-10-22 09:10:36 +03:00
..
benches add insert randomblob benchmark 2025-10-20 14:47:47 -03:00
ext Add cfg attributes for running under Miri 2025-10-13 14:54:16 -05:00
functions Merge 'printf should truncates floats' from Pavan Nambi 2025-10-01 19:31:39 -04:00
incremental core/mvcc: add btree_cursor under MVCC cursor 2025-10-21 18:22:37 +02:00
io add additional fill_bytes method to IO to deterministically generate 2025-10-21 14:10:38 -03:00
json refactor: remove unsafe reference semantics from RefValue 2025-10-07 10:43:44 -03:00
mvcc Merge 'core/io: Make random generation deterministically simulated' from Pedro Muniz 2025-10-22 09:10:36 +03:00
numeric feat: add CAST to fuzzer 2025-09-24 18:06:55 -03:00
storage Merge 'core/io: Make random generation deterministically simulated' from Pedro Muniz 2025-10-22 09:10:36 +03:00
time Move time extension to core 2025-06-30 10:01:03 +03:00
translate Merge 'Make sure explicit column aliases have binding precedence in orderby' from Pavan Nambi 2025-10-21 19:04:42 +03:00
vdbe Merge 'core/io: Make random generation deterministically simulated' from Pedro Muniz 2025-10-22 09:10:36 +03:00
vector fmt 2025-10-14 22:22:14 +04:00
assert.rs core: Add Antithesis-aware turso_assert 2025-06-29 11:46:18 +03:00
build.rs do not run build.rs on debug mode 2025-10-16 01:22:54 -03:00
Cargo.toml add additional fill_bytes method to IO to deterministically generate 2025-10-21 14:10:38 -03:00
error.rs Add FOREIGN_KEY constraint error 2025-10-07 16:22:20 -04:00
fast_lock.rs remove some unnecessary unsafe impls 2025-09-21 13:29:59 -03:00
function.rs add if alais and allow iff to have more arguments 2025-10-12 22:17:35 +05:30
info.rs implement sqlite_source_id function 2025-01-28 14:55:38 -05:00
lib.rs core: Unsafe Send and Sync pushdown 2025-10-16 11:26:50 +03:00
parameters.rs remove unnecessary enum variant 2025-09-30 14:52:59 +04:00
pragma.rs Add pragma foreign_keys and fk_if_zero and fk_counter opcodes 2025-10-07 16:22:20 -04:00
pseudo.rs clippy 2025-10-09 19:00:40 +03:00
schema.rs Merge 'core: move BTreeCursor under MVCC cursor' from Pere Diaz Bou 2025-10-21 19:20:49 +02:00
series.rs Replace ConstraintInfo::plan_info with ConstraintInfo::index 2025-08-05 05:48:29 +02:00
state_machine.rs mvcc: simplify StateMachine 2025-09-22 16:37:31 +03:00
types.rs Fix build after I/O many completions removal 2025-10-16 17:19:16 +03:00
util.rs Add helpers to rewrite REFERENCES from foriegn keys in ColumnDefinition 2025-10-21 10:40:31 -04:00
uuid.rs Move UUID extension to core 2025-06-30 09:54:13 +03:00
vtab.rs implement json_tree 2025-09-23 14:22:02 -04:00