Skip to content

Commit

Permalink
Gas mechanics phase 1 implementation. (#1471)
Browse files Browse the repository at this point in the history
* Added a new message topic for auto relaying.

* WIP.

* some stuff.

* Working deposits and transfers tree.

* Adding missing files.

* Progress dump.

* removed TransferTree.

* Removed transfer tree from proto.

* Revert "Removed transfer tree from proto."

This reverts commit c85dba1.

* Revert "removed TransferTree."

This reverts commit ecc84bf.

* Adding back removed line.

* Working state. Gas not payed due to creator differences.

* Working version.

* Testing for gas mechanics in the sim tests.

* Fix for tests.

* Fixed linter issues.

* Ran gofumpt.

* Fixed more linter issues.

* Linter fix.

* Fixed in mem test.

* Fixed race condition for gas price oracle.

* Fix crash.

* Changes to when no base fee is applied.

* Update for chain validation.

* Fix for build.'

* Added gas price estimation return.

* Seemingly fully working version.

* Fixed compilation bug.

* Ran gofumpt.

* Fix linter issue.'

* Resolved PR comments.

* Ran gofumpt.

* Added gas limit config.

* Generate abi bindings.

* Version that deploys.

* Working version with baseFee == 1

* Adding forgotten file.

* Fix for toml test.

* Fixed immediate batch block bug.

* Added testing contract.

* Added default address for gas payments.

* Fixes for PR review.

* Ran gofumpt.

* Stopped test that shouldn't run in GH.

* Modified gas limit.

* Linter fixes.

* Gofumpt.

---------

Co-authored-by: StefanIliev545 <[email protected]>
Co-authored-by: StefanIliev545 <[email protected]>
  • Loading branch information
3 people authored Sep 21, 2023
1 parent 61a5921 commit c4864da
Show file tree
Hide file tree
Showing 68 changed files with 1,199 additions and 235 deletions.
13 changes: 7 additions & 6 deletions 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:8025",
"url": "http://127.0.0.1:37000",
"deploy": [
"deployment_scripts/core/layer1/",
"deployment_scripts/testnet/layer1/",
Expand All @@ -13,15 +13,16 @@
},
"localObscuro": {
"chainId": 777,
"url": "http://127.0.0.1:3000/v1",
"obscuroEncRpcUrl": "ws://127.0.0.1:81",
"gasPrice": 2000000000,
"url": "http://127.0.0.1:3000/v1/",
"obscuroEncRpcUrl": "ws://127.0.0.1:37901",
"companionNetworks" : {
"layer1" : "localGeth"
},
"deploy": [
"deployment_scripts/core/layer2/",
"deployment_scripts/bridge/layer2/",
"deployment_scripts/messenger/layer1",
"deployment_scripts/messenger/layer2",
"deployment_scripts/bridge/",
"deployment_scripts/testnet/layer1/",
"deployment_scripts/testnet/layer2/"
],
"accounts": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ 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!!
const messageBusAddress : string = process.env.MESSAGE_BUS_ADDRESS || "0xa1fdA5f6Df55a326f5f4300F3A716317f0f03110"
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
await deployments.deploy('CrossChainMessenger', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// Get the prefunded L2 deployer account to use for deploying.
const {deployer} = await getNamedAccounts();

console.log(`Deployer acc ${deployer}`);

// TODO: Remove hardcoded L2 message bus address when properly exposed.
const busAddress = hre.ethers.utils.getAddress("0x526c84529b2b8c11f57d93d3f5537aca3aecef9b")

console.log(`Beginning deploy of cross chain messenger`);

// Deploy the L2 Cross chain messenger and use the L2 bus for validation
await deployments.deploy('CrossChainMessenger', {
from: deployer,
from: deployer,
args: [ busAddress ],
log: true,
});
Expand Down
28 changes: 28 additions & 0 deletions contracts/deployment_scripts/testing/001_gas_testing_deployment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import { Receipt } from 'hardhat-deploy/dist/types';


const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const l2Network = hre;
const {deployer} = await hre.getNamedAccounts();

const gcb = await l2Network.deployments.deploy("GasConsumerBalance", {
from: deployer,
log: true
})


const gasConsumerBalance = await hre.ethers.getContractAt("GasConsumerBalance", gcb.address)
const gasEstimation = await gasConsumerBalance.estimateGas.get_balance({from: deployer});

await hre.deployments.execute("GasConsumerBalance", {
from: deployer,
gasLimit: gasEstimation.div(2),
log: true
}, "get_balance");
};


export default func;
func.tags = ['GasDebug'];
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,26 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
let messages = getXChainMessages(hocResult);
messages = messages.concat(getXChainMessages(pocResult));

console.log("Attempting to verify cross chain message transfer.");

// Poll message submission
await new Promise(async (resolve, fail)=> {
setTimeout(fail, 30_000)
const messageBusContract = (await hre.ethers.getContractAt('MessageBus', '0x526c84529b2b8c11f57d93d3f5537aca3aecef9b'));
while (await messageBusContract.callStatic.verifyMessageFinalized(messages[1]) != true) {
console.log(`Messages not stored on L2 yet, retrying...`);
await sleep(1_000);
try {
while (await messageBusContract.callStatic.verifyMessageFinalized(messages[1], {
maxFeePerGas: 2,
}) != true) {
console.log(`Messages not stored on L2 yet, retrying...`);
await sleep(1_000);
}
}catch (err) {
console.log(err)
fail(err)
}



resolve(true);
});

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Large diffs are not rendered by default.

Loading

0 comments on commit c4864da

Please sign in to comment.