Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/flamenco/runtime/fd_cost_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#define FD_COST_TRACKER_ERROR_WOULD_EXCEED_ACCOUNT_DATA_TOTAL_LIMIT (5)

FD_STATIC_ASSERT( FD_WRITE_LOCK_UNITS*FD_RUNTIME_MAX_TXN_ACC_WRITES_PER_SLOT +
FD_PACK_COST_PER_SIGNATURE*((FD_RUNTIME_MAX_TXN_ACC_WRITES_PER_SLOT+63UL)/64UL)<=87500000UL,
FD_PACK_COST_PER_SIGNATURE*((FD_RUNTIME_MAX_TXN_ACC_WRITES_PER_SLOT+MAX_TX_ACCOUNT_LOCKS-1UL)/MAX_TX_ACCOUNT_LOCKS)<=FD_PACK_MAX_COST_PER_BLOCK_UPPER_BOUND,
max_writable_accounts_per_slot_fits );
FD_STATIC_ASSERT( FD_WRITE_LOCK_UNITS*(FD_RUNTIME_MAX_TXN_ACC_WRITES_PER_SLOT+1UL) +
FD_PACK_COST_PER_SIGNATURE*((FD_RUNTIME_MAX_TXN_ACC_WRITES_PER_SLOT+64UL)/64UL)>87500000UL,
FD_PACK_COST_PER_SIGNATURE*((FD_RUNTIME_MAX_TXN_ACC_WRITES_PER_SLOT+MAX_TX_ACCOUNT_LOCKS)/MAX_TX_ACCOUNT_LOCKS)>FD_PACK_MAX_COST_PER_BLOCK_UPPER_BOUND,
max_writable_accounts_per_slot_is_tight );

/* TODO: Extremely gross. Used because these are in a pool which needs
Expand Down
14 changes: 7 additions & 7 deletions src/flamenco/runtime/fd_runtime_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ FD_PROTOTYPES_BEGIN
#define FD_RUNTIME_ACC_SZ_MAX (10UL<<20) /* 10MiB */

/* Bound the number of distinct writable accounts that can enter the
cost tracker in an 87.5M CU block. A transaction with w writable
cost tracker in a 100M CU block. A transaction with w writable
accounts costs at least 720+300*w CUs and carries at most 64 writable
accounts. Thus W writables need at least ceil(W/64) transactions:

300*W + 720*ceil(W/64) <= 87500000
300*W + 720*ceil(W/64) <= 100000000

The largest solution is 281123: 4392 full 64-account transactions
plus one 35-account transaction cost 87499860 CUs. A 281124th
writable would cost 87500160 CUs. */
The largest solution is 321282: 5020 full 64-account transactions
plus one 2-account transaction cost 99999720 CUs. A 321283rd
writable would cost 100000020 CUs. */

#define FD_RUNTIME_MAX_TXN_ACC_WRITES_PER_SLOT (281123UL)
#define FD_RUNTIME_MAX_TXN_ACC_WRITES_PER_SLOT (321282UL)

/* With 100M stake accounts, ceil(100M/4096)=24415 partitions.
Assuming uniform hashing, one partition has
Expand All @@ -96,7 +96,7 @@ FD_PROTOTYPES_BEGIN
on the number of unique accounts that can be written to in a single
slot. The worst case can be defined by:
1. Worst case number of writable accounts in a slot from worst-case
transactions. This bound comes from the cost tracker: 281123.
transactions. This bound comes from the cost tracker: 321282.
2. During partitioned epoch rewards. A reasonable upper bound is
8192 accounts per stake partition since the odds of this happening
are very very low.
Expand Down
6 changes: 3 additions & 3 deletions src/flamenco/runtime/test_cost_tracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ test_cost_tracker_init_reconciliation( fd_cost_tracker_t * ct ) {
fd_cost_tracker_init( ct, &f, &FD_SLOT_PARAMS_400MS, SLOT );
FD_TEST( ct->block_cost_limit ==60000000UL );
FD_TEST( ct->account_cost_limit==24000000UL );
FD_TEST( ct->data_size_limit ==100000000UL );
FD_TEST( ct->data_size_limit ==FD_PACK_MAX_ALLOCATED_DATA_PER_BLOCK );

/* 400ms + raise_block_limits_to_100m: table scaled by 100/60 ->
100M / 40M. */
memset( &f, 0xFF, sizeof(f) );
f.raise_block_limits_to_100m = 0UL;
fd_cost_tracker_init( ct, &f, &FD_SLOT_PARAMS_400MS, SLOT );
FD_TEST( ct->block_cost_limit ==100000000UL );
FD_TEST( ct->block_cost_limit ==FD_PACK_MAX_COST_PER_BLOCK_UPPER_BOUND );
FD_TEST( ct->account_cost_limit==40000000UL );
FD_TEST( ct->data_size_limit ==100000000UL );
FD_TEST( ct->data_size_limit ==FD_PACK_MAX_ALLOCATED_DATA_PER_BLOCK );

/* 200ms + 100m: regime table scaled by 100/60 -> 50M / 20M / 50M. */
memset( &f, 0xFF, sizeof(f) );
Expand Down
Loading