Skip to content

Commit 060b56e

Browse files
authored
Merge pull request #6632 from obycode/feat/clarity-4-costs
feat: add costs for Clarity 4
2 parents 3e7ecdb + 2ba6843 commit 060b56e

5 files changed

+32
-36
lines changed

clarity/src/vm/costs/costs_4.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ impl CostValues for Costs4 {
450450

451451
fn cost_contract_hash(_n: u64) -> InterpreterResult<ExecutionCost> {
452452
Ok(ExecutionCost {
453-
runtime: 100, // TODO: needs criterion benchmark
453+
runtime: 188,
454454
write_length: 0,
455455
write_count: 0,
456456
read_count: 1,
@@ -459,22 +459,18 @@ impl CostValues for Costs4 {
459459
}
460460

461461
fn cost_to_ascii(n: u64) -> InterpreterResult<ExecutionCost> {
462-
// TODO: needs criterion benchmark
463-
Ok(ExecutionCost::runtime(linear(n, 1, 100)))
462+
Ok(ExecutionCost::runtime(linear(n, 16, 150)))
464463
}
465464

466465
fn cost_restrict_assets(n: u64) -> InterpreterResult<ExecutionCost> {
467-
// TODO: needs criterion benchmark
468-
Ok(ExecutionCost::runtime(linear(n, 1, 100)))
466+
Ok(ExecutionCost::runtime(linear(n, 125, 750)))
469467
}
470468

471469
fn cost_as_contract_safe(n: u64) -> InterpreterResult<ExecutionCost> {
472-
// TODO: needs criterion benchmark
473-
Ok(ExecutionCost::runtime(linear(n, 1, 100)))
470+
Ok(ExecutionCost::runtime(linear(n, 125, 888)))
474471
}
475472

476473
fn cost_secp256r1verify(n: u64) -> InterpreterResult<ExecutionCost> {
477-
// TODO: needs criterion benchmark
478-
Ok(ExecutionCost::runtime(1))
474+
Ok(ExecutionCost::runtime(51750))
479475
}
480476
}

stackslib/src/chainstate/stacks/boot/costs-4.clar

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -654,21 +654,21 @@
654654

655655
(define-read-only (cost_contract_hash (n uint))
656656
{
657-
runtime: u100, ;; TODO: needs criterion benchmark
657+
runtime: u188,
658658
write_length: u0,
659659
write_count: u0,
660660
read_count: u1,
661661
read_length: u32
662662
})
663663

664664
(define-read-only (cost_to_ascii (n uint))
665-
(runtime (linear n u1 u100))) ;; TODO: needs criterion benchmark
665+
(runtime (linear n u16 u150)))
666666

667667
(define-read-only (cost_restrict_assets (n uint))
668-
(runtime (linear n u1 u100))) ;; TODO: needs criterion benchmark
668+
(runtime (linear n u125 u750)))
669669

670670
(define-read-only (cost_as_contract_safe (n uint))
671-
(runtime (linear n u1 u100))) ;; TODO: needs criterion benchmark
671+
(runtime (linear n u125 u888)))
672672

673673
(define-read-only (cost_secp256r1verify (n uint))
674-
(runtime u1)) ;; TODO: needs criterion benchmark
674+
(runtime u51750))

stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__append_stx_transfers_success.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ expression: result
6262
),
6363
)),
6464
Success(ExpectedBlockOutput(
65-
marf_hash: "84fd4d4a87d53924cb9743c1f5448b42d6a4b08f3c8b50feb6f49415ec8dc644",
65+
marf_hash: "180457415b54799e13905b076af575c96c77614e13e26f8211aa32e7cb1e893e",
6666
evaluated_epoch: Epoch33,
6767
transactions: [
6868
ExpectedTransactionOutput(

stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__chainstate_error_expression_stack_depth_too_deep.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ expression: result
66
Failure("Invalid Stacks block 4283815e1f66aa52f455cfe8a415c8ff1c3d28794b83a08384534e30650554e2: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
77
Failure("Invalid Stacks block b97c37a0da184764a8eb0769d6c8a9af0a6c98b0e6c950423d324286a349bf0c: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
88
Failure("Invalid Stacks block 121b03507be0248b0abd05ccf93403e3c50bd8969e8b1c4d2d3f215fd6243576: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
9-
Failure("Invalid Stacks block 322a20636ec464a2931d73e6e7d8d30f53d991c7b8671fb9111e257c4c223e29: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
10-
Failure("Invalid Stacks block 21f04d05a17d11025270fe3dc95dc67aac9a01f8853a139a9d126308b69104e5: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
11-
Failure("Invalid Stacks block 6e0c907eae08ccabff1b2c36a15a072d81c895462a934d9a745006c009690ace: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
12-
Failure("Invalid Stacks block 75ff54adb614d195487f2a0bb1706fde20bc366d3e8e1459f1cae14d542546c0: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
9+
Failure("Invalid Stacks block 0cb105df328cc9565f4817071f27374a10d73f1fd88a2a91ccf2885b41bef3e3: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
10+
Failure("Invalid Stacks block 516690436438389acc8b58ea7bbbd0a04d844f4f69f8d1ea0500458d9fa8e4d7: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
11+
Failure("Invalid Stacks block 96d7c8d5ce7b5452a16079b20a97effd3d3c839e0d97af86484df1f5e48c2b74: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
12+
Failure("Invalid Stacks block 57ed3ad80ddb289a20f936cc27ad6c07640b5f3f5acfbfcda39a900dc38735f3: ClarityError(Parse(ParseError { err: ExpressionStackDepthTooDeep, pre_expressions: None, diagnostic: Diagnostic { level: Error, message: \"AST has too deep of an expression nesting. The maximum stack depth is 64\", spans: [], suggestion: None } }))"),
1313
]

stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__consensus__successfully_deploy_and_call.snap

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ expression: result
508508
),
509509
)),
510510
Success(ExpectedBlockOutput(
511-
marf_hash: "38a8f28f1e3fefc43a38f84dc1791b082e0e0485594a52f06fe1308c519d3336",
511+
marf_hash: "a4d7a7e6071908e2780d665ce73f1fc248a06419857e1148af6a289b178f7562",
512512
evaluated_epoch: Epoch33,
513513
transactions: [
514514
ExpectedTransactionOutput(
@@ -536,7 +536,7 @@ expression: result
536536
),
537537
)),
538538
Success(ExpectedBlockOutput(
539-
marf_hash: "5f3f3254cdda89fa216c1d65db1651c0d07cf35546d90a5cfab4bb67706dd322",
539+
marf_hash: "f93629deb181a073d7f1f7f26c1b4d2eaf844cff08f74c2fd9881fa19c4d8408",
540540
evaluated_epoch: Epoch33,
541541
transactions: [
542542
ExpectedTransactionOutput(
@@ -564,7 +564,7 @@ expression: result
564564
),
565565
)),
566566
Success(ExpectedBlockOutput(
567-
marf_hash: "fcbd175bb6eebab2f11944dec89551ab91b61556dcecadd159ede09d268ed20f",
567+
marf_hash: "0a43d8c0d910d9a2ca58b723c4533c63e1c32ca90dce7fab5cfe9216c5e34432",
568568
evaluated_epoch: Epoch33,
569569
transactions: [
570570
ExpectedTransactionOutput(
@@ -592,7 +592,7 @@ expression: result
592592
),
593593
)),
594594
Success(ExpectedBlockOutput(
595-
marf_hash: "cf3ce058c2bb36af66d1b10601ecb199844748e4d3a7a3e8bd74bb61634061a2",
595+
marf_hash: "ec3fa2b2fa5766499c2ee43c70c59c09d65ab9d04b04bcecf86117224243ebf7",
596596
evaluated_epoch: Epoch33,
597597
transactions: [
598598
ExpectedTransactionOutput(
@@ -620,7 +620,7 @@ expression: result
620620
),
621621
)),
622622
Success(ExpectedBlockOutput(
623-
marf_hash: "634e97e600c79304fe44e9e321802fc994a7f9d06a6f8e37d30ea4511b003e69",
623+
marf_hash: "d3451f558343a34dc1013cacf3f9c07d04f76bf84e1f5ff7a5738230364c453f",
624624
evaluated_epoch: Epoch33,
625625
transactions: [
626626
ExpectedTransactionOutput(
@@ -648,7 +648,7 @@ expression: result
648648
),
649649
)),
650650
Success(ExpectedBlockOutput(
651-
marf_hash: "85cafa36a1e414404b8fe8803d0f25fb15f0b95ce9409117808632719660c48c",
651+
marf_hash: "56f27df16675d8dbe666f8d0793c8f31fe8a7616436f0638041dad6aaf12ffd7",
652652
evaluated_epoch: Epoch33,
653653
transactions: [
654654
ExpectedTransactionOutput(
@@ -676,7 +676,7 @@ expression: result
676676
),
677677
)),
678678
Success(ExpectedBlockOutput(
679-
marf_hash: "c0939834a96f607582e250b4be680efd7cf2f1d89ec8409317236aa4268ff11d",
679+
marf_hash: "61ed7b44320cc7100664c4732d431d0e3103869bbb8e7b095a2a2cb256b32f41",
680680
evaluated_epoch: Epoch33,
681681
transactions: [
682682
ExpectedTransactionOutput(
@@ -704,7 +704,7 @@ expression: result
704704
),
705705
)),
706706
Success(ExpectedBlockOutput(
707-
marf_hash: "7e3bc89f4f80cc392cd0ebddab5ab5958a1279995809d1803729098e94481431",
707+
marf_hash: "3dd0da4b5c81ddb60394adc0078f07951b94be164b0acbb3dc18dd7a824f38b3",
708708
evaluated_epoch: Epoch33,
709709
transactions: [
710710
ExpectedTransactionOutput(
@@ -732,7 +732,7 @@ expression: result
732732
),
733733
)),
734734
Success(ExpectedBlockOutput(
735-
marf_hash: "d5f11dacb02acf78898e99122f9683e56f65b56669921f7ff4ba51e584628217",
735+
marf_hash: "d615a756f0feeda86821fc3df4176ac8ad81403fc4d8cc905cbe23e32eeb97a2",
736736
evaluated_epoch: Epoch33,
737737
transactions: [
738738
ExpectedTransactionOutput(
@@ -760,7 +760,7 @@ expression: result
760760
),
761761
)),
762762
Success(ExpectedBlockOutput(
763-
marf_hash: "f8ab58d9665439bcfbfc753593f94dddb11e1bac4d8987bce0b78819fd179633",
763+
marf_hash: "13274516ac921e85a216911865d829fde2a03ec6069f184aea8d872cd2d68691",
764764
evaluated_epoch: Epoch33,
765765
transactions: [
766766
ExpectedTransactionOutput(
@@ -788,7 +788,7 @@ expression: result
788788
),
789789
)),
790790
Success(ExpectedBlockOutput(
791-
marf_hash: "ddc153d05ab9ae0d4493495db42639a40a63f5a2e106f3885a5d520a0886c8d3",
791+
marf_hash: "03f0b38ef9c1689d6b6d94c6dafb3559aeca63b3e4a20e2b3095afe470e228a1",
792792
evaluated_epoch: Epoch33,
793793
transactions: [
794794
ExpectedTransactionOutput(
@@ -816,7 +816,7 @@ expression: result
816816
),
817817
)),
818818
Success(ExpectedBlockOutput(
819-
marf_hash: "82a7a177456bf6167394a18c28d202778143bed833b1f36593f8f6d9650036fc",
819+
marf_hash: "bddb1e348ec4af76001dd26054a5b15f7ee73734a33a96d1f42b8d070401f3d0",
820820
evaluated_epoch: Epoch33,
821821
transactions: [
822822
ExpectedTransactionOutput(
@@ -844,7 +844,7 @@ expression: result
844844
),
845845
)),
846846
Success(ExpectedBlockOutput(
847-
marf_hash: "f345911217eefdfe2be7758b93a636570ca3789dd1d1b4c21d504824ea7521fa",
847+
marf_hash: "b36b6a71291844658462fd63b1404505dac195ab6d1e0f617ce741b6763bc002",
848848
evaluated_epoch: Epoch33,
849849
transactions: [
850850
ExpectedTransactionOutput(
@@ -872,7 +872,7 @@ expression: result
872872
),
873873
)),
874874
Success(ExpectedBlockOutput(
875-
marf_hash: "60820a72ff037030f3ca671da33826e5c2aaa7a4879f4d1bfcc588aee57ffd34",
875+
marf_hash: "1509e7208cbc57f11f7130e9a723d88a55bd7dd7d1db21bfebde27694f82a3c9",
876876
evaluated_epoch: Epoch33,
877877
transactions: [
878878
ExpectedTransactionOutput(
@@ -900,7 +900,7 @@ expression: result
900900
),
901901
)),
902902
Success(ExpectedBlockOutput(
903-
marf_hash: "a72f90d536cc70ca84abbd298204830afe27abd284fbd3a60b5b0059f616ff45",
903+
marf_hash: "b35dd5af7b0489b95ad09fc4a4a0cd824e0722d54dcfefb97331062ccad7d411",
904904
evaluated_epoch: Epoch33,
905905
transactions: [
906906
ExpectedTransactionOutput(
@@ -928,7 +928,7 @@ expression: result
928928
),
929929
)),
930930
Success(ExpectedBlockOutput(
931-
marf_hash: "d133b26622ba4072dcd51b738709092d7040a225464cefc5f693ce9a7b55a54c",
931+
marf_hash: "f93386433ae622b3ccbac5c4f8fca3de479af09ee16ad7935a521b68f5a3713f",
932932
evaluated_epoch: Epoch33,
933933
transactions: [
934934
ExpectedTransactionOutput(
@@ -956,7 +956,7 @@ expression: result
956956
),
957957
)),
958958
Success(ExpectedBlockOutput(
959-
marf_hash: "19cf5df2dab4cb0d66d92edc65fd3a4872375313661e98771ba48404d7246f3e",
959+
marf_hash: "3717b93edcec46ca2e785a0709ffd725ff078b2cdf3ddc8b7fa0eb9a2bb8e4d0",
960960
evaluated_epoch: Epoch33,
961961
transactions: [
962962
ExpectedTransactionOutput(

0 commit comments

Comments
 (0)