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: constructed persistent account keys from instruction #191

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

frolvanya
Copy link
Contributor

@frolvanya frolvanya commented Jan 15, 2025

Just to add some clarity, I want to provide a small explanation why do we need this logic

These are account keys that we can get from raw_message.account_keys:

Account Keys: ["BXss9YNCX2p6VPf2Em54pHXkXnC2FPBeZgbB9fY1cuBR", "DsR6nocBnnkmRdRNYCXtXoNsdTKfa9Kd4ZdcxJEZJeKv", "79nePUUxtfJSdrkbririgL5YMaoEh5g4HNQaar2EuJ7", "dahPEoZGXfyV58JqqH85okdHmpN8U2q8owgPUXSCPxe", "2yVjuQwpsvdsrywzs
JJVs9Ueh4zayyo5DYJbBNc3DDpn", "3ZLekZYq2qkZiSpnSvabjit34tUkjSwD1JFuW9as9wBG", "6tckHFBpiJ8YgYN8FUskvtvTpXQZ55g5LHeo1kvELoDQ", "9bFNrXNb2WTx8fMHXCheaZqkLZ3YCCaiqTftHxeintHy", "G7BgdUgsQ7iQmHUqPM85XvantPDqHxEi88Fs23FeDTLo", "11
111111111111111111111111111111", "SysvarC1ock11111111111111111111111111111111", "SysvarRent111111111111111111111111111111111", "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth", "2iA
NpDh96GgithLPTVMZjZFtnbrYBUCLqnEvaytbwTQq", "FvULawNPGBbuwYus74ECaQoV1oH9Tk6XPN7VPN51NYds"]

They are sorted based on few rules. Firstly, accounts are splitted into the groups and the priority is like this:

  1. fee payer
  2. signers
  3. writable accounts
  4. read-only accounts (e.g program and sysvar accounts)

Then accounts in each group are sorted in lexicographical order, which means that this is way too impersistent for our use case. In order to get a strong order that will be based on our instructions we can look into instruction.accounts which is a simple &[u8] with the correct strict position of each account key:

Instruction: [15, 5, 8, 3, 6, 0, 14, 4, 7, 2, 1, 0, 10, 11, 13, 9, 12]
Instruction account keys: ["FvULawNPGBbuwYus74ECaQoV1oH9Tk6XPN7VPN51NYds", "3ZLekZYq2qkZiSpnSvabjit34tUkjSwD1JFuW9as9wBG", "G7BgdUgsQ7iQmHUqPM85XvantPDqHxEi88Fs23FeDTLo", "dahPEoZGXfyV58JqqH85okdHmpN8U2q8owgPUXSCPxe", "6tckHF
BpiJ8YgYN8FUskvtvTpXQZ55g5LHeo1kvELoDQ", "BXss9YNCX2p6VPf2Em54pHXkXnC2FPBeZgbB9fY1cuBR", "2iANpDh96GgithLPTVMZjZFtnbrYBUCLqnEvaytbwTQq", "2yVjuQwpsvdsrywzsJJVs9Ueh4zayyo5DYJbBNc3DDpn", "9bFNrXNb2WTx8fMHXCheaZqkLZ3YCCaiqTftHxe
intHy", "79nePUUxtfJSdrkbririgL5YMaoEh5g4HNQaar2EuJ7", "DsR6nocBnnkmRdRNYCXtXoNsdTKfa9Kd4ZdcxJEZJeKv", "BXss9YNCX2p6VPf2Em54pHXkXnC2FPBeZgbB9fY1cuBR", "SysvarC1ock11111111111111111111111111111111", "SysvarRent1111111111111111
11111111111111111", "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth", "11111111111111111111111111111111", "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"]

Refactoring code to resolve `too_many_lines` clippy error will take too much time, so I decided to silence the error for now. All other issues were fixed
@frolvanya frolvanya force-pushed the feat/persistent-account-keys branch from 34bf4cc to 6eb9c79 Compare January 15, 2025 06:50
@frolvanya frolvanya merged commit 92e2adb into relayer Jan 15, 2025
5 of 7 checks passed
frolvanya added a commit that referenced this pull request Jan 17, 2025
* feat: added native fee in structures (#69)

* chore: added `nativeFee` field

closes #47

* chore: renamed `eth` to `evm`

In general all methods that we're using for eth are also appliable for evm

* feat: handled scenario with insufficient fees

* chore: reordered events

* feat: get `wormhole_chain_id` based on recipient

* chore: renamed `withdraw_log` to `init_log`

Changed due to the new name in bridge token factory structure

* feat: updated to the latest version of omni-types

* feat: removed `check_bad_fees` logic

* chore: renamed `BAD_FEE_EVENTS` to `BAD_FEES`

* feat: removed whole bad fees logic

* feat: provided proper fee structure into signing method

* feat: updated accordingly to new version of bridge-sdk

* feat: claim native fee (#70)

* feat: added `fin_transfer` event to redis db

* feat: signing claiming native fee

* fix: sign_claim_native_fee call

* feat: added `claim_native_fee` call

* feat: handled `ClaimFeeEvent`

* fix: issues after merging

* chore: renamed `relayer` -> `relayer_address_on_evm`

* chore: use relayer from config

* fix: typo in redis key

* fix: expected different event

* chore: recipient should be our relayer

* fix: bunch of naming mistakes

* chore: renamed `fin_transfer_events` redis key

* feat: handled `FinTransferEvent` with some nonce

* chore: improved readability

* refactor: changed logging style

* feat: derive eth address from private key (#76)

* feat: derived eth pk from sk

* refactor: removed optional typing

* refactor: shortened code

* feat: used existing crate to derive pk

* refactor: moved `relayer_address` under `evm` struct

* chore: some renamings

* chore: updated omni-types (#92)

* feat: wait for eth light client (#71)

* feat: wait until light client receives info about block

closes #63

* chore: added config.toml to .gitignore

* chore: renamed method in evm worker

* chore: made clippy happy

* fix: issues after merging

* chore: fixed style

* chore: added example config

* chore: moved `eth_light_client` under `evm` config

* feat: check block number before claiming fee

* feat: added sleep for light client waiting time

* fix: don't wait for light client if we have vaa

* fix: constructed proper `FinTransferArgs`

* feat: added wormhole support for `claim_fee` worker

* feat: expect either fintransfer or claimfee event

* fix: provided correct args for claiming fee

* chore: provided proper name for prover args constructor

* feat: scratch implementation of fee estimation (#81)

* feat: scratch implementation of fee estimation

* refactor: few tweaks

* chore: better way to handle `UpdateFee` event

* Squashed commit of the following:

commit 3d2e905
Author: Ivan Frolov <[email protected]>
Date:   Fri Oct 25 16:39:22 2024 +0200

    chore: provided proper name for prover args constructor

commit 8857140
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 22:48:15 2024 +0200

    fix: provided correct args for claiming fee

commit 160e0e3
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 22:14:02 2024 +0200

    feat: expect either fintransfer or claimfee event

commit 1a8def1
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 21:07:14 2024 +0200

    feat: added wormhole support for `claim_fee` worker

commit 1a3c711
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 20:49:32 2024 +0200

    fix: constructed proper `FinTransferArgs`

commit ad16b81
Merge: 8b469bc 4786123
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 15:35:10 2024 +0200

    Merge branch 'relayer' into feat/wait-for-light-client

commit 8b469bc
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 15:26:28 2024 +0200

    fix: don't wait for light client if we have vaa

commit 68821cd
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 15:23:01 2024 +0200

    feat: added sleep for light client waiting time

commit 998b21e
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 15:21:32 2024 +0200

    feat: check block number before claiming fee

commit ad692b6
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 15:18:27 2024 +0200

    chore: moved `eth_light_client` under `evm` config

commit 4786123
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 01:00:24 2024 +0200

    chore: updated omni-types (#92)

commit 96954ae
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 17 11:16:32 2024 +0100

    chore: added example config

commit ad35e56
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 17 11:09:49 2024 +0100

    chore: fixed style

commit 7473caa
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 17 11:07:26 2024 +0100

    fix: issues after merging

commit 316a90f
Author: Ivan Frolov <[email protected]>
Date:   Wed Oct 9 14:42:46 2024 +0100

    chore: made clippy happy

commit 8d44254
Author: Ivan Frolov <[email protected]>
Date:   Wed Oct 9 14:07:31 2024 +0100

    chore: renamed method in evm worker

commit b3118d9
Author: Ivan Frolov <[email protected]>
Date:   Wed Oct 9 13:56:14 2024 +0100

    chore: added config.toml to .gitignore

commit f0677a8
Author: Ivan Frolov <[email protected]>
Date:   Wed Oct 9 13:42:03 2024 +0100

    feat: wait until light client receives info about block

    closes #63

* Squashed commit of the following:

commit 4786123
Author: Ivan Frolov <[email protected]>
Date:   Thu Oct 24 01:00:24 2024 +0200

    chore: updated omni-types (#92)

* fix: read estimated gas as u64

* chore: updated bridge-sdk

* fix: removed unnecessary things from fee estimation

* feat: added retry logic while estimating fee (#105)

* feat: added retry logic and changed location for checking fee

* refactor: swapped if blocks

* feat: changed retry logic

* fix: addressed issues

* feat: support of multiple chains (#146)

* feat: scratch implementation of supporting multiple chains

* chore: removed claiming native fee on EVM chain

* chore: updated example configuration

* fix: getting vaa

* feat: working version of relayer with multiple chains support

* feat: call proper `fin_transfer` based on recipient chain

* refactor: reduced code duplication by abstracting evm indexer

* feat: removed `sign_claim_native_fee` logic

* chore: removed few newlines

* refactor: reduced code duplication in config structs

* feat: getting native token id by calling a method

* chore: added a disclaimer that `get_native_token_id` is not working for now

* feat: made evm chains optional

* feat: refactor evm bridge clients initialization

* feat: solana support (#153)

* feat: added solana indexer

* feat: added finalization from solana

* feat: finished solana init&finalize transfer

* feat: added solana live logs support

* feat: added support for `..._transfer_sol` methods

* chore: updated bridge token addresses

* fix: bug with provided chain_kind

* fix: storage deposit amount calculation

* chore: few log modifications

* fix: few tweaks to make solana transfers work

* feat: added native_fee support for storage_deposit args from solana

* chore: add a todo mentioning that `get_storage_deposit_actions` method is redundant

* chore: added comment about aws usage

* refactor: reduced code duplication for creating storage deposit actions

* fix: h160 address parsing

* feat: solana transfer native tokens

* fix: near -> sol native token transfer

* fix: solana indexer logic

* feat: support non-near to non-near transfers

* feat: replaced anchor deserialization with borsh

* chore: start from block + 1

Since this block was already processed, there's no need to check it one more time

* fix: near sign transfer

* fix: prevented issues that could result in panic

* chore: updated bridge token address

* fix: use eth light client only for eth chain

* refactor: moved timestamps checks to the bottom

This ensures at least one execution

* chore: added some comments for solana network configuation

* fix: use eth light client only for eth chain and when vaa is none

* feat: made solana-indexer less complicated

* feat: implemented fee check (#172)

* chore: synced changes with main

* chore: fmt

* chore: added relayer to clippy makefile

* feat: constructed persistent account keys from instruction (#191)

* chore: updated mainnet example config

* chore: removed `eth.rs` that was pulled from main during merge

* refactor: simplify extraction of evm config

* feat: added an option to provide solana credentials using path

* chore: updated testnet `api_key` replacement

* chore: renamed `RPC_API_KEY` to more specific `INFURA_API_KEY`

* feat: improved the process of getting private keys from file

* chore: removed unnecessary `Result`

* chore: updated omni-types version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants