"""Reproduce the synthetic editorial examples, using Python's standard library. Run: python reproduce-calculations.py.txt --output ./litecoin-scenarios-20261021 No network, node RPC, transaction signing or broadcasting is performed. """ from pathlib import Path from decimal import Decimal, ROUND_HALF_UP import argparse,csv,json D=Decimal def write_csv(out,name,header,rows): with (out/name).open('w',encoding='utf-8',newline='') as f: w=csv.writer(f);w.writerow(header);w.writerows(rows) def generate(out): out=Path(out);out.mkdir(parents=True,exist_ok=True) budget,overhead,interval=1_000_000,1_000,150 scaling=[] for vsize in [140,250,500,1000]: count=(budget-overhead)//vsize tps=D(count)/interval scaling.append(['synthetic_capacity',4_000_000,overhead,vsize,count,interval,str(tps),str(tps.quantize(D('.01'),rounding=ROUND_HALF_UP)),'Other consensus/policy constraints omitted; full-budget target-spacing scenario']) assert [x[4] for x in scaling]==[7135,3996,1998,999] write_csv(out,'scaling-scenarios.csv',['kind','block_weight_limit_WU','chosen_overhead_vB','transaction_vsize','transactions_per_modeled_block','target_seconds','nominal_tps_unrounded','display_tps','scope'],scaling) energy=[] for ident,h,e in [('H1_E150','1','150'),('H1_E210','1','210'),('H1_E300','1','300'),('H3_E210','3','210'),('H1_WEIGHTED','1','198')]: H,E,F,hours=map(D,[h,e,'1.10','8760']) it_mw=H*E facility=it_mw*F twh=facility*hours/D(1_000_000) energy.append([ident,'synthetic_realized_work',H,E,F,it_mw,facility,hours,twh,'150/300 efficiencies and all fleet work rates are hypothetical; 210 is the cited L9 specification']) assert D('0.50')*150+D('0.30')*210+D('0.20')*300==198 assert energy[1][8]==D('2.02356') and energy[3][8]==D('6.07068') and energy[4][8]==D('1.907928') write_csv(out,'energy-scenarios.csv',['id','kind','realized_hashrate_PH_s','efficiency_J_GH','assumed_facility_multiplier','active_IT_MW','facility_MW','hours','energy_TWh','scope'],energy) devices=[] for u,idle in [('1','0'),('0.95','0'),('0.95','100')]: run,uptime,idle_w=map(D,['3360',u,idle]) avg=run*uptime+idle_w*(1-uptime) kwh=avg/D(1000)*24 devices.append([run,uptime,idle_w,avg,24,kwh,'Idle values and duty fractions are hypothetical; running power is the typical L9 specification; site loads excluded']) assert [x[5] for x in devices]==[D('80.64'),D('76.608'),D('76.728')] write_csv(out,'device-energy.csv',['running_W','running_fraction','idle_W','average_device_W','hours','energy_kWh','scope'],devices) fees=[] for rate in ['0.00001000','0.00002000','0.00005000']: lt_vb=D(rate)*100000 litoshis=lt_vb*200 fees.append(['synthetic_rate',rate,200,lt_vb,litoshis,litoshis/D(100000000),'LTC/kB rate converted using 1000 vB; transparent example only']) write_csv(out,'mempool-calculations.csv',['kind','rpc_rate_LTC_kB','vsize','rate_litoshi_vB','fee_litoshis','fee_LTC','scope'],fees) parent_size,child_size,parent_fee,child_fee=200,100,200,800 package_rate=D(parent_fee+child_fee)/D(parent_size+child_size) assert package_rate.quantize(D('.01'),rounding=ROUND_HALF_UP)==D('3.33') write_csv(out,'mempool-dependency.csv',['kind','vsize','fee_litoshis','rate_litoshi_vB'],[ ['synthetic_parent',parent_size,parent_fee,D(parent_fee)/parent_size], ['synthetic_child',child_size,child_fee,D(child_fee)/child_size], ['synthetic_combined',parent_size+child_size,parent_fee+child_fee,package_rate]]) entry={ 'vsize':200,'ancestorcount':1,'descendantcount':1, 'fees':{'base':0.000004,'modified':0.000004,'ancestor':0.000004,'descendant':0.000004}, 'depends':[],'spentby':[],'bip125-replaceable':False,'unbroadcast':False} rpc={'example_type':'synthetic; selected fields only; not a node observation','core_reference':'v0.21.5.8','transaction_scope':'transparent; no MWEB weight','selected_getmempoolentry_fields':entry,'calculation':{'base_fee_litoshis':400,'vsize':200,'rate_litoshi_vB':2},'dependency_example':{'parent_vsize':parent_size,'parent_fee_litoshis':parent_fee,'child_vsize':child_size,'child_fee_litoshis':child_fee,'combined_rate_litoshi_vB':str(package_rate)},'limits':'No actual transaction, policy acceptance or global propagation is asserted.'} (out/'mempool-rpc-example.json').write_text(json.dumps(rpc,indent=2),encoding='utf-8') node={'example_type':'synthetic selected fields; not a mainnet snapshot','core_reference':'v0.21.5.8','example_configuration':{'server':1,'disablewallet':1,'prune':10000,'listen':0},'selected_getblockchaininfo_fields':{'chain':'main','blocks':3200000,'headers':3200000,'initialblockdownload':False,'verificationprogress':0.9999,'pruned':True,'pruneheight':3180000,'automatic_pruning':True,'prune_target_size':10000*1024*1024},'interpretation':['Check tip freshness and a recent block hash separately.','A pruning target is not the total data-directory size.','A synchronization estimate is not a confirmation or security guarantee.'],'measurement_claim':False} assert node['selected_getblockchaininfo_fields']['prune_target_size']==10485760000 (out/'node-rpc-example.json').write_text(json.dumps(node,indent=2),encoding='utf-8') # Validate the capacity inputs independently against the stated weight identity. for row in scaling: assert row[4]*row[3]+overhead<=budget assert (row[4]+1)*row[3]+overhead>budget print(json.dumps({'generated_files':7,'scaling_rows':len(scaling),'energy_rows':len(energy),'device_rows':len(devices),'fee_rows':len(fees),'assertions':'passed'},indent=2)) if __name__=='__main__': parser=argparse.ArgumentParser(description=__doc__) parser.add_argument('--output',default='litecoin-scenarios-20261021') generate(parser.parse_args().output)