Merge branch 'master' into ci/improve

This commit is contained in:
DaniPopes 2023-02-25 12:50:11 +01:00
commit c3748e95ea
No known key found for this signature in database
GPG Key ID: 0F09640DDB7AC692
4 changed files with 29 additions and 32 deletions

16
Cargo.lock generated
View File

@ -2688,18 +2688,18 @@ dependencies = [
[[package]]
name = "num_enum"
version = "0.5.10"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e0072973714303aa6e3631c7e8e777970cf4bdd25dc4932e41031027b8bcc4e"
checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9"
dependencies = [
"num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.5.10"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0629cbd6b897944899b1f10496d9c4a7ac5878d45fd61bc22e9e79bfbbc29597"
checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@ -4114,9 +4114,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
[[package]]
name = "svm-rs"
version = "0.2.21"
version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "719b86a8043b9bf425247c8f559edb1de8cfc5d444f8b8f19af2d7d24a7f0988"
checksum = "01afefe60c02f4a2271fb15d1965c37856712cebb338330b06649d12afec42df"
dependencies = [
"anyhow",
"cfg-if 1.0.0",
@ -4145,9 +4145,9 @@ dependencies = [
[[package]]
name = "svm-rs-builds"
version = "0.1.13"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7d778dbd9c8f2b55a44fd953c2ccf91e8e1893406693263a22c9403cf65156"
checksum = "2e69c19996b709c881de264a6ce64609ff305ef0bf59fc45243ac5a67291afd1"
dependencies = [
"build_const",
"hex",

View File

@ -42,7 +42,7 @@ cargo_metadata = { version = "0.15.3", optional = true }
convert_case = { version = "0.6.0", optional = true }
syn = { version = "1.0.108", optional = true }
proc-macro2 = { version = "1.0.51", optional = true }
num_enum = "0.5.10"
num_enum = "0.5.11"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tempfile = { version = "3.3.0", default-features = false }

View File

@ -539,14 +539,15 @@ impl I256 {
}
}
/// Wrapping addition.
/// Wrapping (modular) addition. Computes `self + rhs`, wrapping around at the boundary of the
/// type.
#[inline(always)]
#[must_use]
pub fn wrapping_add(self, rhs: Self) -> Self {
self.overflowing_add(rhs).0
}
/// Calculates ``self` - `rhs``
/// Calculates `self` - `rhs`
///
/// Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic
/// overflow would occur. If an overflow would have occurred then the wrapped value is returned.
@ -1034,13 +1035,8 @@ impl I256 {
}
}
/// Panic-free bitwise shift-left; yields `self << mask(rhs)`, where `mask` removes
/// any high-order bits of `rhs` that would cause the shift to exceed the bitwidth of the type.
///
/// Note that this is *not* the same as a rotate-left; the RHS of a wrapping shift-left is
/// restricted to the range of the type, rather than the bits shifted out of the LHS being
/// returned to the other end. The primitive integer types all implement a
/// [`rotate_left`](Self::rotate_left) function, which may be what you want instead.
/// Wrapping shift left. Computes `self << rhs`, returning 0 if larger than or equal to the
/// number of bits in `self`.
#[inline(always)]
#[must_use]
pub fn wrapping_shl(self, rhs: usize) -> Self {
@ -1072,31 +1068,32 @@ impl I256 {
}
}
/// Right shift by `rhs` bits.
/// Wrapping shift right. Computes `self >> rhs`, returning 0 if larger than or equal to the
/// number of bits in `self`.
#[inline(always)]
#[must_use]
pub fn wrapping_shr(self, rhs: usize) -> Self {
self.overflowing_shr(rhs).0
}
/// Arithmetic Shift Right operation. Shifts `shift` number of times to the right maintaining
/// the original sign. If the number is positive this is the same as logic shift right.
/// Arithmetic shift right operation. Computes `self >> rhs` maintaining the original sign. If
/// the number is positive this is the same as logic shift right.
#[inline(always)]
#[must_use]
pub fn asr(self, shift: usize) -> Self {
pub fn asr(self, rhs: usize) -> Self {
// Avoid shifting if we are going to know the result regardless of the value.
match (shift, self.sign()) {
match (rhs, self.sign()) {
(0, _) => self,
// Perform the shift.
(1..=254, Sign::Positive) => self >> shift,
(1..=254, Sign::Positive) => self.wrapping_shr(rhs),
(1..=254, Sign::Negative) => {
// We need to do: `for 0..shift { self >> 1 | 2^255 }`
// We can avoid the loop by doing: `self >> shift | ~(2^(255 - shift) - 1)`
// where '~' represents ones complement
const TWO: U256 = U256([2, 0, 0, 0]);
let bitwise_or = Self::from_raw(!(TWO.pow(U256::from(255 - shift)) - U256::one()));
(self >> shift) | bitwise_or
let bitwise_or = Self::from_raw(!(TWO.pow(U256::from(255 - rhs)) - U256::one()));
(self.wrapping_shr(rhs)) | bitwise_or
}
// It's always going to be zero (i.e. 00000000...00000000)
@ -1109,17 +1106,17 @@ impl I256 {
}
}
/// Arithmetic Shift Left operation. Shifts `shift` number of times to the left, checking for
/// overflow on the final result.
/// Arithmetic shift left operation. Computes `self << rhs`, checking for overflow on the final
/// result.
///
/// Returns `None` if the operation overflowed (most significant bit changes).
#[inline(always)]
#[must_use]
pub fn asl(self, shift: usize) -> Option<Self> {
if shift == 0 {
pub fn asl(self, rhs: usize) -> Option<Self> {
if rhs == 0 {
Some(self)
} else {
let result = self << shift;
let result = self.wrapping_shl(rhs);
if result.sign() != self.sign() {
// Overflow occurred
None

View File

@ -37,7 +37,7 @@ impl TestWallets {
pub async fn fund<T: JsonRpcClient, U: Into<u32>>(&self, provider: &Provider<T>, n: U) {
let addrs = (0..n.into()).map(|i| self.get(i).address()).collect::<Vec<_>>();
// hardcoded funder address private key, GOERLI
let signer = "39aa18eeb5d12c071e5f19d8e9375a872e90cb1f2fa640384ffd8800a2f3e8f1"
let signer = "9867bd0f8d9e16c57f5251b35a73f6f903eb8eee1bdc7f15256d0dc09d1945fb"
.parse::<LocalWallet>()
.unwrap()
.with_chain_id(provider.get_chainid().await.unwrap().as_u64());