Skip to content

Commit

Permalink
bump rust version
Browse files Browse the repository at this point in the history
  • Loading branch information
mangas committed Dec 19, 2023
1 parent 72ba5e4 commit 6a79cb9
Show file tree
Hide file tree
Showing 100 changed files with 5,115 additions and 3,830 deletions.
885 changes: 562 additions & 323 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"core",
"chain/*",
Expand Down Expand Up @@ -26,6 +27,8 @@ prost = "0.11.9"
prost-types = "0.11.9"
tonic = { version = "0.8.3", features = ["tls-roots", "gzip"] }
tonic-build = { version = "0.8.4", features = ["prost"] }
wasmtime = "15.0.1"
wasmparser = "0.118.1"

# Incremental compilation on Rust 1.58 causes an ICE on build. As soon as graph node builds again, these can be removed.
[profile.test]
Expand Down
1 change: 0 additions & 1 deletion chain/arweave/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ prost-types = { workspace = true }
serde = "1.0"
sha2 = "0.10.8"

graph-runtime-wasm = { path = "../../runtime/wasm" }
graph-runtime-derive = { path = "../../runtime/derive" }

[dev-dependencies]
Expand Down
27 changes: 20 additions & 7 deletions chain/arweave/src/data_source.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use graph::anyhow::Context;
use graph::blockchain::{Block, TriggerWithHandler};
use graph::blockchain::{Block, DataSourceTemplate as _, TriggerWithHandler};
use graph::components::store::StoredDynamicDataSource;
use graph::data::subgraph::DataSourceContext;
use graph::prelude::SubgraphManifestValidationError;
use graph::data_source::DataSourceTemplateInfo;
use graph::prelude::{InstanceDSTemplateInfo, SubgraphManifestValidationError};
use graph::{
anyhow::{anyhow, Error},
blockchain::{self, Blockchain},
prelude::{
async_trait, BlockNumber, CheapClone, DataSourceTemplateInfo, Deserialize, Link,
LinkResolver, Logger,
},
prelude::{async_trait, BlockNumber, CheapClone, Deserialize, Link, LinkResolver, Logger},
semver,
};
use std::collections::HashSet;
Expand All @@ -34,7 +32,10 @@ pub struct DataSource {
}

