Skip to content

Commit

Permalink
Initial constants and config for the max initcode size
Browse files Browse the repository at this point in the history
In order to implement the verification of initcode size, necessary for the RSKIP438,
we need the constant value with the max allowed value. So we can start to validate
and use it on the logic of the verification
  • Loading branch information
fmacleal committed Sep 5, 2024
1 parent 01bb758 commit 319d678
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion rskj-core/src/main/java/org/ethereum/config/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class Constants {

private static final long DEFAULT_MAX_TIMESTAMPS_DIFF_IN_SECS = 5L * 60; // 5 mins
private static final long TESTNET_MAX_TIMESTAMPS_DIFF_IN_SECS = 120L * 60; // 120 mins
private static final int MAX_CONTRACT_SIZE = 0x6000;
private static final int MAX_INITCODE_SIZE = 2 * MAX_CONTRACT_SIZE;


private final byte chainId;
private final boolean seedCowAccounts;
Expand Down Expand Up @@ -214,7 +217,11 @@ public static BigInteger getTransactionGasCap() {
}

public static int getMaxContractSize() {
return 0x6000;
return MAX_CONTRACT_SIZE;
}

public static int getMaxInitCodeSize() {
return MAX_INITCODE_SIZE;
}

public static int getMaxAddressByteLength() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public enum ConsensusRule {
RSKIP415("rskip415"),
RSKIP417("rskip417"),
RSKIP428("rskip428"),
RSKIP434("rskip434")
RSKIP434("rskip434"),
RSKIP438("rskip438")
;

private String configKey;
Expand Down
3 changes: 2 additions & 1 deletion rskj-core/src/main/resources/expected.conf
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ blockchain = {
rskip417 = <hardforkName>
rskip428 = <hardforkName>
rskip434 = <hardforkName>
}
rskip438 = <hardforkName>
}
}
gc = {
enabled = <enabled>
Expand Down
1 change: 1 addition & 0 deletions rskj-core/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ blockchain = {
rskip417 = arrowhead600
rskip428 = lovell700
rskip434 = arrowhead631
rskip438 = lovell700
}
}
gc = {
Expand Down
10 changes: 10 additions & 0 deletions rskj-core/src/test/java/org/ethereum/config/ConstantsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,14 @@ void rskip297ActivationTest() {
assertEquals(300, Constants.testnet(activationConfig).getMaxTimestampsDiffInSecs(preRskip297Config));
assertEquals(7200, Constants.testnet(activationConfig).getMaxTimestampsDiffInSecs(postRskip297Config));
}

@Test
void maxInitcodeSizeTest() {
//given
int maxInitCodeSizeExpected = 49152;
//when
int maxInitCodeSize = Constants.getMaxInitCodeSize();
//then
assertEquals(maxInitCodeSizeExpected, maxInitCodeSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class ActivationConfigTest {
" rskip417: arrowhead600",
" rskip434: arrowhead631",
" rskip428: lovell700",
" rskip438: lovell700",
"}"
));

Expand Down

0 comments on commit 319d678

Please sign in to comment.