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

fast-bridge: Add fast bridge contract #361

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
49d3d54
added bridge escrow contract
dhruvja Jul 20, 2024
45e42c0
added bridge escrow contract
dhruvja Jul 20, 2024
44423f4
Merge branch 'fast-bridge' of https://github.com/ComposableFi/emulate…
dhruvja Jul 20, 2024
f7d4780
bridge-scrow -> tests.rs (#355)
doradelta Aug 6, 2024
aadd44b
test push alberto
doradelta Aug 7, 2024
f7a5ec8
on_receive_transfer & send_funds_to_user escrow contract
doradelta Aug 8, 2024
44cdd86
on_receive_transfer & send_funds_to_user escrow contract
doradelta Aug 8, 2024
30ecf73
on_receive_transfer & send_funds_to_user escrow contract
doradelta Aug 8, 2024
38d798b
some docs and quick fixes
dhruvja Aug 9, 2024
35c58ee
add timeout method
dhruvja Aug 12, 2024
1d7e0d7
fix receive method argument
dhruvja Aug 12, 2024
a308799
added tests for single domain
dhruvja Aug 13, 2024
2f45602
assert tests conditiosn
dhruvja Aug 13, 2024
9ee7025
bridge escrow - auctioneer_transfer
doradelta Aug 19, 2024
3255b59
remove auctioner_trasnfer() on escrow Program
doradelta Aug 19, 2024
4cd9003
add single domain in intent
dhruvja Aug 20, 2024
01ae66c
update tests and send funds to user method
dhruvja Aug 20, 2024
0e41399
Update lib.rs
doradelta Aug 20, 2024
aec6bf8
Update lib.rs
doradelta Aug 20, 2024
93d26ad
update escrow id
doradelta Aug 20, 2024
f821b35
fmt
dhruvja Aug 22, 2024
b05cb01
pull from master and fix merge conflicts
dhruvja Aug 22, 2024
aa04971
fix clippy
dhruvja Aug 22, 2024
b84d3ee
fix clippy
dhruvja Aug 22, 2024
0a02300
use struct for ix args instead of multiple args
dhruvja Aug 22, 2024
777c22a
fmt
dhruvja Aug 22, 2024
5e86bc1
fix wallet path
dhruvja Aug 22, 2024
c0e7f13
fast-bridge: Send required accounts for cross domain transfer (#375)
dhruvja Aug 26, 2024
15a4ad7
fast-bridge: Emit events for each method. (#374)
dhruvja Aug 26, 2024
6126f31
fast-bridge: Timeouts (#381)
dhruvja Aug 27, 2024
89a44de
remove intent from on receive transfer method
dhruvja Aug 27, 2024
43b9908
add timeout and on receive methods in tests
dhruvja Aug 27, 2024
0772575
change token in to string instead of pubkey
dhruvja Aug 28, 2024
7bfa988
set arbitrary space
dhruvja Aug 29, 2024
4902f26
allocate accounts to heap
dhruvja Aug 30, 2024
4b6e54c
use intent payload instead of string
dhruvja Aug 31, 2024
0986913
Update lib.rs
doradelta Sep 1, 2024
9e63fab
Update lib.rs
doradelta Sep 1, 2024
dcab6ba
hardcode solana ibc address
dhruvja Sep 2, 2024
1603619
Update lib.rs
doradelta Sep 2, 2024
5c569ba
Update lib.rs
doradelta Sep 2, 2024
e938903
avoid deserialization of solana ibc accounts
dhruvja Sep 3, 2024
3acbc6f
change token_mint & receiver_token_account on SplTokenTransfer struct
doradelta Sep 3, 2024
8639a56
box mint and receiver token account
dhruvja Sep 3, 2024
346c2f1
Update lib.rs
doradelta Sep 3, 2024
a543834
Update bridge.rs
doradelta Sep 3, 2024
82d6fcc
Update lib.rs
doradelta Sep 20, 2024
6d03458
Update lib.rs
doradelta Sep 24, 2024
d843604
Update tests.rs
doradelta Sep 25, 2024
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
19 changes: 10 additions & 9 deletions Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
[toolchain]

[features]
seeds = false
skip-lint = false

[programs.devnet]
restaking = "8n3FHwYxFgQCQc2FNFkwDUf9mcqupxXcCvgfHbApMLv3"
solana_ibc = "2HLLVco5HvwWriNbUhmVwA2pCetRkpgrqwnjcsZdyTKT"
bridge-escrow = "A5ygmioT2hWFnxpPapY3XyDjwwfMDhnSP1Yxoynd5hs4"
restaking = "JEG7nDQFRPFjjFgWVXaA25EkcXGVjma2Cy56C976sXhk"
solana_ibc = "EUiJni1BZFL3BhaWcS7NTJmqWyh8NwRLjBzrcGBvxKU4"

[programs.localnet]
restaking = "8n3FHwYxFgQCQc2FNFkwDUf9mcqupxXcCvgfHbApMLv3"
solana_ibc = "2HLLVco5HvwWriNbUhmVwA2pCetRkpgrqwnjcsZdyTKT"
bridge-escrow = "A5ygmioT2hWFnxpPapY3XyDjwwfMDhnSP1Yxoynd5hs4"
restaking = "JEG7nDQFRPFjjFgWVXaA25EkcXGVjma2Cy56C976sXhk"
solana_ibc = "EUiJni1BZFL3BhaWcS7NTJmqWyh8NwRLjBzrcGBvxKU4"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "localnet"
cluster = "Localnet"
wallet = "~/.config/solana/id.json"

[workspace]
members = [
"solana/restaking/programs/restaking",
"solana/solana-ibc/programs/solana-ibc"
]
members = ["solana/bridge-escrow/programs/bridge-escrow", "solana/restaking/programs/restaking", "solana/solana-ibc/programs/solana-ibc"]

[scripts]
test = "./solana-test.sh"
Expand Down
44 changes: 43 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ rust-version = "1.71.0"
members = [
"common/*",
"solana/allocator",
"solana/bridge-escrow/programs/*",
"solana/restaking/programs/*",
"solana/signature-verifier",
"solana/solana-ibc/programs/*",
Expand Down
5 changes: 0 additions & 5 deletions common/cf-guest/src/client/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ impl<PK: PubKey> ibc::ClientStateCommon for ClientState<PK> {
}
}


impl From<proof::VerifyError> for ibc::ClientError {
fn from(err: proof::VerifyError) -> Self {
use ibc::CommitmentError::EncodingFailure;
Expand Down Expand Up @@ -396,7 +395,6 @@ where
}
}


impl<PK: PubKey> ClientState<PK> {
pub fn do_update_state(
&self,
Expand Down Expand Up @@ -641,12 +639,10 @@ impl<PK: PubKey> ClientState<PK> {
}
}


fn error(msg: impl ToString) -> ibc::ClientError {
ibc::ClientError::Other { description: msg.to_string() }
}


/// Checks client id’s client type is what’s expected and then parses the id as
/// `ClientIdx`.
///
Expand All @@ -666,7 +662,6 @@ fn parse_client_id(client_id: &ibc::ClientId) -> Result<trie_ids::ClientIdx> {
Err(ibc::ClientError::ClientSpecific { description })
}


#[test]
fn test_verify_client_type() {
use core::str::FromStr;
Expand Down
2 changes: 0 additions & 2 deletions common/cf-guest/src/client/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ fn test_header_misbehaviour() {
add_block(&mut ctx, Some(&bad_block_2), 25 * HOUR, 2, Ok(true), None);
}


/// Tests Misbehaviour client messages.
///
/// Only verification and checking for misbehaviour are tested. No state
Expand Down Expand Up @@ -302,7 +301,6 @@ impl TestContext {
}
}


impl guestchain::Verifier<MockPubKey> for TestContext {
fn verify(
&self,
Expand Down
1 change: 0 additions & 1 deletion common/cf-guest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ impl<PK: PubKey> Header<PK> {
}
}


proto_utils::define_wrapper! {
proto: proto::Header,
wrapper: Header<PK> where
Expand Down
5 changes: 0 additions & 5 deletions common/cf-guest/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub enum ClientMessage<PK: PubKey> {
Misbehaviour(Misbehaviour<PK>),
}


// Conversions directly to and from the Message enum.

impl<PK: guestchain::PubKey> From<ClientMessage<PK>> for Message {
Expand Down Expand Up @@ -48,7 +47,6 @@ impl<PK: guestchain::PubKey> TryFrom<&Message> for ClientMessage<PK> {
}
}


// Conversions directly into the Message enum from variant types.

impl<PK: guestchain::PubKey> From<Header<PK>> for Message {
Expand All @@ -67,7 +65,6 @@ impl<PK: guestchain::PubKey> From<&Misbehaviour<PK>> for Message {
fn from(msg: &Misbehaviour<PK>) -> Self { Self::Misbehaviour(msg.into()) }
}


// Conversion into ClientMessage proto from variant types.

impl<PK: guestchain::PubKey> From<Header<PK>> for proto::ClientMessage {
Expand All @@ -90,7 +87,6 @@ impl<PK: guestchain::PubKey> From<&Misbehaviour<PK>> for proto::ClientMessage {
}
}


// And finally, conversions between proto and Rust type

impl<PK: guestchain::PubKey> From<ClientMessage<PK>> for proto::ClientMessage {
Expand Down Expand Up @@ -125,7 +121,6 @@ impl<PK: guestchain::PubKey> TryFrom<&proto::ClientMessage>
}
}


proto_utils::define_wrapper! {
proto: proto::ClientMessage,
wrapper: ClientMessage<PK> where
Expand Down
3 changes: 0 additions & 3 deletions common/cf-guest/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ impl IbcProof {
}
}


#[derive(Clone, Debug, PartialEq, Eq, derive_more::From)]
pub enum GenerateError {
/// State root in block header and root of trie don’t match.
Expand Down Expand Up @@ -104,7 +103,6 @@ pub fn generate<A: sealable_trie::Allocator>(
Ok(IbcProof { proof, root, value })
}


#[derive(
Clone, Debug, PartialEq, Eq, derive_more::From, derive_more::Display,
)]
Expand Down Expand Up @@ -253,7 +251,6 @@ pub fn verify(
}
}


#[test]
fn test_proofs() {
use core::str::FromStr;
Expand Down
1 change: 0 additions & 1 deletion common/lib/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ mod imp {
}
}


/// Builder for the cryptographic hash.
///
/// The builder calculates the digest of bytes that it’s fed using the
Expand Down
4 changes: 0 additions & 4 deletions common/proto-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub trait AnyConvert: Sized {
fn try_from_any(type_url: &str, value: &[u8]) -> Result<Self, DecodeError>;
}


/// Error during decoding of a protocol message.
#[derive(Clone, PartialEq, Eq, derive_more::From)]
pub enum DecodeError {
Expand Down Expand Up @@ -106,7 +105,6 @@ impl From<BadMessage> for ibc_core_client_context::types::error::ClientError {
}
}


/// Defines common associated symbols and conversions for a proto message type.
#[macro_export]
macro_rules! define_message {
Expand Down Expand Up @@ -230,7 +228,6 @@ macro_rules! define_message {
};
}


/// Implements conversion between given type and Any message.
///
/// Specified type must implement [`AnyConvert`].
Expand Down Expand Up @@ -281,7 +278,6 @@ macro_rules! impl_from_to_any {
};
}


/// Defines a wrapper type for a raw protocol message type.
// TODO(mina86): Add definition of tests.
#[macro_export]
Expand Down
3 changes: 0 additions & 3 deletions common/sealable-trie/src/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,6 @@ impl core::cmp::PartialEq<Owned> for Slice<'_> {
fn eq(&self, other: &Owned) -> bool { self == &other.as_slice() }
}



impl TryFrom<Slice<'_>> for Vec<u8> {
type Error = MisalignedSlice;
#[inline]
Expand Down Expand Up @@ -795,7 +793,6 @@ impl TryFrom<Owned> for Vec<u8> {
}
}


impl fmt::Display for Slice<'_> {
fn fmt(&self, fmtr: &mut fmt::Formatter<'_>) -> fmt::Result {
use ascii::AsciiChar;
Expand Down
5 changes: 0 additions & 5 deletions common/sealable-trie/src/bits/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use lib::u3::U3;

use super::{Owned, Slice};


/// Trying to concatenate slices which result in slice whose size is too large.
///
/// Slice’s length must not overflow u16.
Expand Down Expand Up @@ -87,14 +86,12 @@ impl From<MisalignedSlice> for Error {
fn from(_: MisalignedSlice) -> Error { Error::Misaligned }
}


pub trait Concat<Rhs> {
type Error: Into<Error>;

fn concat_impl(prefix: Self, suffix: Rhs) -> Result<Owned, Self::Error>;
}


impl<'a> Concat<Slice<'a>> for bool {
type Error = SliceTooLong;

Expand Down Expand Up @@ -215,7 +212,6 @@ pub(super) fn extend_impl(
Ok(())
}


/// Checks that concatenating two slices produces slice whose length doesn’t
/// overflow `u16`.
pub(super) fn check_length(
Expand Down Expand Up @@ -255,7 +251,6 @@ fn check_alignment_and_length(
Ok(check_length(pre_len, suf_len)?)
}


#[test]
fn test_unshift() {
for offset in U3::all() {
Expand Down
2 changes: 0 additions & 2 deletions common/sealable-trie/src/bits/ext_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ impl fmt::Debug for Chunks<'_> {
}
}



impl<'a> core::iter::Iterator for Chunks<'a> {
type Item = ExtKey<'a>;

Expand Down
1 change: 0 additions & 1 deletion common/sealable-trie/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ impl<'a, S> ValueRef<'a, S> {
}
}


// =============================================================================
// PartialEq

Expand Down
1 change: 0 additions & 1 deletion common/sealable-trie/src/proof/serialisation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ fn invalid_data(msg: String) -> io::Error {
io::Error::new(io::ErrorKind::InvalidData, msg)
}


#[test]
fn test_item_borsh() {
#[track_caller]
Expand Down
1 change: 0 additions & 1 deletion common/sealable-trie/src/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ impl<A: memory::Allocator<Value = Value>> Trie<A> {
}
}


#[cfg(test)]
impl Trie<memory::test_utils::TestAllocator<Value>> {
/// Creates a test trie using a TestAllocator with given capacity.
Expand Down
3 changes: 0 additions & 3 deletions common/sealable-trie/src/trie/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ impl<'a> KeyGen<'a> for RandKeys<'a> {
fn count(&self) -> Option<usize> { Some(self.count) }
}


#[test]
fn stress_test() {
let count = lib::test_utils::get_iteration_count(500);
Expand Down Expand Up @@ -444,7 +443,6 @@ impl core::fmt::Debug for Key {
}
}


trait KeyGen<'a> {
fn next(&mut self, known: &HashMap<Key, CryptoHash>) -> Option<&'a [u8]>;
fn count(&self) -> Option<usize>;
Expand All @@ -470,7 +468,6 @@ impl<'a, I: Iterator<Item = &'a [u8]>> KeyGen<'a> for IterKeyGen<I> {
fn count(&self) -> Option<usize> { self.0.size_hint().1 }
}


struct TestTrie {
trie: super::Trie<TestAllocator<super::Value>>,
mapping: HashMap<Key, CryptoHash>,
Expand Down
1 change: 0 additions & 1 deletion common/trie-ids/src/path_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ impl PathInfo {
}
}


#[test]
fn test_try_from_path() {
use std::str::FromStr;
Expand Down
Loading