Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto funding script #1543

Merged
merged 28 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/config/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"layer1" : "localGeth"
},
"deploy": [
"deployment_scripts/funding/layer1",
"deployment_scripts/messenger/layer1",
"deployment_scripts/messenger/layer2",
"deployment_scripts/bridge/",
Expand Down
39 changes: 39 additions & 0 deletions contracts/deployment_scripts/funding/layer1/001_fund_accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';


const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const layer1 = hre.companionNetworks.layer1;

const {deployer} = await hre.getNamedAccounts();
const l1Accs = await layer1.getNamedAccounts();

const messageBusAddress = process.env.MESSAGE_BUS_ADDRESS || "0x3FA8A7A039519602eBA00D443a14C0eb2358359a"

const messageBus = (await hre.ethers.getContractFactory('MessageBus')).attach(messageBusAddress)
const prefundAmount = hre.ethers.utils.parseEther("0.5");
const tx = await messageBus.populateTransaction.sendValueToL2(deployer, prefundAmount, {
value: prefundAmount
});


console.log(`Sending ${prefundAmount} to ${deployer}`);

const receipt = await layer1.deployments.rawTx({
from: l1Accs.deployer,
to: messageBusAddress,
value: prefundAmount,
data: tx.data,
log: true,
waitConfirmations: 1,
});
if (receipt.events?.length === 0) {
console.log(`Account prefunding status = FAILURE NO CROSS CHAIN EVENT`);
} else {
console.log(`Account prefunding status = ${receipt.status}`);
}
};

export default func;
func.tags = ['GasPrefunding', 'GasPrefunding_deploy'];
// No dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.companionNetworks.layer1.getNamedAccounts();

// Read the message bus address from the management contract deployment.
const messageBusAddress : string = process.env.MESSAGE_BUS_ADDRESS || "0xa1fdA5f6Df55a326f5f4300F3A716317f0f03110"
const messageBusAddress : string = process.env.MESSAGE_BUS_ADDRESS || "0x3FA8A7A039519602eBA00D443a14C0eb2358359a"
console.log(`Message Bus address ${messageBusAddress}`);

// Setup the cross chain messenger and point it to the message bus from the management contract to be used for validation
Expand All @@ -27,4 +27,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

export default func;
func.tags = ['CrossChainMessenger', 'CrossChainMessenger_deploy'];
func.dependencies = ['ManagementContract', 'HPERC20']; //TODO: Remove HPERC20, this is only to have matching addresses.
func.dependencies = ['ManagementContract', 'HPERC20', 'GasPrefunding']; //TODO: Remove HPERC20, this is only to have matching addresses.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await new Promise(async (resolve, fail)=> {
setTimeout(fail, 30_000)
const messageBusContract = (await hre.ethers.getContractAt('MessageBus', '0x526c84529b2b8c11f57d93d3f5537aca3aecef9b'));
const gasLimit = await messageBusContract.estimateGas.verifyMessageFinalized(messages[1], {
maxFeePerGas: 2,
})
try {
while (await messageBusContract.callStatic.verifyMessageFinalized(messages[1], {
maxFeePerGas: 2,
gasLimit: gasLimit,
from: l2Accounts.deployer
}) != true) {
console.log(`Messages not stored on L2 yet, retrying...`);
await sleep(1_000);
Expand All @@ -108,8 +113,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
fail(err)
}



resolve(true);
});

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/generated/MessageBus/MessageBus.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/src/messaging/MessageBus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ contract MessageBus is IMessageBus, Ownable {
}

receive() external payable {
revert("the Wormhole contract does not accept assets");
this.sendValueToL2{value: msg.value}(msg.sender, msg.value);
}
}
2 changes: 1 addition & 1 deletion go/enclave/storage/init/edgelessdb/001_init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ create table if not exists obsdb.l1_msg
id INTEGER AUTO_INCREMENT,
message varbinary(1024) NOT NULL,
block binary(32) NOT NULL,
is_transfer boolean NOT NULL,
is_transfer boolean NOT NULL,
INDEX (block),
primary key (id)
);
Expand Down
1 change: 1 addition & 0 deletions go/node/docker_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func (d *DockerNode) startEnclave() error {
"-maxBatchSize=25600",
"-maxRollupSize=65536",
fmt.Sprintf("-logLevel=%d", d.cfg.logLevel),
"-obscuroGenesis", "{}",
)

if d.cfg.sgxEnabled {
Expand Down
1 change: 1 addition & 0 deletions testnet/launcher/l2contractdeployer/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (n *ContractDeployer) Start() error {
"saveDeployments" : true,
"companionNetworks" : { "layer1" : "layer1" },
"deploy": [
"deployment_scripts/funding/layer1",
"deployment_scripts/messenger/layer1",
"deployment_scripts/messenger/layer2",
"deployment_scripts/bridge/",
Expand Down
Loading