Skip to content

Commit

Permalink
Merge pull request starknet-io#621 from notV4l/583-rpc-adaptation
Browse files Browse the repository at this point in the history
RPC endpoint adaptation 2
Force merge beside CI:
Devnet RPC 0.3 is not fully ready (simulate)
Infura (Pathfinder) RPC 0.3 is not the default
  • Loading branch information
tabaktoni authored Jun 12, 2023
2 parents df35fcc + ed80330 commit 702873f
Show file tree
Hide file tree
Showing 35 changed files with 6,977 additions and 5,715 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,8 @@ jobs:
# TODO - periodically check if conditional services are supported; https://github.com/actions/runner/issues/822
services:
devnet:
# TODO - The image utilized is a temporary workaround to allow for the RPC request validation
# deactivation argument to be set since the service configuration lacks a corresponding
# functionality; https://github.com/actions/runner/issues/2276.
# It was generated from the following Dockerfile:
# FROM shardlabs/starknet-devnet:0.5.1-seed0
# CMD ["--disable-rpc-request-validation", "--timeout", "600"]
# Switch back to the standard Devnet image once a full release is available.
# image: penovicp/devnet-test:0.5.1
# image: shardlabs/starknet-devnet:0.5.1-seed0
image: ${{ inputs.is-rpc && 'penovicp/devnet-test:0.5.1' || 'shardlabs/starknet-devnet:0.5.2-seed0' }}
# image: ${{ inputs.is-rpc && 'shardlabs/starknet-devnet:0.5.3-seed0' || 'shardlabs/starknet-devnet:0.5.2-seed0' }}
image: shardlabs/starknet-devnet:0.5.3-seed0
ports:
- 5050:5050

Expand Down
48 changes: 5 additions & 43 deletions __mocks__/cairo/account/account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod Account {
use super::Call;
use starknet::ContractAddress;
use zeroable::Zeroable;
use serde::ArraySerde;

struct Storage {
public_key: felt252
Expand Down Expand Up @@ -77,53 +78,14 @@ mod Account {

starknet::call_contract_syscall(
address: to, entry_point_selector: selector, calldata: calldata.span()
).unwrap_syscall()
)
.unwrap_syscall()
}
}

#[derive(Drop)]
#[derive(Drop, Serde)]
struct Call {
to: ContractAddress,
selector: felt252,
calldata: Array<felt252>
}

impl CallSerde of Serde<Call> {
fn serialize(self: @Call, ref output: Array<felt252>) {
let Call{to, selector, calldata } = self;
to.serialize(ref output);
selector.serialize(ref output);
calldata.serialize(ref output);
}

fn deserialize(ref serialized: Span<felt252>) -> Option<Call> {
let to = Serde::<ContractAddress>::deserialize(ref serialized)?;
let selector = Serde::<felt252>::deserialize(ref serialized)?;
let calldata = Serde::<Array<felt252>>::deserialize(ref serialized)?;
Option::Some(Call { to, selector, calldata })
}
}

fn serialize_array_call_helper(ref output: Array<felt252>, mut input: Array<Call>) {
gas::withdraw_gas().expect('Out of gas');
match input.pop_front() {
Option::Some(value) => {
value.serialize(ref output);
serialize_array_call_helper(ref output, input);
},
Option::None(_) => {},
}
}

fn deserialize_array_call_helper(
ref serialized: Span<felt252>, mut curr_output: Array<Call>, remaining: felt252
) -> Option<Array<Call>> {
if remaining == 0 {
return Option::Some(curr_output);
}

gas::withdraw_gas().expect('Out of gas');

curr_output.append(Serde::<Call>::deserialize(ref serialized)?);
deserialize_array_call_helper(ref serialized, curr_output, remaining - 1)
}
}
Loading

0 comments on commit 702873f

Please sign in to comment.