Skip to content

Commit

Permalink
Merge branch 'develop' into v1.17.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinaNikolaevaa committed Feb 17, 2025
2 parents 3748372 + cec2084 commit c335537
Show file tree
Hide file tree
Showing 24 changed files with 450 additions and 242 deletions.
16 changes: 16 additions & 0 deletions contracts/EIPs/ERC20/MultipleActions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ contract MultipleActionsERC20 {
erc20.transfer(transfer_to, transfer_amount);
}


function transferReadBalanceTransfer(
uint256 transfer_amount,
address transfer_to
) public {
uint current_balance;
uint balance_before = erc20.balanceOf(address(this));
uint expected_balance = balance_before - transfer_amount;
erc20.transfer(transfer_to, transfer_amount);
for (uint256 i = 0; i < 50; i++) {
current_balance = erc20.balanceOf(address(this));
require(current_balance == expected_balance, "balance not updated");
}
erc20.transfer(transfer_to, transfer_amount);
}

function mintMint(
uint256 mint_amount1,
uint256 mint_amount2
Expand Down
24 changes: 24 additions & 0 deletions contracts/common/Block.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import "../libraries/CarefulMath.sol";


contract BlockTimestamp is CarefulMath {
event Result(uint256 block_timestamp);

uint256 public a;
uint public accrualBlockTimestamp;
uint public accrualBlockNumber;
Expand All @@ -13,7 +15,9 @@ contract BlockTimestamp is CarefulMath {
uint256 value1;
uint256 value2;
}

mapping(uint256 => Data) public dataByTimestamp;

event DataAdded(uint256 timestamp, uint256 value1, uint256 value2);

constructor() {
Expand Down Expand Up @@ -50,6 +54,7 @@ contract BlockTimestamp is CarefulMath {

accrualBlockNumber = currentBlockTimestamp;
}

function addDataToMapping(uint256 _value1, uint256 _value2) public {
uint256 currentTimestamp = block.timestamp % 1000000;
for (uint256 i = 0; i < 20; i++) {
Expand All @@ -72,6 +77,7 @@ contract BlockTimestamp is CarefulMath {

contract BlockTimestampDeployer {
BlockTimestamp public blockTimestamp;

event Log(address indexed addr);

constructor() {
Expand All @@ -84,6 +90,7 @@ contract BlockTimestampDeployer {
contract BlockNumber is CarefulMath {
event Log(address indexed sender, string message);
event Result(uint256 block_number);

bytes32[64] public b;


Expand All @@ -93,6 +100,7 @@ contract BlockNumber is CarefulMath {
uint256 value1;
uint256 value2;
}

mapping(uint256 => Data) public dataByNumber;
uint256 public a;

Expand Down Expand Up @@ -148,4 +156,20 @@ contract BlockNumber is CarefulMath {

accrualBlockNumber = currentBlockNumber;
}


function accrueInterestIterative() public {
uint currentBlockNumber = block.number;
uint accrualBlockNumberPrior = accrualBlockNumber;

bytes memory result = new bytes(1000);
for (uint256 i = 0; i < 1000; i++) {
result[i] = "a";
}

(MathError mathErr, uint blockDelta) = subUInt(currentBlockNumber, accrualBlockNumberPrior);
require(mathErr == MathError.NO_ERROR, "calc block delta error");

accrualBlockNumber = currentBlockNumber;
}
}
53 changes: 44 additions & 9 deletions deploy/cli/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import typing as tp
import pathlib
import logging
import time

from paramiko.client import SSHClient
from scp import SCPClient
Expand Down Expand Up @@ -57,22 +58,56 @@ def deploy_infrastructure(
os.environ["TF_VAR_proxy_model_commit"] = proxy_branch
os.environ["TF_VAR_dockerhub_org_name"] = os.environ.get("GITHUB_REPOSITORY_OWNER")
os.environ["TF_VAR_devnet_solana_url"] = devnet_solana_url
os.environ["TF_LOG"] = "DEBUG"

if use_real_price:
os.environ["TF_VAR_use_real_price"] = "1"

instance_types = ["cpx51", "cx52", "cpx41", "cx42", "ccx33", "ccx43"]
locations = ["nbg1", "hel1", "fsn1", "ash", "hil", "sin"]
instances = [{"server_type": i, "location": j} for i in instance_types for j in locations]
print("Possible instance options: ", instances)

retry_amount = 10
retry_amount = (
len(instances) if len(instances) > retry_amount else retry_amount
) # Verify that we can try all regions and locations

terraform.init(backend_config=TF_BACKEND_CONFIG)
return_code, stdout, stderr = terraform.apply(skip_plan=True)
print(f"code: {return_code}")
print(f"stdout: {stdout}")
print(f"stderr: {stderr}")
with open("terraform.log", "w") as file:
file.write(stdout)
file.write(stderr)
if return_code != 0:

instance_iterator = 0
retry_iterator = 0
while retry_iterator < retry_amount:
return_code, stdout, stderr = terraform.apply(
skip_plan=True,
capture_output=True,
var={
"server_type": instances[instance_iterator]["server_type"],
"location": instances[instance_iterator]["location"],
},
)
print(f"code: {return_code}")
print(f"stdout: {stdout}")
print(f"stderr: {stderr}")
if return_code == 0:
break
elif return_code != 0:
retry_iterator += 1
if "(resource_unavailable)" in stderr:
instance_iterator += 1
print(
"Resource_unavailable; ",
instances[instance_iterator],
" Trying to recreate instances with another region / another instance type...",
)
else:
print("Retry because ", stderr, "; Retries left: ", retry_amount - retry_iterator)
time.sleep(3)
if retry_iterator >= retry_amount:
print("Retries left: ", retry_amount - retry_iterator)
print("Terraform apply failed:", stderr)
print("Terraform infrastructure is not built correctly")
sys.exit(1)

output = terraform.output(json=True)
print(f"output: {output}")
proxy_ip = output["proxy_ip"]["value"]
Expand Down
26 changes: 13 additions & 13 deletions deploy/hetzner/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ resource "hcloud_server" "proxy" {
content = data.template_file.proxy_init.rendered
destination = "/tmp/proxy_init.sh"

connection {
type = "ssh"
user = "root"
host = hcloud_server.proxy.ipv4_address
private_key = file("/tmp/ci-stands")
}
connection {
type = "ssh"
user = "root"
host = hcloud_server.proxy.ipv4_address
private_key = file("/tmp/ci-stands")
}

}

Expand All @@ -37,18 +37,18 @@ resource "hcloud_server" "proxy" {
"chmod a+x /tmp/proxy_init.sh",
"sudo /tmp/proxy_init.sh"
]
connection {
type = "ssh"
user = "root"
host = hcloud_server.proxy.ipv4_address
private_key = file("/tmp/ci-stands")
}
connection {
type = "ssh"
user = "root"
host = hcloud_server.proxy.ipv4_address
private_key = file("/tmp/ci-stands")
}

}

labels = {
environment = "ci"
purpose = "ci-oz-full-tests"
purpose = "ci-oz-full-tests"
}
depends_on = [
hcloud_server.solana
Expand Down
2 changes: 1 addition & 1 deletion deploy/hetzner/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ variable "dockerhub_org_name" {
}

variable "use_real_price" {
type = number
type = number
default = 0
}
Loading

0 comments on commit c335537

Please sign in to comment.