Skip to content

refactor(rpc): override the max steps versioned constant only if value provided by user #2773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/juno/juno.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const (
defaultCNL1ChainID = ""
defaultCNL2ChainID = ""
defaultCNCoreContractAddressStr = ""
defaultCallMaxSteps = 4_000_000
defaultCallMaxSteps = 0
defaultGwTimeout = "5s,"
defaultCorsEnable = false
defaultVersionedConstantsFile = ""
Expand Down Expand Up @@ -178,7 +178,8 @@ const (
"- Single value (e.g. '5s'): After each failure, the timeout will increase dynamically \n" +
"- Comma-separated list (e.g. '5s,10s,20s'): Each value will be used in sequence after failures. " +
"- Single value with trailing comma (e.g. '5s,'): Uses a fixed timeout without dynamic adjustment"
callMaxStepsUsage = "Maximum number of steps to be executed in starknet_call requests"
callMaxStepsUsage = "Maximum number of steps to be executed in starknet_call requests. " +
"If not provided, the value will be fetched from versioned constants"
corsEnableUsage = "Enable CORS on RPC endpoints"
versionedConstantsFileUsage = "Use custom versioned constants from provided file"
pluginPathUsage = "Path to the plugin .so file"
Expand Down
2 changes: 1 addition & 1 deletion cmd/juno/juno_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestConfigPrecedence(t *testing.T) {
defaultRPCMaxBlockScan := uint(math.MaxUint)
defaultMaxCacheSize := uint(1024)
defaultMaxHandles := 1024
defaultCallMaxSteps := uint(4_000_000)
defaultCallMaxSteps := uint(0)
defaultGwTimeout := "5s,"

tests := map[string]struct {
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/_config-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
| `pprof-host` | `localhost` | The interface on which the pprof HTTP server will listen for requests |
| `pprof-port` | `6062` | The port on which the pprof HTTP server will listen for requests |
| `remote-db` | | gRPC URL of a remote Juno node |
| `rpc-call-max-steps` | `4000000` | Maximum number of steps to be executed in starknet_call requests |
| `rpc-call-max-steps` | | Maximum number of steps to be executed in starknet_call requests. If not provided, the value will be fetched from versioned constants |
| `rpc-cors-enable` | `false` | Enable CORS on RPC endpoints |
| `rpc-max-block-scan` | `18446744073709551615` | Maximum number of blocks scanned in single starknet_getEvents call |
| `versioned-constants-file` | | Use custom versioned constants from provided file |
Expand Down
4 changes: 3 additions & 1 deletion vm/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,9 @@ fn build_block_context(
}
let mut constants = get_versioned_constants(block_info.version);
if let Some(max_steps) = max_steps {
constants.invoke_tx_max_n_steps = max_steps as u32;
if max_steps > 0 {
constants.invoke_tx_max_n_steps = max_steps as u32;
}
}

let block_info = BlockifierBlockInfo {
Expand Down
8 changes: 0 additions & 8 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,6 @@ func makeCBlockInfo(blockInfo *BlockInfo) C.BlockInfo {
return cBlockInfo
}

func makeByteFromBool(b bool) byte {
var boolByte byte
if b {
boolByte = 1
}
return boolByte
}

func (v *vm) Call(callInfo *CallInfo, blockInfo *BlockInfo, state core.StateReader,
network *utils.Network, maxSteps uint64, sierraVersion string, structuredErrStack, returnStateDiff bool,
) (CallResult, error) {
Expand Down
2 changes: 1 addition & 1 deletion vm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestCallDeprecatedCairoMaxSteps(t *testing.T) {
ContractAddress: contractAddr,
ClassHash: classHash,
Selector: entryPoint,
}, &BlockInfo{Header: &core.Header{}}, testState, &utils.Mainnet, 0, simpleClass.SierraVersion(), false, false)
}, &BlockInfo{Header: &core.Header{}}, testState, &utils.Mainnet, 1, simpleClass.SierraVersion(), false, false)
assert.ErrorContains(t, err, "RunResources has no remaining steps")
}

Expand Down
Loading