Auto determine block gas limit, small modification for supporting public networks
This commit is contained in:
parent
87590524d9
commit
e521205d0f
|
@ -1,10 +1,10 @@
|
|||
HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0
|
||||
HOME_BRIDGE_ADDRESS=0x0448A50271c3791A09939e45fbdffd70824e29BC
|
||||
HOME_TOKEN_ADDRESS=0x2c9aAaea798a992a8664c9e0a6D7C84E02A579f6
|
||||
HOME_START_BLOCK=13273212
|
||||
HOME_BRIDGE_ADDRESS=0x6ADCa5e691341fb9de8927d15c0a89B83A4E665e
|
||||
HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc
|
||||
HOME_START_BLOCK=13276224
|
||||
|
||||
SIDE_RPC_URL=https://sokol.poa.network
|
||||
SIDE_SHARED_DB_ADDRESS=0x9271D07B3C038a30347089C9Ec8B9FDc10a7a286
|
||||
SIDE_SHARED_DB_ADDRESS=0xda9a1cA2Fcb18cAB02934269369627D2b4ea8902
|
||||
|
||||
FOREIGN_URL=https://testnet-dex.binance.org/
|
||||
FOREIGN_CHAIN_ID=Binance-Chain-Nile
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0
|
||||
HOME_BRIDGE_ADDRESS=0x0448A50271c3791A09939e45fbdffd70824e29BC
|
||||
HOME_TOKEN_ADDRESS=0x2c9aAaea798a992a8664c9e0a6D7C84E02A579f6
|
||||
HOME_START_BLOCK=13273212
|
||||
HOME_BRIDGE_ADDRESS=0x6ADCa5e691341fb9de8927d15c0a89B83A4E665e
|
||||
HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc
|
||||
HOME_START_BLOCK=13276224
|
||||
|
||||
SIDE_RPC_URL=https://sokol.poa.network
|
||||
SIDE_SHARED_DB_ADDRESS=0x9271D07B3C038a30347089C9Ec8B9FDc10a7a286
|
||||
SIDE_SHARED_DB_ADDRESS=0xda9a1cA2Fcb18cAB02934269369627D2b4ea8902
|
||||
|
||||
FOREIGN_URL=https://testnet-dex.binance.org/
|
||||
FOREIGN_CHAIN_ID=Binance-Chain-Nile
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0
|
||||
HOME_BRIDGE_ADDRESS=0x0448A50271c3791A09939e45fbdffd70824e29BC
|
||||
HOME_TOKEN_ADDRESS=0x2c9aAaea798a992a8664c9e0a6D7C84E02A579f6
|
||||
HOME_START_BLOCK=13273212
|
||||
HOME_BRIDGE_ADDRESS=0x6ADCa5e691341fb9de8927d15c0a89B83A4E665e
|
||||
HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc
|
||||
HOME_START_BLOCK=13276224
|
||||
|
||||
SIDE_RPC_URL=https://sokol.poa.network
|
||||
SIDE_SHARED_DB_ADDRESS=0x9271D07B3C038a30347089C9Ec8B9FDc10a7a286
|
||||
SIDE_SHARED_DB_ADDRESS=0xda9a1cA2Fcb18cAB02934269369627D2b4ea8902
|
||||
|
||||
FOREIGN_URL=https://testnet-dex.binance.org/
|
||||
FOREIGN_CHAIN_ID=Binance-Chain-Nile
|
||||
|
|
|
@ -3,7 +3,7 @@ HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0
|
|||
#HOME_PRIVATE_KEY is taken from src/deploy/.keys.staging
|
||||
|
||||
#Set to '0x' for redeployment of token contract in staging environment
|
||||
HOME_TOKEN_ADDRESS=0x2c9aAaea798a992a8664c9e0a6D7C84E02A579f6
|
||||
HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc
|
||||
|
||||
VALIDATOR_ADDRESS_1=0xaaaaB15630f63cA01bb50943AaAb4008CB53748D
|
||||
VALIDATOR_ADDRESS_2=0xbbbb63D6Fc58bD14dAF9eeF653650c4D10f3dBC8
|
||||
|
|
|
@ -30,6 +30,8 @@ const lock = new AsyncLock()
|
|||
|
||||
let homeValidatorNonce
|
||||
let sideValidatorNonce
|
||||
let homeBlockGasLimit
|
||||
let sideBlockGasLimit
|
||||
|
||||
const app = express()
|
||||
app.use(express.json())
|
||||
|
@ -58,6 +60,9 @@ async function main () {
|
|||
homeValidatorNonce = await homeWeb3.eth.getTransactionCount(validatorAddress)
|
||||
sideValidatorNonce = await sideWeb3.eth.getTransactionCount(validatorAddress)
|
||||
|
||||
homeBlockGasLimit = (await homeWeb3.eth.getBlock("latest", false)).gasLimit
|
||||
sideBlockGasLimit = (await sideWeb3.eth.getBlock("latest", false)).gasLimit
|
||||
|
||||
console.log(`My validator address in home and side networks is ${validatorAddress}`)
|
||||
|
||||
app.listen(8001, () => {
|
||||
|
@ -190,7 +195,7 @@ function sideSendQuery (query) {
|
|||
}
|
||||
tx.gas = Math.min(Math.ceil(await query.estimateGas({
|
||||
from: validatorAddress
|
||||
}) * 1.5), 6721975)
|
||||
}) * 1.5), sideBlockGasLimit)
|
||||
const signedTx = await sideWeb3.eth.accounts.signTransaction(tx, VALIDATOR_PRIVATE_KEY)
|
||||
|
||||
return sideWeb3.eth.sendSignedTransaction(signedTx.rawTransaction)
|
||||
|
@ -204,8 +209,8 @@ function sideSendQuery (query) {
|
|||
console.log('Out of gas, retrying')
|
||||
return true
|
||||
} else {
|
||||
console.log('Home tx failed', e.message)
|
||||
return false
|
||||
console.log('Side tx failed, retrying', e.message)
|
||||
return true
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -228,7 +233,7 @@ function homeSendQuery (query) {
|
|||
}
|
||||
tx.gas = Math.min(Math.ceil(await query.estimateGas({
|
||||
from: validatorAddress
|
||||
}) * 1.5), 6721975)
|
||||
}) * 1.5), homeBlockGasLimit)
|
||||
const signedTx = await homeWeb3.eth.accounts.signTransaction(tx, VALIDATOR_PRIVATE_KEY)
|
||||
|
||||
return homeWeb3.eth.sendSignedTransaction(signedTx.rawTransaction)
|
||||
|
@ -242,8 +247,8 @@ function homeSendQuery (query) {
|
|||
console.log('Out of gas, retrying')
|
||||
return true
|
||||
} else {
|
||||
console.log('Home tx failed', e.message)
|
||||
return false
|
||||
console.log('Home tx failed, retrying', e.message)
|
||||
return true
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0
|
||||
HOME_TOKEN_ADDRESS=0x2c9aAaea798a992a8664c9e0a6D7C84E02A579f6
|
||||
HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc
|
||||
|
|
|
@ -9,8 +9,8 @@ const token = new web3.eth.Contract(abiToken, HOME_TOKEN_ADDRESS)
|
|||
|
||||
const address = process.argv[2]
|
||||
|
||||
web3.eth.getBalance(address).then(x => console.log(x.toString()))
|
||||
web3.eth.getBalance(address).then(x => console.log(`${x.toString()} wei`))
|
||||
|
||||
token.methods.balanceOf(address).call()
|
||||
.then(x => console.log(x.toString()))
|
||||
.catch(() => console.log(0))
|
||||
.then(x => console.log(`${x.toString()} tokens`))
|
||||
.catch(() => console.log('0 tokens'))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
HOME_RPC_URL=http://ganache_home:8545
|
||||
HOME_BRIDGE_ADDRESS=0x0448A50271c3791A09939e45fbdffd70824e29BC
|
||||
HOME_TOKEN_ADDRESS=0x2c9aAaea798a992a8664c9e0a6D7C84E02A579f6
|
||||
HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0
|
||||
HOME_BRIDGE_ADDRESS=0x6ADCa5e691341fb9de8927d15c0a89B83A4E665e
|
||||
HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc
|
||||
|
||||
#HOME_PRIVATE_KEY is taken from src/test-services/.keys.staging
|
||||
|
|
|
@ -12,6 +12,7 @@ const sender = web3.eth.accounts.privateKeyToAccount(`0x${HOME_PRIVATE_KEY}`).ad
|
|||
|
||||
async function main () {
|
||||
const HOME_CHAIN_ID = await web3.eth.net.getId()
|
||||
const blockGasLimit = (await web3.eth.getBlock("latest", false)).gasLimit
|
||||
|
||||
let to = process.argv[2]
|
||||
|
||||
|
@ -36,7 +37,7 @@ async function main () {
|
|||
}
|
||||
tx.gas = Math.min(Math.ceil(await query.estimateGas({
|
||||
from: sender
|
||||
}) * 1.5), 6721975)
|
||||
}) * 1.5), blockGasLimit)
|
||||
let signedTx = await web3.eth.accounts.signTransaction(tx, HOME_PRIVATE_KEY)
|
||||
|
||||
let receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1b71aae16f2c8c497f8d10067efcf522e6ad575b
|
||||
Subproject commit 73a6db93f4805b27f5c0f2b2c139869e8cecf581
|
Loading…
Reference in New Issue