From 4bfe1d70d3c87d397b34148e2a278c238e2040a0 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Tue, 8 Oct 2024 18:39:01 -0400 Subject: [PATCH] Add DisableSubnetValidatorTx complexity tests --- vms/platformvm/txs/fee/calculator_test.go | 12 ++++++++++++ vms/platformvm/txs/fee/complexity.go | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/vms/platformvm/txs/fee/calculator_test.go b/vms/platformvm/txs/fee/calculator_test.go index cfd17b97330f..c128c278c856 100644 --- a/vms/platformvm/txs/fee/calculator_test.go +++ b/vms/platformvm/txs/fee/calculator_test.go @@ -267,5 +267,17 @@ var ( }, expectedDynamicFee: 113_900, }, + { + name: "DisableSubnetValidatorTx", + tx: "00000000002700003039000000000000000000000000000000000000000000000000000000000000000000000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007002386f1f88b4b9e000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c00000001fd91c5c421468b13b09dda413bdbe1316c7c9417f2468b893071d4cb608a01da00000000dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000005002386f1f88b4e5200000001000000000000000038e6e9fe31c6d070a8c792dbacf6d0aefb8eac2aded49cc0aa9f422d1fdd9ecd0000000a00000000000000020000000900000001ff99bb626d898907a660701e2febaa311b4e644fe71add2d1a3f71748102c73f54d73c8370a9ae33e09c984bb8c03da4922bf208af836ec2daaa31cb42788bee010000000900000000", + expectedStaticFeeErr: ErrUnsupportedTx, + expectedComplexity: gas.Dimensions{ + gas.Bandwidth: 347, // The length of the tx in bytes + gas.DBRead: IntrinsicDisableSubnetValidatorTxComplexities[gas.DBRead] + intrinsicInputDBRead, + gas.DBWrite: IntrinsicDisableSubnetValidatorTxComplexities[gas.DBWrite] + intrinsicInputDBWrite + intrinsicOutputDBWrite, + gas.Compute: 0, // TODO: implement + }, + expectedDynamicFee: 114_700, + }, } ) diff --git a/vms/platformvm/txs/fee/complexity.go b/vms/platformvm/txs/fee/complexity.go index 797fad7b566c..1e63e918316b 100644 --- a/vms/platformvm/txs/fee/complexity.go +++ b/vms/platformvm/txs/fee/complexity.go @@ -223,7 +223,8 @@ var ( IntrinsicDisableSubnetValidatorTxComplexities = gas.Dimensions{ gas.Bandwidth: IntrinsicBaseTxComplexities[gas.Bandwidth] + ids.IDLen + // validationID - wrappers.IntLen, // auth typeID + wrappers.IntLen + // auth typeID + wrappers.IntLen, // authCredential typeID gas.DBRead: 0, // TODO gas.DBWrite: 0, // TODO gas.Compute: 0,