Skip to content

Commit

Permalink
Merge pull request #42 from icon-project/eunki-bsc-tycho
Browse files Browse the repository at this point in the history
Set `Tycho` hardfork date on bsc mainnet
  • Loading branch information
kornery authored Jun 18, 2024
2 parents fa63c4a + 5872abf commit 053bdca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bmv/bsc2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = '0.6.0'
version = '0.6.1'

dependencies {
compileOnly("foundation.icon:javaee-api:$javaeeVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void verify(ChainConfig config, Header head) {
Context.require(head.getGasUsed().compareTo(head.getGasLimit()) < 0, "Invalid gas used");
Context.require(head.getSigner(BigInteger.valueOf(config.ChainID)).equals(head.getCoinbase()), "Coinbase mismatch");

if (config.isTycho(head.getNumber())) {
if (config.isTycho(head.getTime())) {
Context.require(head.getWithdrawalsHash().equals(EMPTY_WITHDRAWALS_HASH), "Invalid withdrawals hash");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ public static ChainConfig getInstance() {
public static ChainConfig fromChainID(BigInteger cid) {
if (cid.longValue() == 56L) {
// BSC Mainnet
return new ChainConfig(56L, 200L, 3L, BigInteger.valueOf(31302048L), null);
return new ChainConfig(56L, 200L, 3L, BigInteger.valueOf(31302048L),
BigInteger.valueOf(1718863500L));
} else if (cid.longValue() == 97L) {
// BSC Testnet
return new ChainConfig(97L, 200L, 3L, BigInteger.valueOf(31103030L),
BigInteger.valueOf(39539137L));
BigInteger.valueOf(1713330442L));
} else if (cid.longValue() == 99L) {
// Private BSC Testnet
return new ChainConfig(99L, 200L, 3L, BigInteger.valueOf(8), null);
Expand All @@ -72,8 +73,8 @@ public boolean isHertz(BigInteger number) {
return Hertz != null && Hertz.compareTo(number) <= 0;
}

public boolean isTycho(BigInteger number) {
return Tycho != null && Tycho.compareTo(number) <= 0;
public boolean isTycho(long time) {
return Tycho != null && Tycho.longValue() <= time;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static Header readObject(ObjectReader r) {
Hash withdrawalsHash = Hash.EMPTY;
BigInteger blobGasUsed = null;
BigInteger excessBlobGas = null;
if (ChainConfig.getInstance().isTycho(number)) {
if (ChainConfig.getInstance().isTycho(time)) {
withdrawalsHash = r.read(Hash.class);
blobGasUsed = r.readBigInteger();
excessBlobGas = r.readBigInteger();
Expand All @@ -135,7 +135,7 @@ public static Header readObject(ObjectReader r) {
}

public static void writeObject(ObjectWriter w, Header o) {
if (ChainConfig.getInstance().isTycho(o.number)) {
if (ChainConfig.getInstance().isTycho(o.time)) {
w.beginList(19);
} else if (ChainConfig.getInstance().isHertz(o.number)) {
w.beginList(16);
Expand All @@ -161,7 +161,7 @@ public static void writeObject(ObjectWriter w, Header o) {
Context.require(o.baseFee != null, "no fields for hertz");
w.write(o.baseFee);
}
if (ChainConfig.getInstance().isTycho(o.number)) {
if (ChainConfig.getInstance().isTycho(o.time)) {
Context.require(o.withdrawalsHash != Hash.EMPTY && o.blobGasUsed != null
&& o.excessBlobGas != null, "no fields for tycho");
w.write(o.withdrawalsHash);
Expand Down

0 comments on commit 053bdca

Please sign in to comment.