Skip to content
/ tbbr Public

Time-Bucketed Balance Records: Bounded-Storage Ephemeral Tokens for Resource-Constrained Systems

Notifications You must be signed in to change notification settings

glanzz/tbbr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Time-Bucketed Balance Records: Bounded-Storage Ephemeral Tokens for Resource-Constrained Systems

This folder contains the experimental setup for measuring gas costs of the time-bucketed balance record algorithm.

The algorithm is dependent on evm-auth.

Running the Experiments

Add to evmauth tests

Add the current repository into test/ folder of evmauth-core repository.

Quick Gas Snapshot

# From the repository root
forge test --match-path test/tbbr/*.sol --gas-report

Generate Gas Snapshots

# Create a gas snapshot file
forge snapshot --match-path "test/*.sol" --snap test/tbbr/.gas-snapshot

# Compare with previous snapshot
forge snapshot --match-path "test/tbbr/*.sol" --diff test/tbbr/.gas-snapshot

Run with Verbose Output

forge test --match-path test/tbbr/*.sol -vvv

Run Specific Test

forge test --match-test "test_gas_" -vvv

Run All Benchmarks with Script

./test/paper1_experiments/run_benchmarks.sh

Experiments

1. Basic Operation Costs (GasBenchmark.t.sol)

Measures gas for core operations:

  • Mint (new record): First mint creating a new balance record
  • Mint (coalesce): Mint within same time bucket (record merging)
  • Transfer: FIFO consumption from sender + insert to recipient
  • Burn: FIFO consumption
  • Balance query: View function cost
  • Prune: Cleanup of expired/empty records

2. Scaling Analysis (GasScaling.t.sol)

Measures how gas scales with:

  • Number of existing records (1, 10, 50, 100)
  • Various TTL configurations
  • Worst-case insertion (shifting all elements)

3. DoS Resistance (GasDoS.t.sol)

Demonstrates bounded gas costs:

  • Adversary creates many deposits
  • Victim's operation cost remains O(k)

Results

Basic Operations (k=100, TTL=30 days):

Operation Gas Cost
Mint (new record) 95,407
Mint (coalesce) 4,931
Transfer 94,853
Burn 4,511
Balance query 2,265

Worst-case (100 records):

Operation Gas Cost
Burn all records 335,499
Transfer all records 9,994,917

Releases

No releases published

Packages

No packages published