Skip to content
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

Restructure repo #102

Merged
merged 14 commits into from
May 2, 2022
Merged
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
7 changes: 4 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ jobs:
sudo apt install -y libgmp3-dev
python -m pip install --upgrade pip
pip install -r requirements.txt

pip install werkzeug==2.0.3
pip install marshmallow-dataclass==8.5.3 --force

- name: Run Linters
run: |
yarn check-format
run: yarn check-format
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,20 @@ To run these tests locally:

#### Install and run [StarkNet Devnet](https://github.com/Shard-Labs/starknet-devnet) (In a separate terminal):
```bash
pip install starknet-devnet
starknet-devnet -p 8000
yarn chain:l2
```

#### Run an ethereum hardhat node (In a separate terminal)

```bash
npx hardhat node
yarn chain:l1
```

#### Run tests:
```bash
yarn test
# You can also use `yarn test:l1` to just test the solidity contracts,
# `yarn test:l2` to just test the cairo contracts,
# and `yarn test:l1l2` to test the cross chain flow
yarn test:l1
yarn test:l2
yarn test:crosschain
```

## DISCLAIMER: STILL IN DEVELOPMENT
Expand All @@ -70,5 +68,5 @@ This project is still under heavy development. Feel free to contact us on [Disco

## License

Snapshot is open-source software licensed under the © [MIT license](LICENSE).
Snapshot X contracts are open-source software licensed under the © [MIT license](LICENSE).

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ interface IStarknetCore {
uint256 selector,
uint256[] calldata payload
) external returns (bytes32);

function consumeMessageFromL2(uint256 fromAddress, uint256[] calldata payload)
external
returns (bytes32);

function l2ToL1Messages(bytes32 msgHash) external view returns (uint256);
}
4 changes: 2 additions & 2 deletions contracts/ethereum/L1Interact/StarkNetCommit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
pragma solidity 0.8.9;

import '@openzeppelin/contracts/proxy/utils/Initializable.sol';
// import './Interfaces/IStarknetCore.sol';
// import '../Interfaces/IStarknetCore.sol';
// For testing purposes, we use a mock StarkNet messaging contract.
import 'contracts/ethereum/testContracts/MockStarknetMessaging.sol';
import 'contracts/ethereum/TestContracts/MockStarknetMessaging.sol';

/**
* @title StarkNet Commit Contract
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity 0.8.9;

import '@gnosis.pm/zodiac/contracts/guard/Guardable.sol';
import './Interfaces/IStarknetCore.sol';
import '../Interfaces/IStarknetCore.sol';

/**
* @title Snapshot X L1 Proposal Relayer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ end

@constructor
func constructor{syscall_ptr : felt*, pedersen_ptr : HashBuiltin*, range_check_ptr}(
starknet_commit_address : felt
):
starknet_commit_address : felt):
starknet_commit_address_store.write(value=starknet_commit_address)
return ()
end

# Receives hash from StarkNet commit contract and stores it in state.
@l1_handler
func commit{syscall_ptr : felt*, pedersen_ptr : HashBuiltin*, range_check_ptr : felt}(
from_address : felt, sender : EthAddress, hash : felt
):
from_address : felt, sender : EthAddress, hash : felt):
# Check L1 message origin is equal to the StarkNet commit address.
let (origin) = starknet_commit_address_store.read()
with_attr error_message("Invalid message origin address"):
Expand All @@ -43,8 +41,7 @@ end

@external
func execute{syscall_ptr : felt*, range_check_ptr, pedersen_ptr : HashBuiltin*}(
target : felt, function_selector : felt, calldata_len : felt, calldata : felt*
):
target : felt, function_selector : felt, calldata_len : felt, calldata : felt*):
alloc_locals
# Cast arguments to single array
let (input_array : felt*) = alloc()
Expand All @@ -69,7 +66,6 @@ func execute{syscall_ptr : felt*, range_check_ptr, pedersen_ptr : HashBuiltin*}(
contract_address=target,
function_selector=function_selector,
calldata_size=calldata_len,
calldata=calldata,
)
calldata=calldata)
return ()
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ from starkware.starknet.common.syscalls import call_contract
# Forwards `data` to `target` without verifying anything.
@external
func execute{syscall_ptr : felt*, range_check_ptr}(
to : felt, function_selector : felt, calldata_len : felt, calldata : felt*
) -> ():
target : felt, function_selector : felt, calldata_len : felt, calldata : felt*) -> ():
# TODO: Actually verify the signature

# Call the contract
call_contract(
contract_address=to,
contract_address=target,
function_selector=function_selector,
calldata_size=calldata_len,
calldata=calldata,
)
calldata=calldata)

return ()
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ from starkware.starknet.common.messages import send_message_to_l1

@external
func execute{syscall_ptr : felt*}(
proposal_outcome : felt,
execution_hash : Uint256,
execution_params_len : felt,
execution_params : felt*,
):
proposal_outcome : felt, execution_hash : Uint256, execution_params_len : felt,
execution_params : felt*):
alloc_locals

let (caller_address) = get_caller_address()
Expand All @@ -33,7 +30,6 @@ func execute{syscall_ptr : felt*}(

# Send message to L1 Contract
send_message_to_l1(
to_address=l1_zodiac_address, payload_size=payload_size, payload=message_payload
)
to_address=l1_zodiac_address, payload_size=payload_size, payload=message_payload)
return ()
end
7 changes: 7 additions & 0 deletions contracts/starknet/interfaces/i_authenticator.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
%lang starknet

@contract_interface
namespace i_authenticator:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inb4 @bonustrack fires you for writing this 👺👺👺

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just love snake case so much, cant help it...

func execute(target : felt, function_selector : felt, calldata_len : felt, calldata : felt*):
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ from contracts.starknet.lib.eth_address import EthAddress
from starkware.cairo.common.uint256 import Uint256

@contract_interface
namespace IExecutionStrategy:
namespace i_execution_strategy:
func execute(
proposal_outcome : felt,
execution_hash : Uint256,
execution_params_len : felt,
execution_params : felt*,
):
proposal_outcome : felt, execution_hash : Uint256, execution_params_len : felt,
execution_params : felt*):
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ from contracts.starknet.lib.eth_address import EthAddress
from starkware.cairo.common.uint256 import Uint256

@contract_interface
namespace IVotingStrategy:
namespace i_voting_strategy:
func get_voting_power(
timestamp : felt, address : EthAddress, params_len : felt, params : felt*
) -> (voting_power : Uint256):
timestamp : felt, address : EthAddress, params_len : felt, params : felt*) -> (
voting_power : Uint256):
end
end
Loading