Update to substrate alpha.7 release (#105)

* Update to substrate alpha.7

* Remove gas limit from contracts put code

* Rename SystemEvent::ReapedAccount to KilledAccount

* Log debug event received before attempting to decode

* Temporary registration of Balance type before #102 merged

* Show contract test errors, increase instantiate gas_limit
This commit is contained in:
Andrew Jones
2020-05-06 09:15:14 +01:00
committed by GitHub
parent 5001a161d7
commit f2c42f88cf
5 changed files with 36 additions and 37 deletions
+11 -6
View File
@@ -95,6 +95,10 @@ impl<T: System> TryFrom<Metadata> for EventsDecoder<T> {
type_sizes: HashMap::new(),
marker: PhantomData,
};
// REMOVE when https://github.com/paritytech/substrate-subxt/pull/102 is merged
// Balance type will be registered by the proc macro.
decoder.register_type_size::<u128>("Balance")?;
// register default event arg type sizes for dynamic decoding of events
decoder.register_type_size::<bool>("bool")?;
decoder.register_type_size::<u32>("ReferendumIndex")?;
@@ -225,6 +229,12 @@ impl<T: System> EventsDecoder<T> {
let event_variant = input.read_byte()?;
let event_metadata = module.event(event_variant)?;
log::debug!(
"received event '{}::{}'",
module.name(),
event_metadata.name
);
let mut event_data = Vec::<u8>::new();
self.decode_raw_bytes(
&event_metadata.arguments(),
@@ -232,12 +242,7 @@ impl<T: System> EventsDecoder<T> {
&mut event_data,
)?;
log::debug!(
"received event '{}::{}', raw bytes: {}",
module.name(),
event_metadata.name,
hex::encode(&event_data),
);
log::debug!("raw bytes: {}", hex::encode(&event_data),);
RuntimeEvent::Raw(RawEvent {
module: module.name().to_string(),
+9 -15
View File
@@ -41,9 +41,6 @@ pub trait Contracts: System + Balances {}
/// You can instantiate contracts only with stored code.
#[derive(Debug, Encode)]
pub struct PutCodeCall<'a> {
/// Gas limit.
#[codec(compact)]
pub gas_limit: Gas,
/// Wasm blob.
pub code: &'a [u8],
}
@@ -171,13 +168,7 @@ mod tests {
let xt = client.xt(signer, None).await?;
let result = xt
.watch()
.submit(PutCodeCall {
gas_limit: 500_000,
code: &wasm,
})
.await?;
let result = xt.watch().submit(PutCodeCall { code: &wasm }).await?;
let code_hash = result
.find_event::<CodeStoredEvent<T>>()?
.ok_or(Error::Other("Failed to find CodeStored event".into()))?
@@ -190,7 +181,7 @@ mod tests {
#[ignore] // requires locally running substrate node
fn tx_put_code() {
env_logger::try_init().ok();
let code_hash: Result<_, Error> = async_std::task::block_on(async move {
let code_hash_result: Result<_, Error> = async_std::task::block_on(async move {
let signer = AccountKeyring::Alice.pair();
let client = test_client().await;
let code_hash = put_code(&client, signer).await?;
@@ -198,8 +189,11 @@ mod tests {
});
assert!(
code_hash.is_ok(),
"Contracts CodeStored event should be received and decoded"
code_hash_result.is_ok(),
format!(
"Error calling put_code and receiving CodeStored Event: {:?}",
code_hash_result
)
);
}
@@ -220,7 +214,7 @@ mod tests {
.watch()
.submit(InstantiateCall {
endowment: 100_000_000_000_000,
gas_limit: 500_000,
gas_limit: 500_000_000,
code_hash: &code_hash,
data: &[],
})
@@ -235,7 +229,7 @@ mod tests {
assert!(
result.is_ok(),
"Contract should be instantiated successfully"
format!("Error instantiating contract: {:?}", result)
);
}
}
+1 -1
View File
@@ -184,7 +184,7 @@ pub enum SystemEvent<T: System> {
/// A new account was created.
NewAccount(T::AccountId),
/// An account was reaped.
ReapedAccount(T::AccountId),
KilledAccount(T::AccountId),
}
/// A phase of a block's execution.