Skip to content

Commit

Permalink
Test ci 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ercecan committed Jul 19, 2024
1 parent 62f98db commit e46bd4c
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 60 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ jobs:
# cd crates/evm/src/evm/system_contracts
# forge test -vvv
# id: test

check_genesis_files:
strategy:
fail-fast: true
Expand All @@ -441,18 +440,14 @@ jobs:
with:
version: nightly

- name: Run Forge install
- name: Run Foundry Setup
run: |
cd crates/evm/src/evm/system_contracts
forge --version
forge install
id: forgeInstall

- name: Foundryup
run: |
cd crates/evm/src/evm/system_contracts
export FOUNDRY_HOME="$HOME/.foundry"
curl -L https://foundry.paradigm.xyz | bash
source $HOME/.bashrc
foundryup
id: foundryup
foundry --version
shell: bash

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -461,4 +456,5 @@ jobs:

- name: Run check_genesis.sh
run: ./.github/scripts/check_genesis.sh
shell: bash

146 changes: 97 additions & 49 deletions crates/evm/src/evm/system_contracts/script/GenesisToEvmJson.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,105 @@
import json
import sys
import time
import asyncio
i = 0
async def main():
global i
print(1)
with open(sys.argv[1], "r") as file:
data = json.load(file)
print(2)
i+=1
# Sort the data by key
data = {k: data[k] for k in sorted(data)}
print(3)
i+=1
new_data = []
print(4)
i+=1
for key in data:
new_data.append({
"address": key,
"balance": data[key]["balance"],
"code": data[key]["code"]
})
if data[key]["storage"] != {}:
new_data[-1]["storage"] = data[key]["storage"]
print(5)
i+=1
evm_json = {}
evm_json["data"] = new_data
evm_json["chain_id"] = 5655
evm_json["limit_contract_code_size"] = None
evm_json["spec"] = {"0": "SHANGHAI"}
evm_json["coinbase"] = "0x3100000000000000000000000000000000000005"
evm_json["starting_base_fee"] = 1000000000
evm_json["block_gas_limit"] = 30000000
evm_json["base_fee_params"] = {"max_change_denominator": 8, "elasticity_multiplier" : 2}
evm_json["difficulty"] = 0
evm_json["extra_data"] = "0x"
evm_json["timestamp"] = 0
evm_json["nonce"] = 0
print(6)
i+=1
with open(sys.argv[2], "w") as file:
json.dump(evm_json, file, indent=2)
print(7)
i+=1
# Copy evm.json to following paths
paths = [
"../../../../../resources/genesis/bitcoin-regtest/evm.json",
"../../../../../resources/genesis/mock/evm.json",
"../../../../../resources/genesis/mock-dockerized/evm.json",
"../../../../../resources/test-data/demo-tests/bitcoin-regtest/evm.json",
"../../../../../resources/test-data/demo-tests/mock/evm.json",
"../../../../../resources/test-data/integration-tests/evm.json",
"../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json",
"../../../../../resources/test-data/integration-tests-low-max-l2-blocks-per-l1/evm.json"
]
print(8)
i+=1

with open(sys.argv[1], "r") as file:
data = json.load(file)
# check if the files are equal

# Sort the data by key
data = {k: data[k] for k in sorted(data)}
for path in paths:
with open(path, "r") as file:
data = json.load(file)

new_data = []
if path == "../../../../../resources/genesis/bitcoin-regtest/evm.json":
print("111111\n\n\n\n\n")
# print(data)
print("222222\n\n\n\n\n")
# print(evm_json)
print("3333333\n\n\n\n\n")
if path == "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json":
new_evm_json = evm_json.copy()
new_evm_json["block_gas_limit"] = 1500000
if json.dumps(new_evm_json, indent=None, separators=(',', ':')) != json.dumps(data, indent=None, separators=(',', ':')):
print("Not Eq", path)
continue
if json.dumps(evm_json, indent=None, separators=(',', ':')) != json.dumps(data, indent=None, separators=(',', ':')):
print("Not Eq", path)

for key in data:
new_data.append({
"address": key,
"balance": data[key]["balance"],
"code": data[key]["code"]
})
if data[key]["storage"] != {}:
new_data[-1]["storage"] = data[key]["storage"]
print(9)
i+=1
print(i)
await asyncio.sleep(5)
print(10)
for path in paths:
print("W1")
with open(path, "w+") as file:
print("W2")
if path == "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json":
new_evm_json = evm_json.copy()
new_evm_json["block_gas_limit"] = 1500000
json.dump(new_evm_json, file, indent=2)
print("W3")
continue
json.dump(evm_json, file, indent=2)
print("W3")
print(11)

evm_json = {}
evm_json["data"] = new_data
evm_json["chain_id"] = 5655
evm_json["limit_contract_code_size"] = None
evm_json["spec"] = {"0": "SHANGHAI"}
evm_json["coinbase"] = "0x3100000000000000000000000000000000000005"
evm_json["starting_base_fee"] = 1000000000
evm_json["block_gas_limit"] = 30000000
evm_json["base_fee_params"] = {"max_change_denominator": 8, "elasticity_multiplier" : 2}
evm_json["difficulty"] = 0
evm_json["extra_data"] = "0x"
evm_json["timestamp"] = 0
evm_json["nonce"] = 0
if __name__ == '__main__':

with open(sys.argv[2], "w") as file:
json.dump(evm_json, file, indent=2)

# Copy evm.json to following paths
paths = [
"../../../../../resources/genesis/bitcoin-regtest/evm.json",
"../../../../../resources/genesis/mock/evm.json",
"../../../../../resources/genesis/mock-dockerized/evm.json",
"../../../../../resources/test-data/demo-tests/bitcoin-regtest/evm.json",
"../../../../../resources/test-data/demo-tests/mock/evm.json",
"../../../../../resources/test-data/integration-tests/evm.json",
"../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json",
"../../../../../resources/test-data/integration-tests-low-max-l2-blocks-per-l1/evm.json"
]

for path in paths:
with open(path, "w") as file:
if path == "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json":
new_evm_json = evm_json.copy()
new_evm_json["block_gas_limit"] = 1500000
json.dump(new_evm_json, file, indent=2)
continue
json.dump(evm_json, file, indent=2)
asyncio.run(main())

0 comments on commit e46bd4c

Please sign in to comment.