From a8cf4efc915f8fd52d23918f35587b4d70e929bc Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 21 Nov 2017 20:43:23 +0100 Subject: [PATCH] Merge pull request #7110 from paritytech/remove-storage-error WASM storage_read and storage_write don't return anything --- ethcore/res/wasm-tests | 2 +- ethcore/wasm/src/env.rs | 4 ++-- ethcore/wasm/src/runtime.rs | 4 ++-- ethcore/wasm/src/tests.rs | 38 ++++++++++++++++++------------------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ethcore/res/wasm-tests b/ethcore/res/wasm-tests index d4920761f95..e5fcae4e9c2 160000 --- a/ethcore/res/wasm-tests +++ b/ethcore/res/wasm-tests @@ -1 +1 @@ -Subproject commit d4920761f959a785c3ec15cf2848fc75795eb2d4 +Subproject commit e5fcae4e9c2a570f293a22baa4d78d9f4b391a0f diff --git a/ethcore/wasm/src/env.rs b/ethcore/wasm/src/env.rs index 1a2f5fd3bf1..1004f3526ab 100644 --- a/ethcore/wasm/src/env.rs +++ b/ethcore/wasm/src/env.rs @@ -25,12 +25,12 @@ pub const SIGNATURES: &'static [UserFunctionDescriptor] = &[ Static( "_storage_read", &[I32; 2], - Some(I32), + None, ), Static( "_storage_write", &[I32; 2], - Some(I32), + None, ), Static( "_balance", diff --git a/ethcore/wasm/src/runtime.rs b/ethcore/wasm/src/runtime.rs index 3c2bd101e6c..0782876b5bb 100644 --- a/ethcore/wasm/src/runtime.rs +++ b/ethcore/wasm/src/runtime.rs @@ -168,7 +168,7 @@ impl<'a, 'b> Runtime<'a, 'b> { self.ext.set_storage(key, val).map_err(|_| UserTrap::StorageUpdateError)?; - Ok(Some(0i32.into())) + Ok(None) } /// Read from the storage to wasm memory @@ -184,7 +184,7 @@ impl<'a, 'b> Runtime<'a, 'b> { self.memory.set(val_ptr as u32, &*val)?; - Ok(Some(0.into())) + Ok(None) } /// Fetches balance for address diff --git a/ethcore/wasm/src/tests.rs b/ethcore/wasm/src/tests.rs index 9f8b7ddec2d..f5738871b0f 100644 --- a/ethcore/wasm/src/tests.rs +++ b/ethcore/wasm/src/tests.rs @@ -112,7 +112,7 @@ fn logger() { U256::from(1_000_000_000), "Logger sets 0x04 key to the trasferred value" ); - assert_eq!(gas_left, U256::from(19_143)); + assert_eq!(gas_left, U256::from(19_147)); } // This test checks if the contract can allocate memory and pass pointer to the result stream properly. @@ -180,7 +180,7 @@ fn dispersion() { result, vec![0u8, 0, 125, 11, 197, 7, 255, 8, 19, 0] ); - assert_eq!(gas_left, U256::from(96_961)); + assert_eq!(gas_left, U256::from(96_393)); } #[test] @@ -208,7 +208,7 @@ fn suicide_not() { result, vec![0u8] ); - assert_eq!(gas_left, U256::from(97_290)); + assert_eq!(gas_left, U256::from(96_725)); } #[test] @@ -240,7 +240,7 @@ fn suicide() { }; assert!(ext.suicides.contains(&refund)); - assert_eq!(gas_left, U256::from(97_249)); + assert_eq!(gas_left, U256::from(96_687)); } #[test] @@ -270,7 +270,7 @@ fn create() { assert!(ext.calls.contains( &FakeCall { call_type: FakeCallType::Create, - gas: U256::from(65_903), + gas: U256::from(65_899), sender_address: None, receive_address: None, value: Some(1_000_000_000.into()), @@ -278,7 +278,7 @@ fn create() { code_address: None, } )); - assert_eq!(gas_left, U256::from(65_896)); + assert_eq!(gas_left, U256::from(65_892)); } @@ -393,7 +393,7 @@ fn realloc() { } }; assert_eq!(result, vec![0u8; 2]); - assert_eq!(gas_left, U256::from(97_278)); + assert_eq!(gas_left, U256::from(96_723)); } // Tests that contract's ability to read from a storage @@ -419,7 +419,7 @@ fn storage_read() { }; assert_eq!(Address::from(&result[12..32]), address); - assert_eq!(gas_left, U256::from(99_706)); + assert_eq!(gas_left, U256::from(99_767)); } // Tests keccak calculation @@ -445,7 +445,7 @@ fn keccak() { }; assert_eq!(H256::from_slice(&result), H256::from("68371d7e884c168ae2022c82bd837d51837718a7f7dfb7aa3f753074a35e1d87")); - assert_eq!(gas_left, U256::from(82_009)); + assert_eq!(gas_left, U256::from(81_446)); } // memcpy test. @@ -477,7 +477,7 @@ fn memcpy() { }; assert_eq!(result, test_payload); - assert_eq!(gas_left, U256::from(72_773)); + assert_eq!(gas_left, U256::from(72_216)); } // memmove test. @@ -509,7 +509,7 @@ fn memmove() { }; assert_eq!(result, test_payload); - assert_eq!(gas_left, U256::from(72_773)); + assert_eq!(gas_left, U256::from(72_216)); } // memset test @@ -534,7 +534,7 @@ fn memset() { }; assert_eq!(result, vec![228u8; 8192]); - assert_eq!(gas_left, U256::from(72_763)); + assert_eq!(gas_left, U256::from(72_196)); } macro_rules! reqrep_test { @@ -591,7 +591,7 @@ fn math_add() { U256::from_dec_str("1888888888888888888888888888887").unwrap(), (&result[..]).into() ); - assert_eq!(gas_left, U256::from(96_084)); + assert_eq!(gas_left, U256::from(95_524)); } // multiplication @@ -613,7 +613,7 @@ fn math_mul() { U256::from_dec_str("888888888888888888888888888887111111111111111111111111111112").unwrap(), (&result[..]).into() ); - assert_eq!(gas_left, U256::from(95_234)); + assert_eq!(gas_left, U256::from(94_674)); } // subtraction @@ -635,7 +635,7 @@ fn math_sub() { U256::from_dec_str("111111111111111111111111111111").unwrap(), (&result[..]).into() ); - assert_eq!(gas_left, U256::from(96_076)); + assert_eq!(gas_left, U256::from(95_516)); } // subtraction with overflow @@ -677,7 +677,7 @@ fn math_div() { U256::from_dec_str("1125000").unwrap(), (&result[..]).into() ); - assert_eq!(gas_left, U256::from(89_074)); + assert_eq!(gas_left, U256::from(88_514)); } // This test checks the ability of wasm contract to invoke @@ -765,7 +765,7 @@ fn externs() { "Gas limit requested and returned does not match" ); - assert_eq!(gas_left, U256::from(95_291)); + assert_eq!(gas_left, U256::from(94_733)); } #[test] @@ -791,7 +791,7 @@ fn embedded_keccak() { }; assert_eq!(H256::from_slice(&result), H256::from("68371d7e884c168ae2022c82bd837d51837718a7f7dfb7aa3f753074a35e1d87")); - assert_eq!(gas_left, U256::from(82_009)); + assert_eq!(gas_left, U256::from(81_446)); } /// This test checks the correctness of log extern @@ -826,5 +826,5 @@ fn events() { assert_eq!(&log_entry.data, b"gnihtemos"); assert_eq!(&result, b"gnihtemos"); - assert_eq!(gas_left, U256::from(80_199)); + assert_eq!(gas_left, U256::from(79_637)); }