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

feat: update Kakarot send tx API #488

Closed
wants to merge 2 commits into from
Closed

Conversation

Eikix
Copy link
Member

@Eikix Eikix commented Aug 26, 2023

Time spent on this PR: 0.3 day

Resolves: #487

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Testing

What is the new behavior?

Does this introduce a breaking change?

  • Yes
  • No

@Eikix
Copy link
Member Author

Eikix commented Aug 26, 2023

Still a Draft since I can't manage to pass the test_estimate_gas test! Not sure why yet

pub const KAKAROT_TESTNET_ADDRESS: &str = "0x01e98a4d6cadc1e3511d150ef2705b02fccb3fb6f15aba863503af58f4b217ea";
lazy_static! {
    pub static ref ACCOUNT_ADDRESS: FieldElement = FieldElement::from_hex_be(ACCOUNT_ADDRESS_HEX).unwrap();
    pub static ref ACCOUNT_ADDRESS_EVM: Address =
        Address::from_str("0x54B288676B749DEF5FC10EB17244FE2C87375dE1").unwrap();
    pub static ref COUNTER_ADDRESS_EVM: Address =
        Address::from_str("0x2e11ed82f5ec165ab8ce3cc094f025fe7527f4d1").unwrap();
}

These are the constants involved.

New Kakarot behaviour: two additional checks in eth_send_transaction:

    //         origin of eth_call, ie that it's corresponding evm address is actually the provided origin
    // @dev Raise if the calling contract tries to impersonate an EVM address
    func assert_caller_is_origin{
        syscall_ptr: felt*,
        pedersen_ptr: HashBuiltin*,
        range_check_ptr,
        bitwise_ptr: BitwiseBuiltin*,
    }(origin: felt) {
        alloc_locals;
        let (local starknet_caller_address) = get_caller_address();
        let (local evm_caller_address) = IAccount.get_evm_address(starknet_caller_address);
        with_attr error_message("Kakarot: caller contract is not consistent with from tx field") {
            assert origin = evm_caller_address;
        }

        return ();
    }

and

   // @notice Assert that the calling contract is a Kakarot account, ie. that it has been
    //         deployed by kakarot. This is currently required to make sure that evm and
    //         starknet addresses remain consistents along an execution
    // @dev Raise if the declared corresponding evm address (retrieved with get_evm_address)
    //      does not lead to the actual caller address
    func assert_caller_is_kakarot_account{
        syscall_ptr: felt*,
        pedersen_ptr: HashBuiltin*,
        range_check_ptr,
        bitwise_ptr: BitwiseBuiltin*,
    }() {
        alloc_locals;
        let (local starknet_caller_address) = get_caller_address();
        let (local evm_caller_address) = IAccount.get_evm_address(starknet_caller_address);
        let (local computed_starknet_address) = Accounts.compute_starknet_address(
            evm_caller_address
        );

        with_attr error_message("Kakarot: caller contract is not a Kakarot Account") {
            assert computed_starknet_address = starknet_caller_address;
        }

        return ();
    }

So these might be the reason

@Eikix
Copy link
Member Author

Eikix commented Aug 28, 2023

Closing this as I was mistaken! RPC API does not change afaik https://github.com/kkrt-labs/kakarot/blob/main/src/kakarot/accounts/eoa/library.cairo#L140

@Eikix Eikix closed this Aug 28, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: update Kakarot send_transaction API to follow the latest commit
2 participants