Skip to content

Commit ef78d36

Browse files
updating all
1 parent 202e3eb commit ef78d36

25 files changed

+551
-49
lines changed

Cargo.lock

Lines changed: 20 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ cosmwasm-std = { version = "^1.5.0", features = [
5454
"iterator",
5555
], default-features = false }
5656

57+
log = { version = "0.4.21", default-features = true}
5758
parity-scale-codec = { version = "^3.6.5", default-features = false }
5859
cw20 = { version = "^1.1.2", default-features = false }
5960
cw-controllers = { version = "^1.1.1", default-features = false }

contracts/cosmwasm/executor/src/contract.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn initiate_execution(
110110
deps: DepsMut,
111111
env: Env,
112112
tip: Addr,
113-
program: shared::XcProgram,
113+
program: shared::CvmProgram,
114114
) -> Result {
115115
// Reset instruction pointer to zero.
116116
INSTRUCTION_POINTER_REGISTER.save(deps.storage, &0)?;
@@ -379,7 +379,7 @@ pub fn execute_spawn(
379379
network_id: NetworkId,
380380
salt: Vec<u8>,
381381
assets: Funds<Amount>,
382-
program: shared::XcProgram,
382+
program: shared::CvmProgram,
383383
) -> Result {
384384
let Config {
385385
executor_origin,

contracts/cosmwasm/order/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub use types::*;
1919
pub use crate::sv::{ExecMsg, QueryMsg};
2020

2121
use cosmwasm_std::{wasm_execute, Addr, BankMsg, Coin, Event, Order, StdError, Storage};
22-
use cvm_runtime::shared::{XcInstruction, XcProgram};
22+
use cvm_runtime::shared::{CvmInstruction, CvmProgram};
2323
use cw_storage_plus::{Index, IndexList, IndexedMap, Item, Map};
2424
use sylvia::{
2525
contract,
@@ -206,14 +206,14 @@ impl OrderContract<'_> {
206206
},
207207
];
208208
let cvm = wasm_execute(contract, &cvm, funds)?;
209-
209+
trust_fill();
210210
Ok(Response::default().add_message(cvm))
211211
}
212212

213213
/// Provides solution for set of orders.
214214
/// All fully
215215
#[msg(exec)]
216-
pub fn solve(&self, ctx: ExecCtx, msg: SolutionSubMsg) -> StdResult<Response> {
216+
pub fn settle(&self, ctx: ExecCtx, msg: SolutionSubMsg) -> StdResult<Response> {
217217
// read all orders as solver provided
218218
let mut all_orders = join_solution_with_orders(&self.orders, &msg, &ctx)?;
219219
let at_least_one = all_orders.first().expect("at least one");

contracts/cosmwasm/order/src/simulator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use cosmwasm_std::Storage;
2-
use cvm_runtime::shared::XcProgram;
2+
use cvm_runtime::shared::CvmProgram;
33

44
use crate::prelude::*;
55
use crate::CowFilledOrder;
@@ -66,7 +66,7 @@ pub fn simulate_cows_via_bank(
6666
/// Produces remaining each order will receive proportional to what is given.
6767
pub fn simulate_route(
6868
storage: &mut dyn Storage,
69-
route: XcProgram,
69+
route: CvmProgram,
7070
token_a_remaining: Coin,
7171
token_b_remaining: Coin,
7272
orders: Vec<SolvedOrder>,

contracts/cosmwasm/order/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use cosmwasm_std::{ensure, BankMsg, Event, StdResult, Uint64, WasmMsg};
2-
use cvm_runtime::{outpost::ExecuteProgramMsg, shared::XcProgram, AssetId, ExchangeId, NetworkId};
2+
use cvm_runtime::{outpost::ExecuteProgramMsg, shared::CvmProgram, AssetId, ExchangeId, NetworkId};
33

44
use crate::prelude::*;
55

contracts/cosmwasm/outpost/src/contract/ibc/ics20.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use cosmwasm_std::{
1414
use cvm_route::asset::{AssetItem, AssetReference};
1515
use cvm_runtime::{
1616
outpost::{ExecuteMsg, ExecuteProgramMsg, OutpostId},
17-
shared::{XcFunds, XcPacket, XcProgram},
17+
shared::{CvmFunds, CvmPacket, CvmProgram},
1818
transport::ibc::{to_cosmwasm_message, IbcIcs20ProgramRoute, XcMessageData},
1919
AssetId, CallOrigin,
2020
};
@@ -69,7 +69,7 @@ pub(crate) fn handle_bridge_forward(
6969
.map(|(_, amount)| (route.on_remote_asset, *amount))
7070
.expect("not empty");
7171

72-
let packet = XcPacket {
72+
let packet = CvmPacket {
7373
executor: String::from(info.sender).into_bytes(),
7474
user_origin: msg.executor_origin.user_origin.clone(),
7575
salt: msg.msg.salt,
@@ -235,14 +235,14 @@ pub(crate) fn ics20_message_hook(
235235
env: Env,
236236
info: MessageInfo,
237237
) -> Result<Response, ContractError> {
238-
let packet: XcPacket = msg.packet;
238+
let packet: CvmPacket = msg.packet;
239239
ensure_anonymous(&packet.program)?;
240240
deps.api.debug(&format!(
241241
"cvm::outpost::ibc::ics20:: received assets {:?}, packet assets {:?}",
242242
&info.funds, &packet.assets
243243
));
244244

245-
let assets: Result<XcFunds, ContractError> = info
245+
let assets: Result<CvmFunds, ContractError> = info
246246
.funds
247247
.into_iter()
248248
.map(|coin| {
@@ -271,7 +271,7 @@ pub(crate) fn ics20_message_hook(
271271
Ok(Response::new().add_submessage(SubMsg::reply_always(msg, ReplyId::ExecProgram.into())))
272272
}
273273

274-
fn ensure_anonymous(program: &XcProgram) -> Result<()> {
274+
fn ensure_anonymous(program: &CvmProgram) -> Result<()> {
275275
use cvm_runtime::Instruction::*;
276276
for ix in &program.instructions {
277277
match ix {

contracts/cosmwasm/outpost/src/contract/ibc/ics27.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use cosmwasm_std::{
1919
IbcPacketTimeoutMsg, IbcReceiveResponse, MessageInfo, Response, SubMsg,
2020
};
2121
use cvm_route::transport::ChannelInfo;
22-
use cvm_runtime::{proto::Isomorphism, shared::XcPacket, CallOrigin, XCVMAck};
22+
use cvm_runtime::{proto::Isomorphism, shared::CvmPacket, CallOrigin, XCVMAck};
2323
use ibc_core_host_types::identifiers::{ChannelId, ConnectionId};
2424

2525
use super::make_ibc_failure_event;
@@ -92,7 +92,7 @@ pub fn ibc_packet_receive(
9292
) -> Result<IbcReceiveResponse> {
9393
let response = IbcReceiveResponse::default().add_event(make_event("receive"));
9494
let msg = (|| -> Result<_> {
95-
let packet = XcPacket::decode(&msg.packet.data)?;
95+
let packet = CvmPacket::decode(&msg.packet.data)?;
9696
let call_origin = CallOrigin::Remote {
9797
user_origin: packet.user_origin,
9898
};
@@ -122,7 +122,7 @@ pub fn ibc_packet_receive(
122122
pub fn ibc_packet_ack(_deps: DepsMut, _env: Env, msg: IbcPacketAckMsg) -> Result<IbcBasicResponse> {
123123
let ack = XCVMAck::try_from(msg.acknowledgement.data.as_slice())
124124
.map_err(|_| ContractError::InvalidAck)?;
125-
XcPacket::decode(&msg.original_packet.data)?;
125+
CvmPacket::decode(&msg.original_packet.data)?;
126126
Ok(IbcBasicResponse::default().add_event(make_event("ack").add_attribute("ack", ack)))
127127
}
128128

@@ -132,7 +132,7 @@ pub fn ibc_packet_timeout(
132132
_env: Env,
133133
msg: IbcPacketTimeoutMsg,
134134
) -> Result<IbcBasicResponse> {
135-
XcPacket::decode(&msg.packet.data)?;
135+
CvmPacket::decode(&msg.packet.data)?;
136136
// https://github.com/cosmos/ibc/pull/998
137137
Ok(IbcBasicResponse::default())
138138
}
@@ -157,7 +157,7 @@ pub(crate) fn handle_bridge_forward_no_assets(
157157
let channel_id = other.connection.ics27_channel.map(|x| x.id).ok_or(
158158
ContractError::ConnectionFromToNotFoundOverIcs27(this.network_id, msg.to_network),
159159
)?;
160-
let executor = XcPacket {
160+
let executor = CvmPacket {
161161
executor: String::from(info.sender).into_bytes(),
162162
user_origin: msg.executor_origin.user_origin,
163163
salt: msg.msg.salt,

contracts/solana/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Overview
2+
3+
Describes solana-outpost and solana-executor contracts.
4+

contracts/solana/executor/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Per user program instance.

contracts/solana/outpost/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
ICS27 like implementation adhering to solana-ibc app module.

crates/cvm-glt/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
authors = ["Composable Developers"]
3+
edition = "2021"
4+
homepage = "https://composable.finance"
5+
name = "cvm-glt"
6+
version = "0.1.0"

crates/cvm-glt/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Global Lookup Table
2+
3+
Accounts, connections and assets abstractions registry.
4+
5+
Configuration stored on each routeable chain.
6+
7+
8+
Naming inspired by https://solana.com/docs/advanced/lookup-tables . Unlike registry, which usually in native identifiers, it also stores mapping for some global indexes to local native names.

crates/cvm-glt/src/lib.rs

Whitespace-only changes.

crates/cvm-runtime/src/executor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use cosmwasm_std::Event;
22

33
use crate::prelude::*;
4-
use crate::shared::XcProgram;
4+
use crate::shared::CvmProgram;
55
use crate::ExecutorOrigin;
66

77
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
@@ -32,7 +32,7 @@ pub struct Step {
3232
/// instructions we already consumed.
3333
pub instruction_pointer: u16,
3434
/// The next instructions to execute (actual program).
35-
pub program: XcProgram,
35+
pub program: CvmProgram,
3636
}
3737

3838
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
@@ -43,7 +43,7 @@ pub struct Step {
4343
#[serde(rename_all = "snake_case")]
4444
pub enum ExecuteMsg {
4545
/// Execute an CVM program
46-
Execute { tip: Addr, program: XcProgram },
46+
Execute { tip: Addr, program: CvmProgram },
4747

4848
/// This is only meant to be used by the executor itself, otherwise it will return an error
4949
/// The existence of this message is to allow the execution of the `Call` instruction. Once we

crates/cvm-runtime/src/outpost/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub struct ExecuteProgramMsg<Assets = Option<Funds<crate::shared::Displayed<u128
171171
#[serde(skip_serializing_if = "Vec::is_empty", default)]
172172
pub salt: Vec<u8>,
173173
/// The program.
174-
pub program: crate::shared::XcProgram,
174+
pub program: crate::shared::CvmProgram,
175175
/// Assets to fund the CVM executor instance.
176176
/// The executor is funded prior to execution.
177177
/// If None, 100% of received funds go to executor.

crates/cvm-runtime/src/outpost/query.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,7 @@ pub struct GetConfigResponse {
112112
pub networks: Vec<NetworkItem>,
113113
pub network_assets: Vec<NetworkAssetItem>,
114114
}
115+
116+
// impl GetConfigResponse {
117+
// pub fn
118+
// }

crates/cvm-runtime/src/shared.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,29 @@ use serde::{de::DeserializeOwned, Serialize};
55
pub use cvm::shared::*;
66
pub type Salt = Vec<u8>;
77
/// absolute amounts
8-
pub type XcFunds = Vec<(AssetId, Displayed<u128>)>;
9-
/// like `XcFunds`, but allow relative(percentages) amounts. Similar to assets filters in XCM
10-
pub type XcBalanceFilter = crate::asset::Amount;
11-
pub type XcFundsFilter = crate::Funds<XcBalanceFilter>;
12-
pub type XcInstruction = crate::Instruction<Vec<u8>, XcAddr, XcFundsFilter>;
13-
pub type XcPacket = crate::Packet<XcProgram>;
14-
pub type XcProgram = crate::Program<Vec<XcInstruction>>;
8+
pub type CvmFunds = Vec<(AssetId, Displayed<u128>)>;
9+
/// like `CvmFunds`, but allow relative(percentages) amounts. Similar to assets filters in XCM
10+
pub type CvmBalanceFilter = crate::asset::Amount;
11+
pub type CvmFundsFilter = crate::Funds<CvmBalanceFilter>;
12+
pub type CvmInstruction = crate::Instruction<Vec<u8>, XcAddr, CvmFundsFilter>;
13+
pub type CvmPacket = crate::Packet<CvmProgram>;
14+
pub type CvmProgram = crate::Program<Vec<CvmInstruction>>;
1515

16-
impl XcInstruction {
16+
impl CvmProgram {
17+
fn new(instructions: Vec<CvmInstruction>) -> Self {
18+
Self {
19+
tag: vec![0],
20+
instructions,
21+
}
22+
}
23+
}
24+
25+
26+
impl CvmInstruction {
1727
pub fn transfer_absolute_to_account(to: &str, asset_id: u128, amount: u128) -> Self {
1828
Self::Transfer {
1929
to: crate::Destination::Account(XcAddr(to.to_owned())),
20-
assets: XcFundsFilter::one(asset_id.into(), crate::Amount::new(amount, 0)),
30+
assets: CvmFundsFilter::one(asset_id.into(), crate::Amount::new(amount, 0)),
2131
}
2232
}
2333
}

crates/cvm-runtime/src/transport/ibc/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
outpost::{self, Ics20Features, OutpostId},
33
prelude::*,
4-
shared::XcPacket,
4+
shared::CvmPacket,
55
AssetId, NetworkId,
66
};
77
use cosmwasm_std::{Api, BlockInfo, CosmosMsg, Deps, IbcEndpoint, StdResult};
@@ -25,7 +25,7 @@ use ibc_apps_more::{
2525
)]
2626
pub struct XcMessageData {
2727
pub from_network_id: NetworkId,
28-
pub packet: XcPacket,
28+
pub packet: CvmPacket,
2929
}
3030

3131
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
@@ -68,7 +68,7 @@ pub fn to_cosmwasm_message<T>(
6868
api: &dyn Api,
6969
coin: Coin,
7070
route: IbcIcs20ProgramRoute,
71-
packet: XcPacket,
71+
packet: CvmPacket,
7272
block: BlockInfo,
7373
to_outpost: Addr,
7474
) -> StdResult<CosmosMsg<T>> {

0 commit comments

Comments
 (0)