kkrt-labs / kakarot

Kakarot is a zkEVM written in Cairo, leveraging the STARK proof system.
https://kakarot.org
MIT License
982 stars 294 forks source link

admin: protocol handler implementation [4] #1515

Open obatirou opened 1 week ago

obatirou commented 1 week ago

Implement the protocol handler which will be the owner of the kakarot contract. This will be a cairo1 contract. It needs to use access controls depending of the functions called on the kakarot contract and match the Kakarot interfaces.

The roles:

// Contants
soft_pause_expiration = 12 hours
hard_pause_expiration = 7 days

// Storage
struct Storage {
    kakarot_core: ContractAddress
    security_council: ContractAddress
    operator: ContractAddress
    gas_price_admin: ContractAddress
    Map<ContractAddress, bool> guardians
    protocol_frozen_until: felt252
}

// Authorized operator selectors are set in construcor

// Admin 
* fn emergency_execution(call: Call) SECURITY_COUNCIL
* fn upgrade(new_class_hash: felt252) OPERATOR
* fn transfer_ownership(new_owner: ContractAddress) SECURITY_COUNCIL
* fn soft_pause() GUARDIAN
* fn hard_pause() SECURITY_COUNCIL
* fn unpause() SECURITY_COUNCIL or delay passed

// Storage modification
// check if the selector is authorized
* fn execute_call(ref self: ContractState, call: Call) OPERATOR

// Self management
* fn change_operator(new_address_operator: ContractAddress) SECURITY_COUNCIL
* fn change_security_council(new_security_council_address: ContractAddress) SECURITY_COUNCIL
* fn add_guardian(new_guardians_address: ContractAddress) SECURITY_COUNCIL
* fn remove_guardian(guardian_to_remove_address: ContractAddress) SECURITY_COUNCIL
* fn change_gas_price_admin(new_gas_price_admin: ContractAddres) SECURITY_COUNCIL
### Tasks
- [x] Admin functions
- [x] Storage setting functions
- [x] self admin functions
- [ ] end to end tests