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(its)!: changed from trusted addresses to trusted chains #235

Merged
merged 34 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
63beb53
changed from trusted addresses to trusted chains
Foivos Jan 20, 2025
7ac8025
fixed some tests
Foivos Jan 20, 2025
46e65b2
rename some stuff
Foivos Jan 20, 2025
1bf88f1
fix some tests
Foivos Jan 20, 2025
eb43639
fix tests
Foivos Jan 20, 2025
663bbef
fix move tests
Foivos Jan 21, 2025
fcb0cc2
add a creator cap and setup to its
Foivos Jan 21, 2025
9f3c157
add chain name to token_id derivation
Foivos Jan 21, 2025
f335d89
prettier and fix interfaces
Foivos Jan 22, 2025
2a4cab6
Merge remote-tracking branch 'origin/main' into feat/remove-address-t…
Foivos Jan 23, 2025
d1e8ddd
address a few comments
Foivos Jan 23, 2025
27150a8
rename chain_tracker to trusted_chains
Foivos Jan 23, 2025
a3aa2a7
some more comments addressed
Foivos Jan 23, 2025
b8d1e51
Update move/squid/sources/squid/squid.move
Foivos Jan 23, 2025
5c5f184
address some more comments
Foivos Jan 23, 2025
1e47517
addressed a comments
Foivos Jan 23, 2025
e5d2b81
Merge remote-tracking branch 'origin/main' into feat/token-id-chain-d…
Foivos Jan 23, 2025
577f190
Merge branch 'feat/token-id-chain-derivation' into feat/remove-addres…
Foivos Jan 23, 2025
1b76acc
fix tests
Foivos Jan 23, 2025
f65bd68
add its_hub_address as a variable
Foivos Jan 23, 2025
e9f0c72
changed how wrap payload works
Foivos Jan 23, 2025
73ff042
changed pattern for wrapping payload a bit.
Foivos Jan 23, 2025
c5b8d37
Update move/interchain_token_service/sources/types/trusted_chains.move
Foivos Jan 27, 2025
82d091c
Update move/interchain_token_service/sources/types/trusted_chains.move
Foivos Jan 27, 2025
98e1163
Update move/interchain_token_service/sources/types/trusted_chains.move
Foivos Jan 27, 2025
9b987a4
rename `prepare_wrapped_message` to `prepare_hub_message`
Foivos Jan 27, 2025
bff94bd
cs
Foivos Jan 27, 2025
2db608a
added explicit check that chain is contained when trying to remove it.
Foivos Jan 27, 2025
9716566
Merge remote-tracking branch 'origin/main' into feat/remove-address-t…
Foivos Jan 27, 2025
7c2cadb
fix tests
Foivos Jan 27, 2025
6c406fd
Merge remote-tracking branch 'origin/main' into feat/remove-address-t…
Foivos Jan 27, 2025
02915b7
update bcs
Foivos Jan 27, 2025
d780bc9
update bcs test for InterchainTokenServiceV0
Foivos Jan 27, 2025
4172de7
made lint happy
Foivos Jan 28, 2025
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
5 changes: 5 additions & 0 deletions .changeset/chilled-apes-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@axelar-network/axelar-cgp-sui': minor
---

Change ITS from tracking addresses of remote chains to only tracking trusted chains and always using the ITS HUB.
6 changes: 1 addition & 5 deletions move/axelar_gateway/sources/events.move
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ public struct MessageExecuted has copy, drop {
// -----------------
// Package Functions
// -----------------
public(package) fun signers_rotated(
epoch: u64,
signers_hash: Bytes32,
signers: WeightedSigners,
) {
public(package) fun signers_rotated(epoch: u64, signers_hash: Bytes32, signers: WeightedSigners) {
event::emit(SignersRotated {
epoch,
signers_hash,
Expand Down
47 changes: 18 additions & 29 deletions move/interchain_token_service/sources/discovery.move
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use sui::address;
/// Errors
/// ------
#[error]
const EUnsupportedMessageType: vector<u8> =
b"the message type found is not supported";
const EUnsupportedMessageType: vector<u8> = b"the message type found is not supported";
#[error]
const EInvalidMessageType: vector<u8> =
b"can only get interchain transfer info for interchain transfers";
Expand All @@ -25,14 +24,14 @@ const MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN: u256 = 1;
// onst MESSAGE_TYPE_SEND_TO_HUB: u256 = 3;
const MESSAGE_TYPE_RECEIVE_FROM_HUB: u256 = 4;

public fun interchain_transfer_info(
payload: vector<u8>,
): (TokenId, address, u64, vector<u8>) {
public fun interchain_transfer_info(payload: vector<u8>): (TokenId, address, u64, vector<u8>) {
let mut reader = abi::new_reader(payload);
assert!(
reader.read_u256() == MESSAGE_TYPE_INTERCHAIN_TRANSFER,
EInvalidMessageType,
);
assert!(reader.read_u256() == MESSAGE_TYPE_RECEIVE_FROM_HUB, EInvalidMessageType);
// Source chain validation is not done here.
reader.skip_slot();
let payload = reader.read_bytes();
reader = abi::new_reader(payload);
assert!(reader.read_u256() == MESSAGE_TYPE_INTERCHAIN_TRANSFER, EInvalidMessageType);

let token_id = token_id::from_u256(reader.read_u256());
reader.skip_slot(); // skip source_address
Expand Down Expand Up @@ -87,10 +86,7 @@ public fun call_info(its: &InterchainTokenService, mut payload: vector<u8>): Tra
if (message_type == MESSAGE_TYPE_INTERCHAIN_TRANSFER) {
interchain_transfer_tx(its, &mut reader)
} else {
assert!(
message_type == MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN,
EUnsupportedMessageType,
);
assert!(message_type == MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, EUnsupportedMessageType);
deploy_interchain_token_tx(its, &mut reader)
}
}
Expand Down Expand Up @@ -127,10 +123,7 @@ fun interchain_transfer_tx(its: &InterchainTokenService, reader: &mut AbiReader)
)
} else {
let mut discovery_arg = vector[0];
discovery_arg.append(value
.relayer_discovery_id()
.id_to_address()
.to_bytes());
discovery_arg.append(value.relayer_discovery_id().id_to_address().to_bytes());

let mut channel_id_arg = vector[1];
channel_id_arg.append(destination_address.to_bytes());
Expand Down Expand Up @@ -269,9 +262,7 @@ fun test_discovery_interchain_transfer() {
call_info.function().package_id_from_function() == package_id<InterchainTokenService>(),
);
assert!(call_info.function().module_name() == ascii::string(b"interchain_token_service"));
assert!(
call_info.function().name() == ascii::string(b"receive_interchain_transfer"),
);
assert!(call_info.function().name() == ascii::string(b"receive_interchain_transfer"));
let mut arg = vector[0];
arg.append(object::id_address(&its).to_bytes());

Expand Down Expand Up @@ -322,9 +313,7 @@ fun test_discovery_interchain_transfer_with_data() {
let mut reader = abi::new_reader(payload);
reader.skip_slot(); // skip message_type

assert!(
call_info(&its, payload) == interchain_transfer_tx(&its, &mut reader),
);
assert!(call_info(&its, payload) == interchain_transfer_tx(&its, &mut reader));

sui::test_utils::destroy(its);
sui::test_utils::destroy(discovery);
Expand Down Expand Up @@ -376,9 +365,7 @@ fun test_discovery_deploy_token() {
call_info.function().package_id_from_function() == package_id<InterchainTokenService>(),
);
assert!(call_info.function().module_name() == ascii::string(b"interchain_token_service"));
assert!(
call_info.function().name() == ascii::string(b"receive_deploy_interchain_token"),
);
assert!(call_info.function().name() == ascii::string(b"receive_deploy_interchain_token"));
let mut arg = vector[0];
arg.append(object::id_address(&its).to_bytes());

Expand All @@ -395,6 +382,7 @@ fun test_interchain_transfer_info() {
let message_type = MESSAGE_TYPE_INTERCHAIN_TRANSFER;
let token_id = 1;
let source_address = b"source address";
let source_chain = b"Chain Name";
let destination = @0x3.to_bytes();
let amount = 2;
let data = b"data";
Expand All @@ -407,6 +395,9 @@ fun test_interchain_transfer_info() {
.write_bytes(destination)
.write_u256(amount)
.write_bytes(data);
let payload = writer.into_bytes();
writer = abi::new_writer(3);
writer.write_u256(MESSAGE_TYPE_RECEIVE_FROM_HUB).write_bytes(source_chain).write_bytes(payload);

let (
resolved_token_id,
Expand Down Expand Up @@ -486,9 +477,7 @@ fun test_discovery_hub_message() {
call_info.function().package_id_from_function() == package_id<InterchainTokenService>(),
);
assert!(call_info.function().module_name() == ascii::string(b"interchain_token_service"));
assert!(
call_info.function().name() == ascii::string(b"receive_interchain_transfer"),
);
assert!(call_info.function().name() == ascii::string(b"receive_interchain_transfer"));
let mut arg = vector[0];
arg.append(object::id_address(&its).to_bytes());

Expand Down
15 changes: 6 additions & 9 deletions move/interchain_token_service/sources/events.move
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ public struct UnregisteredCoinReceived<phantom T> has copy, drop {
decimals: u8,
}

public struct TrustedAddressSet has copy, drop {
public struct TrustedChainAdded has copy, drop {
chain_name: String,
trusted_address: String,
}

public struct TrustedAddressRemoved has copy, drop {
public struct TrustedChainRemoved has copy, drop {
chain_name: String,
}

Expand Down Expand Up @@ -143,18 +142,16 @@ public(package) fun unregistered_coin_received<T>(
});
}

public(package) fun trusted_address_set(
public(package) fun trusted_chain_added(
chain_name: String,
trusted_address: String,
) {
event::emit(TrustedAddressSet {
event::emit(TrustedChainAdded {
chain_name,
trusted_address,
});
}

public(package) fun trusted_address_removed(chain_name: String) {
event::emit(TrustedAddressRemoved {
public(package) fun trusted_chain_removed(chain_name: String) {
event::emit(TrustedChainRemoved {
chain_name,
});
}
Expand Down
Loading
Loading