Skip to content

Commit a2e4571

Browse files
committed
Set gas cost for new Bridge methods to get/set super/base events info
1 parent 69cfc37 commit a2e4571

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

rskj-core/src/main/java/co/rsk/peg/BridgeMethods.java

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.ethereum.config.blockchain.upgrades.ActivationConfig;
3333
import org.ethereum.core.CallTransaction;
3434
import org.ethereum.db.ByteArrayWrapper;
35-
import org.ethereum.solidity.SolidityType;
3635
import org.ethereum.vm.MessageCall.MsgType;
3736

3837
/**
@@ -131,7 +130,7 @@ public enum BridgeMethods {
131130
CallTransaction.Function.fromSignature(
132131
"getBtcBlockchainBestChainHeight",
133132
new String[]{},
134-
new String[]{"int"}
133+
new String[]{INT}
135134
),
136135
fixedCost(19000L),
137136
(BridgeMethodExecutorTyped<Integer>) Bridge::getBtcBlockchainBestChainHeight,
@@ -142,7 +141,7 @@ public enum BridgeMethods {
142141
CallTransaction.Function.fromSignature(
143142
"getBtcBlockchainInitialBlockHeight",
144143
new String[]{},
145-
new String[]{"int"}
144+
new String[]{INT}
146145
),
147146
fixedCost(20000L),
148147
(BridgeMethodExecutorTyped<Integer>) Bridge::getBtcBlockchainInitialBlockHeight,
@@ -325,7 +324,7 @@ public enum BridgeMethods {
325324
CallTransaction.Function.fromSignature(
326325
"getMinimumLockTxValue",
327326
new String[]{},
328-
new String[]{"int"}
327+
new String[]{INT}
329328
),
330329
fixedCost(2000L),
331330
(BridgeMethodExecutorTyped<Long>) Bridge::getMinimumLockTxValue,
@@ -637,7 +636,7 @@ public enum BridgeMethods {
637636
REGISTER_BTC_TRANSACTION(
638637
CallTransaction.Function.fromSignature(
639638
"registerBtcTransaction",
640-
new String[]{BYTES, "int", BYTES},
639+
new String[]{BYTES, INT, BYTES},
641640
new String[]{}
642641
),
643642
fixedCost(22000L),
@@ -831,7 +830,7 @@ public enum BridgeMethods {
831830
CallTransaction.Function.fromSignature(
832831
"setUnionBridgeContractAddressForTestnet",
833832
new String[]{ADDRESS},
834-
new String[]{"int"}
833+
new String[]{INT}
835834
),
836835
fixedCost(8_000L),
837836
Bridge.executeIfTestnetAndAuthorized(
@@ -870,7 +869,7 @@ public enum BridgeMethods {
870869
CallTransaction.Function.fromSignature(
871870
"increaseUnionBridgeLockingCap",
872871
new String[]{UINT256},
873-
new String[]{"int"}
872+
new String[]{INT}
874873
),
875874
fixedCost(8_000L),
876875
Bridge.executeIfAuthorized(
@@ -885,7 +884,7 @@ public enum BridgeMethods {
885884
CallTransaction.Function.fromSignature(
886885
"requestUnionBridgeRbtc",
887886
new String[]{UINT256},
888-
new String[]{"int"}
887+
new String[]{INT}
889888
),
890889
fixedCost(8_000L),
891890
(BridgeMethodExecutorTyped<Integer>) Bridge::requestUnionBridgeRbtc,
@@ -896,7 +895,7 @@ public enum BridgeMethods {
896895
CallTransaction.Function.fromSignature(
897896
"releaseUnionBridgeRbtc",
898897
new String[]{},
899-
new String[]{"int"}
898+
new String[]{INT}
900899
),
901900
fixedCost(8_000L),
902901
(BridgeMethodExecutorTyped<Integer>) Bridge::releaseUnionBridgeRbtc,
@@ -907,7 +906,7 @@ public enum BridgeMethods {
907906
CallTransaction.Function.fromSignature(
908907
"setUnionBridgeTransferPermissions",
909908
new String[]{BOOL, BOOL},
910-
new String[]{"int"}
909+
new String[]{INT}
911910
),
912911
fixedCost(8_000L),
913912
Bridge.executeIfAuthorized(
@@ -924,7 +923,7 @@ public enum BridgeMethods {
924923
new String[]{},
925924
new String[]{BYTES}
926925
),
927-
fixedCost(3_000L), // TODO define final cost
926+
fixedCost(3_000L),
928927
(BridgeMethodExecutorTyped<byte[]>) Bridge::getSuperEvent,
929928
activations -> activations.isActive(RSKIP529),
930929
fixedPermission(false),
@@ -936,7 +935,7 @@ public enum BridgeMethods {
936935
new String[]{BYTES},
937936
new String[]{}
938937
),
939-
fixedCost(8_000L), // TODO define final cost
938+
fixedCost(8_000L),
940939
(BridgeMethodExecutorVoid) Bridge::setSuperEvent,
941940
activations -> activations.isActive(RSKIP529),
942941
fixedPermission(false)
@@ -947,7 +946,7 @@ public enum BridgeMethods {
947946
new String[]{},
948947
new String[]{}
949948
),
950-
fixedCost(8_000L), // TODO define final cost
949+
fixedCost(8_000L),
951950
(BridgeMethodExecutorVoid) Bridge::clearSuperEvent,
952951
activations -> activations.isActive(RSKIP529),
953952
fixedPermission(false)
@@ -958,7 +957,7 @@ public enum BridgeMethods {
958957
new String[]{},
959958
new String[]{BYTES}
960959
),
961-
fixedCost(3_000L), // TODO define final cost
960+
fixedCost(3_000L),
962961
(BridgeMethodExecutorTyped<byte[]>) Bridge::getBaseEvent,
963962
activations -> activations.isActive(RSKIP529),
964963
fixedPermission(false),
@@ -970,7 +969,7 @@ public enum BridgeMethods {
970969
new String[]{BYTES},
971970
new String[]{}
972971
),
973-
fixedCost(8_000L), // TODO define final cost
972+
fixedCost(8_000L),
974973
(BridgeMethodExecutorVoid) Bridge::setBaseEvent,
975974
activations -> activations.isActive(RSKIP529),
976975
fixedPermission(false)
@@ -981,7 +980,7 @@ public enum BridgeMethods {
981980
new String[]{},
982981
new String[]{}
983982
),
984-
fixedCost(8_000L), // TODO define final cost
983+
fixedCost(8_000L),
985984
(BridgeMethodExecutorVoid) Bridge::clearBaseEvent,
986985
activations -> activations.isActive(RSKIP529),
987986
fixedPermission(false)
@@ -994,6 +993,12 @@ private static class CallTypeHelper {
994993
private static final Predicate<MsgType> RESTRICTED_TO_CALL = callType -> callType == MsgType.CALL;
995994
}
996995

996+
private static final Map<ByteArrayWrapper, BridgeMethods> SIGNATURES = Stream.of(BridgeMethods.values())
997+
.collect(Collectors.toMap(
998+
m -> new ByteArrayWrapper(m.getFunction().encodeSignature()),
999+
Function.identity()
1000+
));
1001+
9971002
private final CallTransaction.Function function;
9981003
private final CostProvider costProvider;
9991004
private final Function<ActivationConfig.ForBlock, Boolean> isEnabledFunction;
@@ -1186,10 +1191,4 @@ private static BridgeCallPermissionProvider fixedPermission(boolean onlyAllowsLo
11861191
private static BridgeCallPermissionProvider fromMethod(BridgeCallPermissionProvider bridgeCallPermissionProvider) {
11871192
return (Bridge bridge, Object[] args) -> bridgeCallPermissionProvider.getOnlyAllowLocalCallsPermission(bridge, args);
11881193
}
1189-
1190-
private static final Map<ByteArrayWrapper, BridgeMethods> SIGNATURES = Stream.of(BridgeMethods.values())
1191-
.collect(Collectors.toMap(
1192-
m -> new ByteArrayWrapper(m.getFunction().encodeSignature()),
1193-
Function.identity()
1194-
));
11951194
}

0 commit comments

Comments
 (0)