Skip to content

Commit 053bdca

Browse files
authoredJun 18, 2024··
Merge pull request #42 from icon-project/eunki-bsc-tycho
Set `Tycho` hardfork date on bsc mainnet
2 parents fa63c4a + 5872abf commit 053bdca

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed
 

‎bmv/bsc2/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = '0.6.0'
1+
version = '0.6.1'
22

33
dependencies {
44
compileOnly("foundation.icon:javaee-api:$javaeeVersion")

‎bmv/bsc2/src/main/java/foundation/icon/btp/bmv/bsc2/BTPMessageVerifier.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ private void verify(ChainConfig config, Header head) {
302302
Context.require(head.getGasUsed().compareTo(head.getGasLimit()) < 0, "Invalid gas used");
303303
Context.require(head.getSigner(BigInteger.valueOf(config.ChainID)).equals(head.getCoinbase()), "Coinbase mismatch");
304304

305-
if (config.isTycho(head.getNumber())) {
305+
if (config.isTycho(head.getTime())) {
306306
Context.require(head.getWithdrawalsHash().equals(EMPTY_WITHDRAWALS_HASH), "Invalid withdrawals hash");
307307
}
308308
}

‎bmv/bsc2/src/main/java/foundation/icon/btp/bmv/bsc2/ChainConfig.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ public static ChainConfig getInstance() {
5050
public static ChainConfig fromChainID(BigInteger cid) {
5151
if (cid.longValue() == 56L) {
5252
// BSC Mainnet
53-
return new ChainConfig(56L, 200L, 3L, BigInteger.valueOf(31302048L), null);
53+
return new ChainConfig(56L, 200L, 3L, BigInteger.valueOf(31302048L),
54+
BigInteger.valueOf(1718863500L));
5455
} else if (cid.longValue() == 97L) {
5556
// BSC Testnet
5657
return new ChainConfig(97L, 200L, 3L, BigInteger.valueOf(31103030L),
57-
BigInteger.valueOf(39539137L));
58+
BigInteger.valueOf(1713330442L));
5859
} else if (cid.longValue() == 99L) {
5960
// Private BSC Testnet
6061
return new ChainConfig(99L, 200L, 3L, BigInteger.valueOf(8), null);
@@ -72,8 +73,8 @@ public boolean isHertz(BigInteger number) {
7273
return Hertz != null && Hertz.compareTo(number) <= 0;
7374
}
7475

75-
public boolean isTycho(BigInteger number) {
76-
return Tycho != null && Tycho.compareTo(number) <= 0;
76+
public boolean isTycho(long time) {
77+
return Tycho != null && Tycho.longValue() <= time;
7778
}
7879

7980
}

‎bmv/bsc2/src/main/java/foundation/icon/btp/bmv/bsc2/Header.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static Header readObject(ObjectReader r) {
122122
Hash withdrawalsHash = Hash.EMPTY;
123123
BigInteger blobGasUsed = null;
124124
BigInteger excessBlobGas = null;
125-
if (ChainConfig.getInstance().isTycho(number)) {
125+
if (ChainConfig.getInstance().isTycho(time)) {
126126
withdrawalsHash = r.read(Hash.class);
127127
blobGasUsed = r.readBigInteger();
128128
excessBlobGas = r.readBigInteger();
@@ -135,7 +135,7 @@ public static Header readObject(ObjectReader r) {
135135
}
136136

137137
public static void writeObject(ObjectWriter w, Header o) {
138-
if (ChainConfig.getInstance().isTycho(o.number)) {
138+
if (ChainConfig.getInstance().isTycho(o.time)) {
139139
w.beginList(19);
140140
} else if (ChainConfig.getInstance().isHertz(o.number)) {
141141
w.beginList(16);
@@ -161,7 +161,7 @@ public static void writeObject(ObjectWriter w, Header o) {
161161
Context.require(o.baseFee != null, "no fields for hertz");
162162
w.write(o.baseFee);
163163
}
164-
if (ChainConfig.getInstance().isTycho(o.number)) {
164+
if (ChainConfig.getInstance().isTycho(o.time)) {
165165
Context.require(o.withdrawalsHash != Hash.EMPTY && o.blobGasUsed != null
166166
&& o.excessBlobGas != null, "no fields for tycho");
167167
w.write(o.withdrawalsHash);

0 commit comments

Comments
 (0)
Please sign in to comment.