Skip to content

Commit

Permalink
Merge branch 'feat/docker' into feat/aragon-nov
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita P committed Nov 13, 2024
2 parents 3ef12ca + ffd060b commit e529aaa
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,23 @@ RUN if [ "$TARGETARCH" = "arm64" ]; then \
git clean -d -x -f; \
fi

RUN if [ "$TARGETARCH" = "arm64" ]; then \
# build solc-v0.8.19
git checkout v0.8.19; \
# the compiler throws warnings when compiling this version, and the warnings are treated as errors.
# we disable treating the warnings as errors, unless the build doesn't succeed
grep -rl '\-Werror' ./cmake/EthCompilerSettings.cmake | xargs sed -i 's/\-Werror/\-Wno\-error/g'; \
# there is no sudo in the container, but we are under root so we do not need it
grep -rl 'sudo make install' ./scripts/build.sh | xargs sed -i 's/sudo make install/make install/g'; \
# build solc faster
grep -rl 'make -j2' ./scripts/build.sh | xargs sed -i 's/make -j2/make -j4/g'; \
./scripts/build.sh; \
mv /usr/local/bin/solc /root/.solcx/solc-v0.8.19; \
git checkout .; \
git checkout develop; \
git clean -d -x -f; \
fi

RUN if [ "$TARGETARCH" = "arm64" ]; then \
# manually install vyper
mkdir /root/.vvm; \
Expand Down Expand Up @@ -288,6 +305,7 @@ RUN if [ "$TARGETARCH" = "arm64" ]; then /root/.solcx/solc-v0.8.4 --version | gr
RUN if [ "$TARGETARCH" = "arm64" ]; then /root/.solcx/solc-v0.8.6 --version | grep 'Version: 0.8.6+commit.11564f7e' || (echo "Incorrect solc-v0.8.6 version" && exit 1) fi
RUN if [ "$TARGETARCH" = "arm64" ]; then /root/.solcx/solc-v0.7.6 --version | grep 'Version: 0.7.6+commit.7338295f' || (echo "Incorrect solc-v0.7.6 version" && exit 1) fi
RUN if [ "$TARGETARCH" = "arm64" ]; then /root/.solcx/solc-v0.8.15 --version | grep 'Version: 0.8.15+commit.e14f2714' || (echo "Incorrect solc-v0.8.15 version" && exit 1) fi
RUN if [ "$TARGETARCH" = "arm64" ]; then /root/.solcx/solc-v0.8.19 --version | grep 'Version: 0.8.19+commit.7dd6d404' || (echo "Incorrect solc-v0.8.19 version" && exit 1) fi
RUN if [ "$TARGETARCH" = "arm64" ]; then /root/.solcx/solc-v0.8.24 --version | grep 'Version: 0.8.24+commit.e11b9ed9' || (echo "Incorrect solc-v0.8.24 version" && exit 1) fi
RUN if [ "$TARGETARCH" = "arm64" ]; then /root/.solcx/solc-v0.6.11 --version | grep 'Version: 0.6.11+commit.5ef660b1' || (echo "Incorrect solc-v0.6.11 version" && exit 1) fi
RUN if [ "$TARGETARCH" = "arm64" ]; then /root/.vvm/vyper-0.3.7 --version | grep '0.3.7+' || (echo "Incorrect vyper-0.3.7 version" && exit 1) fi
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ git clone [email protected]:lidofinance/scripts.git
cd scripts
docker build -t scenv .
```
Note: *If you are running on an arm64 processor (including Apple Silicon) - you will have to wait up to 2 hours while the Solidity compilers compile.*
Note: *If you are running on an arm64 processor (including Apple Silicon) - you will have to wait up to 4 hours while the Solidity compilers compile.*

#### Step 2. Set up the ENV VARs, for example:
- `WEB3_INFURA_PROJECT_ID` - **mandatory** for the execution of tests
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def add_balance_check_middleware():
# TODO: Such implicit manipulation of the balances may lead to hard-debugging errors in the future.
# Better to return back balance after request is done.
def ensure_balance(address):
if web3.eth.get_balance(address) < ETH(1):
if web3.eth.get_balance(address) < ETH(10):
set_balance(address, 1000000)

def balance_check_middleware(make_request, web3):
Expand Down
34 changes: 18 additions & 16 deletions tests/regression/test_csm.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,13 @@ def ref_slot():
return ref_slot


@pytest.fixture
def distribute_reward_tree(deposits_to_csm, fee_oracle, fee_distributor, node_operator, ref_slot):
consensus_version = fee_oracle.getConsensusVersion()
oracle_version = fee_oracle.getContractVersion()
def distribute_reward_tree(node_operator, ref_slot):
consensus_version = contracts.cs_fee_oracle.getConsensusVersion()
oracle_version = contracts.cs_fee_oracle.getContractVersion()

rewards = ETH(0.05)
oracle_report(cl_diff=rewards)
distributed_shares = contracts.lido.sharesOf(fee_distributor)
distributed_shares = contracts.lido.sharesOf(contracts.cs_fee_distributor)
assert distributed_shares > 0

report, report_hash, tree = prepare_csm_report({node_operator: distributed_shares}, ref_slot)
Expand All @@ -93,7 +92,7 @@ def distribute_reward_tree(deposits_to_csm, fee_oracle, fee_distributor, node_op
contracts.csm_hash_consensus,
)

fee_oracle.submitReportData(report, oracle_version, {"from": submitter})
contracts.cs_fee_oracle.submitReportData(report, oracle_version, {"from": submitter})
return tree


Expand Down Expand Up @@ -316,20 +315,23 @@ def test_csm_wsteth_bond(csm, accounting, node_operator):


@pytest.mark.usefixtures("deposits_to_csm")
def test_csm_claim_rewards_steth(csm, distribute_reward_tree, node_operator, fee_distributor):
tree = distribute_reward_tree.tree
shares = tree.values[0]["value"][1]
proof = list(tree.get_proof(tree.find(tree.leaf((node_operator, shares)))))
def test_csm_claim_rewards_steth(csm, node_operator, ref_slot):
reward_address = csm.getNodeOperator(node_operator)["rewardAddress"]
shares_before = contracts.lido.sharesOf(reward_address)
accounting_shares_before = contracts.lido.sharesOf(contracts.cs_accounting)

tree = distribute_reward_tree(node_operator, ref_slot).tree
shares = tree.values[0]["value"][1]
proof = list(tree.get_proof(tree.find(tree.leaf((node_operator, shares)))))

csm.claimRewardsStETH(node_operator, ETH(1), shares, proof, {"from": reward_address})
# subtract 10 to avoid rounding errors
assert contracts.lido.sharesOf(reward_address) > shares_before + shares - 10
shares_after = contracts.lido.sharesOf(reward_address)
accounting_shares_after = contracts.lido.sharesOf(contracts.cs_accounting)
assert shares_after == shares_before + (accounting_shares_before + shares - accounting_shares_after)

@pytest.mark.usefixtures("deposits_to_csm")
def test_csm_claim_rewards_wsteth(csm, distribute_reward_tree, node_operator, fee_distributor):
tree = distribute_reward_tree.tree
def test_csm_claim_rewards_wsteth(csm, node_operator, ref_slot):
tree = distribute_reward_tree(node_operator, ref_slot).tree
shares = tree.values[0]["value"][1]
proof = list(tree.get_proof(tree.find(tree.leaf((node_operator, shares)))))
reward_address = csm.getNodeOperator(node_operator)["rewardAddress"]
Expand All @@ -339,8 +341,8 @@ def test_csm_claim_rewards_wsteth(csm, distribute_reward_tree, node_operator, fe
assert contracts.wsteth.balanceOf(reward_address) > wsteth_before

@pytest.mark.usefixtures("deposits_to_csm")
def test_csm_claim_rewards_eth(csm, distribute_reward_tree, node_operator, fee_distributor):
tree = distribute_reward_tree.tree
def test_csm_claim_rewards_eth(csm, node_operator, ref_slot):
tree = distribute_reward_tree(node_operator, ref_slot).tree
shares = tree.values[0]["value"][1]
proof = list(tree.get_proof(tree.find(tree.leaf((node_operator, shares)))))
reward_address = csm.getNodeOperator(node_operator)["rewardAddress"]
Expand Down
2 changes: 1 addition & 1 deletion utils/test/csm_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def csm_add_node_operator(csm, accounting, node_operator, proof, keys_count=5, c
signatures_batch = random_signatures_batch(keys_count)

value = accounting.getBondAmountByKeysCount['uint256,uint256'](keys_count, curve_id)
set_balance_in_wei(node_operator, value + ETH(1))
set_balance_in_wei(node_operator, value + ETH(10))

csm.addNodeOperatorETH(
keys_count,
Expand Down

0 comments on commit e529aaa

Please sign in to comment.