Skip to content

Commit

Permalink
Dumping debug scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanIliev545 committed Aug 21, 2024
1 parent 69e334f commit a7b3640
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
27 changes: 26 additions & 1 deletion contracts/config/networks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"localGeth": {
"url": "http://127.0.0.1:17000",
"url": "http://127.0.0.1:25400",
"deploy": [
"deployment_scripts/core"
],
Expand Down Expand Up @@ -63,5 +63,30 @@
"balance": "174165200000000000"
}
]
},
"uatGeth": {
"url": "http://dev-testnet-eth2network.uksouth.cloudapp.azure.com:8025",
"deploy": [
"deployment_scripts/core"
],
"accounts": [
"4bfe14725e685901c062ccd4e220c61cf9c189897b6c78bd18d7f51291b2b8f1"
]
},
"testUatObscuro": {
"chainId": 443,
"url": "https://uat-testnet.ten.xyz/v1/",
"useGateway": true,
"companionNetworks" : {
"layer1" : "uatGeth"
},
"deploy": [
"deployment_scripts/testing"
],
"accounts": [
"8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b",
"6e384a07a01263518a09a5424c7b6bbfc3604ba7d93f47e3a455cbdd7f9f0682",
"4bfe14725e685901c062ccd4e220c61cf9c189897b6c78bd18d7f51291b2b8f8"
]
}
}
31 changes: 25 additions & 6 deletions contracts/deployment_scripts/testing/003_simple_withdrawal.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {EthereumProvider, HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import { Receipt } from 'hardhat-deploy/dist/types';
import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
import { keccak256 } from 'ethers';
import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';

function process_value_transfer(ethers, value_transfer) {
const abiTypes = ['address', 'address', 'uint256', 'uint64'];
Expand All @@ -28,14 +29,18 @@ async function sleep(ms: number) {
setTimeout(resolve, ms);
});
}
async function waitForRootPublished(management, msg, proof, root, interval = 5000, timeout = 90000) {
async function waitForRootPublished(management, msg, proof, root, provider: EthereumProvider, interval = 5000, timeout = 90000) {
var gas_estimate = null
const l1Ethers = new HardhatEthersProvider(provider, "layer1")

const startTime = Date.now();
while (gas_estimate === null) {
try {
gas_estimate = await management.estimateGas.ExtractNativeValue(msg, proof, root, {} )
console.log(`Extracting native value from cross chain message for root ${root}`)
const tx = await management.getFunction('ExtractNativeValue').populateTransaction(msg, proof, root, {} )
gas_estimate = await l1Ethers.estimateGas(tx)
} catch (error) {
console.log(`Estimate gas threw error : ${error.reason}`)
console.log(`Estimate gas threw error : ${error}`)
}
if (Date.now() - startTime >= timeout) {
console.log(`Timed out waiting for the estimate gas to return`)
Expand Down Expand Up @@ -89,8 +94,22 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
return
}

var managementContract = await hre.ethers.getContractAt("ManagementContract", "0x526c84529b2b8c11f57d93d3f5537aca3aecef9b");


const networkConfig : any = await hre.network.provider.request({method: 'net_config'});
const mgmtContractAddress = networkConfig.ManagementContractAddress;
const messageBusAddress = networkConfig.MessageBusAddress;

const l1Accounts = await hre.companionNetworks.layer1.getNamedAccounts()
const fundTx = await hre.companionNetworks.layer1.deployments.rawTx({
from: l1Accounts.deployer,
to: messageBusAddress,
value: "1000",
})
console.log(`Message bus funding status = ${fundTx.status}`)

var managementContract = await hre.ethers.getContractAt("ManagementContract", mgmtContractAddress);
const estimation = await waitForRootPublished(managementContract, msg, proof, tree.root, hre.companionNetworks.layer1.provider)
console.log(`Estimation for native value extraction = ${estimation}`)
};


Expand Down
2 changes: 2 additions & 0 deletions integration/eth2network/pos_eth2_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ func startNetworkScript(gethNetworkPort, beaconP2PPort, gethRPCPort, gethHTTPPor
"--beacondata-dir", beacondataDir,
"--validatordata-dir", validatordataDir,
)
fmt.Println(cmd.String())

var out bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &out
Expand Down
1 change: 1 addition & 0 deletions integration/simulation/devnetwork/dev_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func (s *InMemDevNetwork) Start() {
// this is a new network, deploy the contracts to the L1
fmt.Println("Deploying Ten contracts to L1")
s.deployTenNetworkContracts()
fmt.Printf("L1 Port - %d\n", integration.StartPortNetworkTests)
}
fmt.Println("Starting Ten nodes")
s.startNodes()
Expand Down

0 comments on commit a7b3640

Please sign in to comment.