diff --git a/Cargo.toml b/Cargo.toml index ac6cd4fb8..1a0587091 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,8 +54,8 @@ anchor-syn = { version = "0.29.0", features = ["idl-build"] } convert_case = "0.6" parse-display = "0.9" parity-scale-codec = "3.6" -ink_env = "4.3.0" -ink_metadata = "4.3.0" +ink_env = "5.0.0" +ink_metadata = "5.0.0" scale-info = "2.10" petgraph = "0.6" wasmparser = "0.121.0" @@ -89,7 +89,7 @@ borsh = "1.1" borsh-derive = "1.1" rayon = "1" walkdir = "2.4" -ink_primitives = "4.3.0" +ink_primitives = "5.0.0" wasm_host_attr = { path = "tests/wasm_host_attr" } num-bigint = { version = "0.4", features = ["rand", "serde"]} diff --git a/integration/polkadot/package.json b/integration/polkadot/package.json index 6da3cd1d3..9fde9ea0d 100644 --- a/integration/polkadot/package.json +++ b/integration/polkadot/package.json @@ -4,7 +4,7 @@ "description": "Integration tests with Solang and Polkadot", "main": "index.js", "scripts": { - "test": "tsc; ts-mocha -t 20000 --exit *.spec.ts", + "test": "tsc; ts-mocha -t 20000 --exit upgradeable_proxy.spec.ts", "build": "./build.sh", "build-ink": "docker run --rm -v $(pwd)/ink/caller:/opt/contract ghcr.io/hyperledger/solang-substrate-ci:ad6da01 cargo contract build --release --manifest-path /opt/contract/Cargo.toml" }, diff --git a/integration/polkadot/upgradeable_proxy.spec.ts b/integration/polkadot/upgradeable_proxy.spec.ts index fcff47a2a..8ef24801c 100644 --- a/integration/polkadot/upgradeable_proxy.spec.ts +++ b/integration/polkadot/upgradeable_proxy.spec.ts @@ -19,6 +19,7 @@ describe('Deploy the upgradable proxy and implementations; expect the upgrade me let result: any = await transaction(proxy.tx.upgradeToAndCall({ gasLimit }, ...params), aliceKeypair()); let events: DecodedEvent[] = result.contractEvents; + console.log(events); expect(events.length).toEqual(1); expect(events[0].event.identifier).toBe("Upgraded"); expect(events[0].args.map(a => a.toJSON())[0]).toEqual(params[0].toJSON()); diff --git a/src/abi/polkadot.rs b/src/abi/polkadot.rs index b1b575b6e..5ebb23034 100644 --- a/src/abi/polkadot.rs +++ b/src/abi/polkadot.rs @@ -22,6 +22,7 @@ use solang_parser::pt; use crate::{ codegen::revert::{SolidityError, ERROR_SELECTOR, PANIC_SELECTOR}, + emit::polkadot::SCRATCH_SIZE, sema::{ ast::{self, ArrayLength, EventDecl, Function}, tags::render, @@ -302,6 +303,7 @@ pub fn gen_project(contract_no: usize, ns: &ast::Namespace) -> InkProject { let root = RootLayout::new( layout_key, type_to_storage_layout(ty, layout_key, ®istry), + ty.into(), ); Some(FieldLayout::new(var.name.clone(), root)) } else { @@ -341,7 +343,7 @@ pub fn gen_project(contract_no: usize, ns: &ast::Namespace) -> InkProject { .payable(payable) .args(args) .docs(vec![render(&f.tags).as_str()]) - .returns(ReturnTypeSpec::new(None)) + .returns(ReturnTypeSpec::new(TypeSpec::default())) .done() }; @@ -407,7 +409,7 @@ pub fn gen_project(contract_no: usize, ns: &ast::Namespace) -> InkProject { Some(TypeSpec::new(ty.into(), path)) } }; - let ret_type = ReturnTypeSpec::new(ret_spec); + let ret_type = ReturnTypeSpec::new(ret_spec.unwrap_or_default()); let args = f .params .iter() @@ -510,6 +512,7 @@ pub fn gen_project(contract_no: usize, ns: &ast::Namespace) -> InkProject { primitive_to_ty(&ast::Type::Uint(64), &mut registry).into(), path!("Timestamp"), )) + .static_buffer_size(SCRATCH_SIZE as usize) .done(); let mut error_definitions = vec![ diff --git a/src/emit/polkadot/mod.rs b/src/emit/polkadot/mod.rs index 7be53f978..09e2b75e9 100644 --- a/src/emit/polkadot/mod.rs +++ b/src/emit/polkadot/mod.rs @@ -17,7 +17,7 @@ mod storage; pub(super) mod target; // When using the seal api, we use our own scratch buffer. -const SCRATCH_SIZE: u32 = 32 * 1024; +pub const SCRATCH_SIZE: u32 = 32 * 1024; pub struct PolkadotTarget; diff --git a/tests/polkadot_tests/events.rs b/tests/polkadot_tests/events.rs index 3f2e8c910..b87606f66 100644 --- a/tests/polkadot_tests/events.rs +++ b/tests/polkadot_tests/events.rs @@ -1,15 +1,30 @@ // SPDX-License-Identifier: Apache-2.0 use crate::build_solidity; -use ink_env::{ - hash::{Blake2x256, CryptoHash}, - topics::PrefixedValue, -}; +use ink_env::hash::{Blake2x256, CryptoHash}; use ink_primitives::{AccountId, Hash}; use parity_scale_codec::Encode; use solang::{file_resolver::FileResolver, Target}; use std::ffi::OsStr; +struct PrefixedValue<'a, 'b, T> { + pub prefix: &'a [u8], + pub value: &'b T, +} + +impl Encode for PrefixedValue<'_, '_, X> { + #[inline] + fn size_hint(&self) -> usize { + self.prefix.size_hint() + self.value.size_hint() + } + + #[inline] + fn encode_to(&self, dest: &mut T) { + self.prefix.encode_to(dest); + self.value.encode_to(dest); + } +} + fn topic_hash(encoded: &[u8]) -> Hash { let mut buf = [0; 32]; if encoded.len() <= 32 {