Skip to content

Commit

Permalink
feat: inner watcher add devnet config
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkAfCod committed Nov 3, 2023
1 parent 775a73a commit 2a08192
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
1 change: 1 addition & 0 deletions hildr-node/src/main/java/io/optimism/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public record Config(
String jwtSecret,
String checkpointSyncUrl,
Integer rpcPort,
Boolean devnet,
ChainConfig chainConfig) {

/**
Expand Down
29 changes: 15 additions & 14 deletions hildr-node/src/main/java/io/optimism/driver/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,23 @@ public RollupConfigResutl getRollupConfig() {
rollupConfig.setRegolithTime(chainConfig.regolithTime());
rollupConfig.setBatchInboxAddress(chainConfig.batchInbox());
rollupConfig.setDepositContractAddress(chainConfig.depositContract());
rollupConfig.setL1SystemConfigAddress(chainConfig.systemConfigContract());
var curSysConfig = chainConfig.systemConfig();
var sc =
new SystemConfig(
curSysConfig.batchSender(),
curSysConfig.l1FeeOverhead(),
curSysConfig.l1FeeScalar(),
curSysConfig.gasLimit());
var latestGenesis =
new Genesis(
new BlockId(chainConfig.l1StartEpoch().hash(), chainConfig.l1StartEpoch().number()),
new BlockId(chainConfig.l2Genesis().hash(), chainConfig.l2Genesis().number()),
chainConfig.l2Genesis().timestamp(),
sc);
this.cachedRollConfig.setGenesis(latestGenesis);
this.cachedRollConfig = rollupConfig;
}
var curSysConfig = this.chainWatcher.getSystemConfig();
var sc =
new SystemConfig(
curSysConfig.batchSender(),
curSysConfig.l1FeeOverhead(),
curSysConfig.l1FeeScalar(),
curSysConfig.gasLimit());
var latestGenesis =
new Genesis(
new BlockId(chainConfig.l1StartEpoch().hash(), chainConfig.l1StartEpoch().number()),
new BlockId(chainConfig.l2Genesis().hash(), chainConfig.l2Genesis().number()),
chainConfig.l2Genesis().timestamp(),
sc);
this.cachedRollConfig.setGenesis(latestGenesis);
return this.cachedRollConfig;
}

Expand Down
7 changes: 6 additions & 1 deletion hildr-node/src/main/java/io/optimism/l1/InnerWatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public class InnerWatcher extends AbstractExecutionThreadService {

private Disposable l1HeadListener;

private boolean devnet = false;

/**
* create a InnerWatcher instance.
*
Expand All @@ -170,6 +172,7 @@ public InnerWatcher(
this.provider = Web3jProvider.createClient(config.l1RpcUrl());
this.l1StartBlock = l1StartBlock;
this.l2StartBlock = l2StartBlock;
this.devnet = config.devnet() != null && config.devnet();

this.blockUpdateQueue = queue;
this.currentBlock = l1StartBlock;
Expand Down Expand Up @@ -405,7 +408,9 @@ private EthBlock.Block getSafe() throws ExecutionException, InterruptedException
}

private EthBlock.Block getFinalized() throws ExecutionException, InterruptedException {
return this.pollBlock(this.provider, DefaultBlockParameterName.FINALIZED, false);
var parameter =
this.devnet ? DefaultBlockParameterName.LATEST : DefaultBlockParameterName.FINALIZED;
return this.pollBlock(this.provider, parameter, false);
}

private EthBlock.Block getHead() throws ExecutionException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,17 @@ public class RollupConfigResutl {
private String batchInboxAddress;

/**
* L1 Deposit Contract Address.
* L1 deposit contract address.
*/
@JsonProperty("deposit_contract_address")
private String depositContractAddress;

/**
* L1 system config address.
*/
@JsonProperty("l1_system_config_address")
private String l1SystemConfigAddress;

public Genesis getGenesis() {
return genesis;
}
Expand Down Expand Up @@ -173,6 +179,14 @@ public void setDepositContractAddress(String depositContractAddress) {
this.depositContractAddress = depositContractAddress;
}

public String getL1SystemConfigAddress() {
return l1SystemConfigAddress;
}

public void setL1SystemConfigAddress(String l1SystemConfigAddress) {
this.l1SystemConfigAddress = l1SystemConfigAddress;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -187,12 +201,13 @@ public boolean equals(Object o) {
&& Objects.equals(l2ChainId, that.l2ChainId)
&& Objects.equals(regolithTime, that.regolithTime)
&& Objects.equals(batchInboxAddress, that.batchInboxAddress)
&& Objects.equals(depositContractAddress, that.depositContractAddress);
&& Objects.equals(depositContractAddress, that.depositContractAddress)
&& Objects.equals(l1SystemConfigAddress, that.l1SystemConfigAddress);
}

@Override
public int hashCode() {
return Objects.hash(genesis, blockTime, maxSequencerDrift, seqWindowSize, channelTimeout,
l1ChainId, l2ChainId, regolithTime, batchInboxAddress, depositContractAddress);
l1ChainId, l2ChainId, regolithTime, batchInboxAddress, l1SystemConfigAddress);
}
}

0 comments on commit 2a08192

Please sign in to comment.