Skip to content

Commit

Permalink
fix to handle block
Browse files Browse the repository at this point in the history
  • Loading branch information
JSHan94 committed Dec 5, 2023
1 parent f99420d commit 795518c
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bots/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ export class Config implements ConfigInterface {
this.BATCH_SUBMITTER_MNEMONIC = BATCH_SUBMITTER_MNEMONIC;
this.CHALLENGER_MNEMONIC = CHALLENGER_MNEMONIC;
this.USE_LOG_FILE = !!JSON.parse(USE_LOG_FILE);
this.l1lcd = new LCDClient(L1_LCD_URI, {
this.l1lcd = new LCDClient(this.L1_LCD_URI[0], {
gasPrices: '0.15uinit',
gasAdjustment: '2'
});
this.l2lcd = new LCDClient(L2_LCD_URI, {
this.l2lcd = new LCDClient(this.L2_LCD_URI[0], {
gasPrices: '0.15umin',
gasAdjustment: '2'
});
Expand Down
89 changes: 89 additions & 0 deletions bots/src/scripts/fundAccounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { MnemonicKey, MsgSend, Wallet } from "@initia/initia.js";
import { getConfig } from "config";
import { sendTx } from "lib/tx";

const config = getConfig();
const L1_FUNDER = new Wallet(
config.l1lcd,
new MnemonicKey({
mnemonic: ''
})
)
const L2_FUNDER = new Wallet(
config.l2lcd,
new MnemonicKey({
mnemonic: ''
})
)

async function fundL1(){
const executor = new Wallet(config.l1lcd, new MnemonicKey({mnemonic: config.EXECUTOR_MNEMONIC}))
const output = new Wallet(config.l1lcd, new MnemonicKey({mnemonic: config.OUTPUT_SUBMITTER_MNEMONIC}))
const batch = new Wallet(config.l1lcd, new MnemonicKey({mnemonic: config.BATCH_SUBMITTER_MNEMONIC}))
const challenger = new Wallet(config.l1lcd, new MnemonicKey({mnemonic: config.CHALLENGER_MNEMONIC}))

const sendMsg = [
new MsgSend(
L1_FUNDER.key.accAddress,
executor.key.accAddress,
"50000000000uinit"
),
new MsgSend(
L1_FUNDER.key.accAddress,
output.key.accAddress,
"50000000000uinit"
),
new MsgSend(
L1_FUNDER.key.accAddress,
batch.key.accAddress,
"50000000000uinit"
),
new MsgSend(
L1_FUNDER.key.accAddress,
challenger.key.accAddress,
"50000000000uinit"
)
]
await sendTx(L1_FUNDER, sendMsg);
}

async function fundL2(){
const executor = new Wallet(config.l2lcd, new MnemonicKey({mnemonic: config.EXECUTOR_MNEMONIC}))
const output = new Wallet(config.l2lcd, new MnemonicKey({mnemonic: config.OUTPUT_SUBMITTER_MNEMONIC}))
const batch = new Wallet(config.l2lcd, new MnemonicKey({mnemonic: config.BATCH_SUBMITTER_MNEMONIC}))
const challenger = new Wallet(config.l2lcd, new MnemonicKey({mnemonic: config.CHALLENGER_MNEMONIC}))

const sendMsg = [
new MsgSend(
L2_FUNDER.key.accAddress,
executor.key.accAddress,
"1umin"
),
new MsgSend(
L2_FUNDER.key.accAddress,
output.key.accAddress,
"1umin"
),
new MsgSend(
L2_FUNDER.key.accAddress,
batch.key.accAddress,
"1umin"
),
new MsgSend(
L2_FUNDER.key.accAddress,
challenger.key.accAddress,
"1umin"
)
]
await sendTx(L2_FUNDER, sendMsg);
}

async function main(){
// await fundL1();
// await fundL2();
console.log('Funded accounts');
}

if (require.main === module) {
main();
}
2 changes: 1 addition & 1 deletion bots/src/scripts/setupL2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { executor, challenger, outputSubmitter } from 'test/utils/helper';
const config = getConfig();
const SUBMISSION_INTERVAL = 3600; // 1 hour
const FINALIZED_TIME = 3600; // 1 hour
const IBC_METADATA = 'channel-3';
const IBC_METADATA = 'channel-2'; // ibc channel name

class L2Initializer {
l2id = config.BRIDGE_ID;
Expand Down
8 changes: 6 additions & 2 deletions bots/src/worker/bridgeExecutor/Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ export abstract class Monitor {
if (nextHeight % 10 === 0) {
this.logger.info(`${this.name()} height ${nextHeight}`);
}

if (parseInt(metadata.num_txs) === 0) {

if (parseInt(metadata.num_txs) !== 0) {
await this.handleBlock(manager);
this.syncedHeight++;
await manager
.getRepository(StateEntity)
.update({ name: this.name() }, { height: this.syncedHeight });
continue;
}

Expand Down

0 comments on commit 795518c

Please sign in to comment.