Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/extcodehash #2075

Merged
merged 42 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
fd9852c
Add opcode: SHL,SHR,SAR
ithinker1991 Mar 13, 2019
5ec51d5
Add `CREATE2`
ithinker1991 Mar 11, 2019
15b8649
Create contract save returnH value
ithinker1991 Mar 13, 2019
5164c05
Add dataword negate method
ithinker1991 Mar 15, 2019
cefa536
Fix DataWord bug
ithinker1991 Mar 18, 2019
078af92
Fix sender
ithinker1991 Mar 19, 2019
a78dfc5
Add bytes coder
ithinker1991 Mar 19, 2019
bde8009
Add create2 opcode unit test
ithinker1991 Mar 19, 2019
6b18e28
Remove debug msg
ithinker1991 Mar 19, 2019
a5d4069
Add opcode: SHL,SHR,SAR
ithinker1991 Mar 13, 2019
4bf766e
Add bitwise shift instructions
ithinker1991 Mar 18, 2019
417297f
Add shift test
ithinker1991 Mar 20, 2019
ec2e7ae
Fix shiftRightSigned bug
ithinker1991 Mar 20, 2019
b0c742c
Eliminate hidden dangers of DataWord where ZERO is pushed in to the s…
ithinker1991 Mar 20, 2019
9ead847
Fix unsafe method
ithinker1991 Mar 21, 2019
5c5ec2e
Merge branch 'tip29_bitwise_shifting' into tip26_create2
ithinker1991 Mar 21, 2019
f7673d8
Add Zero DataWord
ithinker1991 Mar 21, 2019
b0c8138
Merge branch 'tip29_bitwise_shifting' into tip26_create2
ithinker1991 Mar 21, 2019
1057095
Fix bug
ithinker1991 Mar 21, 2019
b9348c8
Zero DataWord can be rightValue
ithinker1991 Mar 21, 2019
e7f58d1
Merge branch 'tip29_bitwise_shifting' into tip26_create2
ithinker1991 Mar 21, 2019
9aa288b
Add repeat create2 test case
ithinker1991 Mar 21, 2019
0b9faef
refactor
BlueHoopor Mar 22, 2019
7895022
Polish code
ithinker1991 Mar 22, 2019
7aaac97
refactor
BlueHoopor Mar 22, 2019
f0e1ae8
Merge branch 'tip26_create2' of github.com:tronprotocol/java-tron int…
ithinker1991 Mar 22, 2019
30c55b7
Rename final var
ithinker1991 Mar 22, 2019
17b0ba3
refactor: add ALLOW_TVM_CONSTANTINOPLE proposal
CodeNinjaEvan Mar 22, 2019
2acc81b
refactor: filter the decision by allowTvmConstantinople proposal
CodeNinjaEvan Mar 22, 2019
c4ce3cb
Fix salt value
ithinker1991 Mar 25, 2019
5ce3d71
fix: ProposalCreateActuatorTest
CodeNinjaEvan Mar 25, 2019
647c7c7
Merge branch 'feature/bitwise_shifting' into feature/create2
ithinker1991 Mar 25, 2019
bc185cd
Add constantinople hard fork
ithinker1991 Mar 25, 2019
05c64a8
Test add hard fork
ithinker1991 Mar 25, 2019
f474192
Remove `of` method of DataWord
ithinker1991 Mar 25, 2019
41db264
Add fork logic
ithinker1991 Mar 26, 2019
9aa7df8
Add init_code hash
ithinker1991 Mar 27, 2019
0211005
add opcode EXTCODEHASH
llwslc Mar 27, 2019
5a5bd29
add extcodehash fork logic
llwslc Mar 27, 2019
77a67cb
test case DataWord to BigInteger method typo
llwslc Mar 27, 2019
2259037
Fix code style of ABIUtil.java
ithinker1991 Mar 27, 2019
512170b
change return of getCodeHashAt
llwslc Mar 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Polish code
  • Loading branch information
ithinker1991 committed Mar 22, 2019
commit 7895022f18bab3427c01c7dc9da8ed265e624ca4
10 changes: 7 additions & 3 deletions src/main/java/org/tron/common/runtime/vm/DataWord.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class DataWord implements Comparable<DataWord> {

/* Maximum value of the DataWord */
public static final int DATAWORD_UNIT_SIZE = 32;
public static final int UNIT_SIZE = 32;
public static final int MAX_POW = 256;
public static final BigInteger _2_256 = BigInteger.valueOf(2).pow(256);
public static final BigInteger MAX_VALUE = _2_256.subtract(BigInteger.ONE);
Expand Down Expand Up @@ -136,8 +136,8 @@ public byte[] getData() {
public byte[] getClonedData() {
byte[] ret = ByteUtil.EMPTY_BYTE_ARRAY;
if (data != null){
ret = new byte[DATAWORD_UNIT_SIZE];
int dataSize = Math.min(data.length, DATAWORD_UNIT_SIZE);
ret = new byte[UNIT_SIZE];
int dataSize = Math.min(data.length, UNIT_SIZE);
System.arraycopy(data, 0, ret, 0, dataSize);
}
return ret;
Expand Down Expand Up @@ -530,4 +530,8 @@ public DataWord shiftRightSigned(DataWord arg) {
BigInteger result = sValue().shiftRight(arg.intValueSafe());
return new DataWord(ByteUtil.copyToArray(result.and(MAX_VALUE)));
}

public static long sizeInWords(long bytesSize) {
return bytesSize == 0 ? 0 : (bytesSize - 1) / UNIT_SIZE + 1;
}
}
9 changes: 5 additions & 4 deletions src/main/java/org/tron/common/runtime/vm/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,11 @@ public void step(Program program) {
break;
case CREATE2:
DataWord codeSize = stack.get(stack.size() - 3);
energyCost = energyCosts.getCREATE() +
calcMemEnergy(energyCosts, oldMemSize,
memNeeded(stack.get(stack.size() - 2), stack.get(stack.size() - 3)), 0, op) +
VMUtils.getSizeInWords(codeSize.longValueSafe()) * energyCosts.getSHA3_WORD();
energyCost = energyCosts.getCREATE();
energyCost += calcMemEnergy(energyCosts, oldMemSize,
memNeeded(stack.get(stack.size() - 2), stack.get(stack.size() - 3)), 0, op);
energyCost += DataWord.sizeInWords(codeSize.intValueSafe()) * energyCosts.getSHA3_WORD();

break;
case LOG0:
case LOG1:
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/org/tron/common/runtime/vm/VMUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,4 @@ public static String unzipAndDecode(String content) {
return content;
}
}

/**
* Returns number of VM words required to hold data of size {@code size}
*/
public static long getSizeInWords(long size) {
return size == 0 ? 0 : (size - 1) / 32 + 1;
}
}