impl blockchain::DataSource<Chain> for DataSource {
fn from_template_info(_info: DataSourceTemplateInfo<Chain>) -> Result<Self, Error> {
fn from_template_info(
_info: InstanceDSTemplateInfo,
_template: &graph::data_source::DataSourceTemplate<Chain>,
) -> Result<Self, Error> {
Err(anyhow!("Arweave subgraphs do not support templates"))
}

Expand Down Expand Up @@ -327,6 +328,18 @@ impl blockchain::DataSourceTemplate<Chain> for DataSourceTemplate {
}
}

impl Into<DataSourceTemplateInfo> for DataSourceTemplate {
fn into(self) -> DataSourceTemplateInfo {
DataSourceTemplateInfo {
api_version: self.api_version(),
runtime: self.runtime(),
name: self.name().to_string(),
manifest_idx: None,
kind: self.kind().to_string(),
}
}
}

#[derive(Clone, Debug, Default, Hash, Eq, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UnresolvedMapping {
Expand Down
88 changes: 56 additions & 32 deletions chain/arweave/src/runtime/abi.rs
Original file line number Diff line number Diff line change
@@ -1,100 +1,114 @@
use crate::codec;
use crate::trigger::TransactionWithBlockPtr;
use graph::runtime::gas::GasCounter;
use graph::runtime::{asc_new, AscHeap, AscPtr, HostExportError, ToAscObj};
use graph_runtime_wasm::asc_abi::class::{Array, Uint8Array};
use graph::runtime::wasm::asc_abi::class::{Array, Uint8Array};
use graph::runtime::{asc_new, AscHeap, AscPtr, HostExportError, ToAscObj, WasmInstanceContext};
use graph::wasmtime::StoreContextMut;

pub(crate) use super::generated::*;

impl ToAscObj<AscTag> for codec::Tag {
fn to_asc_obj<H: AscHeap + ?Sized>(
&self,
store: &mut StoreContextMut<WasmInstanceContext>,

heap: &mut H,
gas: &GasCounter,
) -> Result<AscTag, HostExportError> {
Ok(AscTag {
name: asc_new(heap, self.name.as_slice(), gas)?,
value: asc_new(heap, self.value.as_slice(), gas)?,
name: asc_new(store, heap, self.name.as_slice(), gas)?,
value: asc_new(store, heap, self.value.as_slice(), gas)?,
})
}
}

impl ToAscObj<AscTransactionArray> for Vec<Vec<u8>> {
fn to_asc_obj<H: AscHeap + ?Sized>(
&self,
store: &mut StoreContextMut<WasmInstanceContext>,

heap: &mut H,
gas: &GasCounter,
) -> Result<AscTransactionArray, HostExportError> {
let content = self
.iter()
.map(|x| asc_new(heap, x.as_slice(), gas))
.map(|x| asc_new(store, heap, x.as_slice(), gas))
.collect::<Result<Vec<AscPtr<Uint8Array>>, _>>()?;
Ok(AscTransactionArray(Array::new(&content, heap, gas)?))
Ok(AscTransactionArray(Array::new(store, &content, heap, gas)?))
}
}

impl ToAscObj<AscTagArray> for Vec<codec::Tag> {
fn to_asc_obj<H: AscHeap + ?Sized>(
&self,
store: &mut StoreContextMut<WasmInstanceContext>,

heap: &mut H,
gas: &GasCounter,
) -> Result<AscTagArray, HostExportError> {
let content = self
.iter()
.map(|x| asc_new(heap, x, gas))
.map(|x| asc_new(store, heap, x, gas))
.collect::<Result<Vec<_>, _>>()?;
Ok(AscTagArray(Array::new(&content, heap, gas)?))
Ok(AscTagArray(Array::new(store, &content, heap, gas)?))
}
}

impl ToAscObj<AscProofOfAccess> for codec::ProofOfAccess {
fn to_asc_obj<H: AscHeap + ?Sized>(
&self,
store: &mut StoreContextMut<WasmInstanceContext>,

heap: &mut H,
gas: &GasCounter,
) -> Result<AscProofOfAccess, HostExportError> {
Ok(AscProofOfAccess {
option: asc_new(heap, &self.option, gas)?,
tx_path: asc_new(heap, self.tx_path.as_slice(), gas)?,
data_path: asc_new(heap, self.data_path.as_slice(), gas)?,
chunk: asc_new(heap, self.chunk.as_slice(), gas)?,
option: asc_new(store, heap, &self.option, gas)?,
tx_path: asc_new(store, heap, self.tx_path.as_slice(), gas)?,
data_path: asc_new(store, heap, self.data_path.as_slice(), gas)?,
chunk: asc_new(store, heap, self.chunk.as_slice(), gas)?,
})
}
}

impl ToAscObj<AscTransaction> for codec::Transaction {
fn to_asc_obj<H: AscHeap + ?Sized>(
&self,
store: &mut StoreContextMut<WasmInstanceContext>,

heap: &mut H,
gas: &GasCounter,
) -> Result<AscTransaction, HostExportError> {
Ok(AscTransaction {
format: self.format,
id: asc_new(heap, self.id.as_slice(), gas)?,
last_tx: asc_new(heap, self.last_tx.as_slice(), gas)?,
owner: asc_new(heap, self.owner.as_slice(), gas)?,
tags: asc_new(heap, &self.tags, gas)?,
target: asc_new(heap, self.target.as_slice(), gas)?,
id: asc_new(store, heap, self.id.as_slice(), gas)?,
last_tx: asc_new(store, heap, self.last_tx.as_slice(), gas)?,
owner: asc_new(store, heap, self.owner.as_slice(), gas)?,
tags: asc_new(store, heap, &self.tags, gas)?,
target: asc_new(store, heap, self.target.as_slice(), gas)?,
quantity: asc_new(
store,
heap,
self.quantity
.as_ref()
.map(|b| b.as_ref())
.unwrap_or_default(),
gas,
)?,
data: asc_new(heap, self.data.as_slice(), gas)?,
data: asc_new(store, heap, self.data.as_slice(), gas)?,
data_size: asc_new(
store,
heap,
self.data_size
.as_ref()
.map(|b| b.as_ref())
.unwrap_or_default(),
gas,
)?,
data_root: asc_new(heap, self.data_root.as_slice(), gas)?,
signature: asc_new(heap, self.signature.as_slice(), gas)?,
data_root: asc_new(store, heap, self.data_root.as_slice(), gas)?,
signature: asc_new(store, heap, self.signature.as_slice(), gas)?,
reward: asc_new(
store,
heap,
self.reward.as_ref().map(|b| b.as_ref()).unwrap_or_default(),
gas,
Expand All @@ -106,24 +120,28 @@ impl ToAscObj<AscTransaction> for codec::Transaction {
impl ToAscObj<AscBlock> for codec::Block {
fn to_asc_obj<H: AscHeap + ?Sized>(
&self,
store: &mut StoreContextMut<WasmInstanceContext>,

heap: &mut H,
gas: &GasCounter,
) -> Result<AscBlock, HostExportError> {
Ok(AscBlock {
indep_hash: asc_new(heap, self.indep_hash.as_slice(), gas)?,
nonce: asc_new(heap, self.nonce.as_slice(), gas)?,
previous_block: asc_new(heap, self.previous_block.as_slice(), gas)?,
indep_hash: asc_new(store, heap, self.indep_hash.as_slice(), gas)?,
nonce: asc_new(store, heap, self.nonce.as_slice(), gas)?,
previous_block: asc_new(store, heap, self.previous_block.as_slice(), gas)?,
timestamp: self.timestamp,
last_retarget: self.last_retarget,
diff: asc_new(
store,
heap,
self.diff.as_ref().map(|b| b.as_ref()).unwrap_or_default(),
gas,
)?,
height: self.height,
hash: asc_new(heap, self.hash.as_slice(), gas)?,
tx_root: asc_new(heap, self.tx_root.as_slice(), gas)?,
hash: asc_new(store, heap, self.hash.as_slice(), gas)?,
tx_root: asc_new(store, heap, self.tx_root.as_slice(), gas)?,
txs: asc_new(
store,
heap,
&self
.txs
Expand All @@ -132,10 +150,11 @@ impl ToAscObj<AscBlock> for codec::Block {
.collect::<Vec<Vec<u8>>>(),
gas,
)?,
wallet_list: asc_new(heap, self.wallet_list.as_slice(), gas)?,
reward_addr: asc_new(heap, self.reward_addr.as_slice(), gas)?,
tags: asc_new(heap, &self.tags, gas)?,
wallet_list: asc_new(store, heap, self.wallet_list.as_slice(), gas)?,
reward_addr: asc_new(store, heap, self.reward_addr.as_slice(), gas)?,
tags: asc_new(store, heap, &self.tags, gas)?,
reward_pool: asc_new(
store,
heap,
self.reward_pool
.as_ref()
Expand All @@ -144,6 +163,7 @@ impl ToAscObj<AscBlock> for codec::Block {
gas,
)?,
weave_size: asc_new(
store,
heap,
self.weave_size
.as_ref()
Expand All @@ -152,6 +172,7 @@ impl ToAscObj<AscBlock> for codec::Block {
gas,
)?,
block_size: asc_new(
store,
heap,
self.block_size
.as_ref()
Expand All @@ -160,18 +181,19 @@ impl ToAscObj<AscBlock> for codec::Block {
gas,
)?,
cumulative_diff: asc_new(
store,
heap,
self.cumulative_diff
.as_ref()
.map(|b| b.as_ref())
.unwrap_or_default(),
gas,
)?,
hash_list_merkle: asc_new(heap, self.hash_list_merkle.as_slice(), gas)?,
hash_list_merkle: asc_new(store, heap, self.hash_list_merkle.as_slice(), gas)?,
poa: self
.poa
.as_ref()
.map(|poa| asc_new(heap, poa, gas))
.map(|poa| asc_new(store, heap, poa, gas))
.unwrap_or(Ok(AscPtr::null()))?,
})
}
Expand All @@ -180,12 +202,14 @@ impl ToAscObj<AscBlock> for codec::Block {
impl ToAscObj<AscTransactionWithBlockPtr> for TransactionWithBlockPtr {
fn to_asc_obj<H: AscHeap + ?Sized>(
&self,
store: &mut StoreContextMut<WasmInstanceContext>,

heap: &mut H,
gas: &GasCounter,
) -> Result<AscTransactionWithBlockPtr, HostExportError> {
Ok(AscTransactionWithBlockPtr {
tx: asc_new(heap, &self.tx.as_ref(), gas)?,
block: asc_new(heap, self.block.as_ref(), gas)?,
tx: asc_new(store, heap, &self.tx.as_ref(), gas)?,
block: asc_new(store, heap, self.block.as_ref(), gas)?,
})
}
}
2 changes: 1 addition & 1 deletion chain/arweave/src/runtime/generated.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use graph::runtime::wasm::asc_abi::class::{Array, AscString, Uint8Array};
use graph::runtime::{AscIndexId, AscPtr, AscType, DeterministicHostError, IndexForAscTypeId};
use graph::semver::Version;
use graph_runtime_derive::AscType;
use graph_runtime_wasm::asc_abi::class::{Array, AscString, Uint8Array};

#[repr(C)]
#[derive(AscType, Default)]
Expand Down
9 changes: 6 additions & 3 deletions chain/arweave/src/trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ use graph::prelude::web3::types::H256;
use graph::prelude::BlockNumber;
use graph::runtime::asc_new;
use graph::runtime::gas::GasCounter;
use graph::runtime::wasm::module::ToAscPtr;
use graph::runtime::AscHeap;
use graph::runtime::AscPtr;
use graph::runtime::HostExportError;
use graph_runtime_wasm::module::ToAscPtr;
use graph::runtime::WasmInstanceContext;
use graph::wasmtime::StoreContextMut;
use std::{cmp::Ordering, sync::Arc};

use crate::codec;
Expand Down Expand Up @@ -37,12 +39,13 @@ impl std::fmt::Debug for ArweaveTrigger {
impl ToAscPtr for ArweaveTrigger {
fn to_asc_ptr<H: AscHeap>(
self,
store: &mut StoreContextMut<WasmInstanceContext>,
heap: &mut H,
gas: &GasCounter,
) -> Result<AscPtr<()>, HostExportError> {
Ok(match self {
ArweaveTrigger::Block(block) => asc_new(heap, block.as_ref(), gas)?.erase(),
ArweaveTrigger::Transaction(tx) => asc_new(heap, tx.as_ref(), gas)?.erase(),
ArweaveTrigger::Block(block) => asc_new(store, heap, block.as_ref(), gas)?.erase(),
ArweaveTrigger::Transaction(tx) => asc_new(store, heap, tx.as_ref(), gas)?.erase(),
})
}
}
Expand Down
3 changes: 1 addition & 2 deletions chain/cosmos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "graph-chain-cosmos"
version.workspace = true
edition = "2018"
edition.workspace = true

[build-dependencies]
tonic-build = { workspace = true }
Expand All @@ -15,5 +15,4 @@ serde = "1.0"
anyhow = "1.0"
semver = "1.0.20"

graph-runtime-wasm = { path = "../../runtime/wasm" }
graph-runtime-derive = { path = "../../runtime/derive" }
Loading

0 comments on commit 6a79cb9

Please sign in to comment.