Skip to content

Commit 6b8acf2

Browse files
committed
cleaned up fastcallreadonly
1 parent 50439a0 commit 6b8acf2

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

stackslib/src/net/api/callreadonly.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
use std::time::Duration;
18-
1917
use clarity::vm::analysis::CheckErrors;
2018
use clarity::vm::ast::parser::v1::CLARITY_NAME_REGEX;
2119
use clarity::vm::clarity::ClarityConnection;
22-
use clarity::vm::costs::{CostErrors, ExecutionCost, LimitedCostTracker};
20+
use clarity::vm::costs::{ExecutionCost, LimitedCostTracker};
2321
use clarity::vm::errors::Error::Unchecked;
2422
use clarity::vm::errors::{Error as ClarityRuntimeError, InterpreterError};
2523
use clarity::vm::representations::{CONTRACT_NAME_REGEX_STRING, STANDARD_PRINCIPAL_REGEX_STRING};
@@ -218,8 +216,6 @@ impl RPCRequestHandler for RPCCallReadOnlyRequestHandler {
218216
cost_limit.write_length = 0;
219217
cost_limit.write_count = 0;
220218

221-
let mut enforce_max_execution_time = false;
222-
223219
chainstate.maybe_read_only_clarity_tx(
224220
&sortdb.index_handle_at_block(chainstate, &tip)?,
225221
&tip,

stackslib/src/net/api/fastcallreadonly.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ use std::time::Duration;
1919
use clarity::vm::analysis::CheckErrors;
2020
use clarity::vm::ast::parser::v1::CLARITY_NAME_REGEX;
2121
use clarity::vm::clarity::ClarityConnection;
22-
use clarity::vm::costs::{CostErrors, ExecutionCost, LimitedCostTracker};
22+
use clarity::vm::costs::{ExecutionCost, LimitedCostTracker};
23+
use clarity::vm::errors::Error as ClarityRuntimeError;
2324
use clarity::vm::errors::Error::Unchecked;
24-
use clarity::vm::errors::{Error as ClarityRuntimeError, InterpreterError};
2525
use clarity::vm::representations::{CONTRACT_NAME_REGEX_STRING, STANDARD_PRINCIPAL_REGEX_STRING};
26-
use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier};
26+
use clarity::vm::types::PrincipalData;
2727
use clarity::vm::{ClarityName, ContractName, SymbolicExpression, Value};
2828
use regex::{Captures, Regex};
2929
use stacks_common::types::chainstate::StacksAddress;
@@ -50,15 +50,17 @@ pub struct RPCFastCallReadOnlyRequestHandler {
5050
}
5151

5252
impl RPCFastCallReadOnlyRequestHandler {
53-
pub fn new(
54-
maximum_call_argument_size: u32,
55-
read_only_call_limit: ExecutionCost,
56-
read_only_max_execution_time: Duration,
57-
) -> Self {
53+
pub fn new(maximum_call_argument_size: u32, read_only_max_execution_time: Duration) -> Self {
5854
Self {
5955
call_read_only_handler: RPCCallReadOnlyRequestHandler::new(
6056
maximum_call_argument_size,
61-
read_only_call_limit,
57+
ExecutionCost {
58+
write_length: 0,
59+
write_count: 0,
60+
read_length: 0,
61+
read_count: 0,
62+
runtime: 0,
63+
},
6264
),
6365
read_only_max_execution_time,
6466
}
@@ -200,14 +202,10 @@ impl RPCRequestHandler for RPCFastCallReadOnlyRequestHandler {
200202
let mainnet = chainstate.mainnet;
201203
let chain_id = chainstate.chain_id;
202204

203-
let mut enforce_max_execution_time = false;
204-
205205
chainstate.maybe_read_only_clarity_tx(
206206
&sortdb.index_handle_at_block(chainstate, &tip)?,
207207
&tip,
208208
|clarity_tx| {
209-
let epoch = clarity_tx.get_epoch();
210-
211209
let clarity_version = clarity_tx
212210
.with_analysis_db_readonly(|analysis_db| {
213211
analysis_db.get_clarity_version(&contract_identifier)

stackslib/src/net/api/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ impl StacksHttp {
7777
));
7878
self.register_rpc_endpoint(fastcallreadonly::RPCFastCallReadOnlyRequestHandler::new(
7979
self.maximum_call_argument_size,
80-
self.read_only_call_limit.clone(),
8180
self.read_only_max_execution_time,
8281
));
8382
self.register_rpc_endpoint(getaccount::RPCGetAccountRequestHandler::new());

stackslib/src/net/api/tests/fastcallreadonly.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,8 @@ fn test_try_parse_request() {
5959
debug!("Request:\n{}\n", std::str::from_utf8(&bytes).unwrap());
6060

6161
let (parsed_preamble, offset) = http.read_preamble(&bytes).unwrap();
62-
let mut handler = fastcallreadonly::RPCFastCallReadOnlyRequestHandler::new(
63-
4096,
64-
BLOCK_LIMIT_MAINNET_21,
65-
Duration::from_secs(30),
66-
);
62+
let mut handler =
63+
fastcallreadonly::RPCFastCallReadOnlyRequestHandler::new(4096, Duration::from_secs(30));
6764
let mut parsed_request = http
6865
.handle_try_parse_request(
6966
&mut handler,

0 commit comments

Comments
 (0)