From 8a20d5cb52c07f241fe83932e1137b14ce3e343f Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 5 Nov 2019 11:56:03 +0000 Subject: [PATCH] rust: remove unneeded mutability in ExecutionContext --- CHANGELOG.md | 5 +++++ bindings/rust/evmc-vm/src/lib.rs | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 407bd7050..0b161700b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning]. which can be used to emulate Host behavior when testing VM implementations. [#456](https://github.com/ethereum/evmc/pull/456) +### Changed + +- In the Rust bindings mark read-only EVMC functions as non-mutating. + [#444](https://github.com/ethereum/evmc/pull/444) + ## [7.0.0] „Istanbul Ready” — 2019-11-11 diff --git a/bindings/rust/evmc-vm/src/lib.rs b/bindings/rust/evmc-vm/src/lib.rs index 6f604e000..c0c1afb3f 100644 --- a/bindings/rust/evmc-vm/src/lib.rs +++ b/bindings/rust/evmc-vm/src/lib.rs @@ -214,7 +214,7 @@ impl<'a> ExecutionContext<'a> { } /// Check if an account exists. - pub fn account_exists(&mut self, address: &Address) -> bool { + pub fn account_exists(&self, address: &Address) -> bool { unsafe { assert!((*self.host).account_exists.is_some()); (*self.host).account_exists.unwrap()(self.context, address as *const Address) @@ -222,7 +222,7 @@ impl<'a> ExecutionContext<'a> { } /// Read from a storage key. - pub fn get_storage(&mut self, address: &Address, key: &Bytes32) -> Bytes32 { + pub fn get_storage(&self, address: &Address, key: &Bytes32) -> Bytes32 { unsafe { assert!((*self.host).get_storage.is_some()); (*self.host).get_storage.unwrap()( @@ -252,7 +252,7 @@ impl<'a> ExecutionContext<'a> { } /// Get balance of an account. - pub fn get_balance(&mut self, address: &Address) -> Uint256 { + pub fn get_balance(&self, address: &Address) -> Uint256 { unsafe { assert!((*self.host).get_balance.is_some()); (*self.host).get_balance.unwrap()(self.context, address as *const Address) @@ -260,7 +260,7 @@ impl<'a> ExecutionContext<'a> { } /// Get code size of an account. - pub fn get_code_size(&mut self, address: &Address) -> usize { + pub fn get_code_size(&self, address: &Address) -> usize { unsafe { assert!((*self.host).get_code_size.is_some()); (*self.host).get_code_size.unwrap()(self.context, address as *const Address) @@ -268,7 +268,7 @@ impl<'a> ExecutionContext<'a> { } /// Get code hash of an account. - pub fn get_code_hash(&mut self, address: &Address) -> Bytes32 { + pub fn get_code_hash(&self, address: &Address) -> Bytes32 { unsafe { assert!((*self.host).get_code_size.is_some()); (*self.host).get_code_hash.unwrap()(self.context, address as *const Address) @@ -276,7 +276,7 @@ impl<'a> ExecutionContext<'a> { } /// Copy code of an account. - pub fn copy_code(&mut self, address: &Address, code_offset: usize, buffer: &mut [u8]) -> usize { + pub fn copy_code(&self, address: &Address, code_offset: usize, buffer: &mut [u8]) -> usize { unsafe { assert!((*self.host).copy_code.is_some()); (*self.host).copy_code.unwrap()( @@ -338,7 +338,7 @@ impl<'a> ExecutionContext<'a> { } /// Get block hash of an account. - pub fn get_block_hash(&mut self, num: i64) -> Bytes32 { + pub fn get_block_hash(&self, num: i64) -> Bytes32 { unsafe { assert!((*self.host).get_block_hash.is_some()); (*self.host).get_block_hash.unwrap()(self.context, num)