Skip to content

Commit 83fd3eb

Browse files
algochoimichaeldiamantalgojackwinderbarnjamin
authored
Merge develop branch to boxes feature branch (#354)
* Ignore copied over txt test resource files (#342) * Github-Actions: Adding pr title and label checks (#339) * Enhancement: Add UNKNOWN enum type to HTTP client enums. (#351) * AVM: Consolidate TEAL and AVM versions (#348) * Testing: Modify cucumber steps to use dev mode network (#350) * DevTools: adding source map decoder (#352) * adding source map decoder * Add back line in makefile * Remove redundant mvn test Co-authored-by: Michael Diamant <michaeldiamant@users.noreply.github.com> Co-authored-by: Jack <87339414+algojack@users.noreply.github.com> Co-authored-by: Will Winder <wwinder.unh@gmail.com> Co-authored-by: Ben Guidarelli <ben.guidarelli@gmail.com>
1 parent 5a9d077 commit 83fd3eb

12 files changed

Lines changed: 520 additions & 35 deletions

File tree

.github/release.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- Skip-Release-Notes
5+
categories:
6+
- title: Bugfixes
7+
labels:
8+
- Bug-Fix
9+
- title: New Features
10+
labels:
11+
- New Feature
12+
- title: Enhancements
13+
labels:
14+
- Enhancement
15+
- title: Not Yet Enabled
16+
labels:
17+
- Not-Yet-Enabled
18+
- title: Other
19+
labels:
20+
- "*"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Check PR category and type
2+
on:
3+
pull_request:
4+
branches:
5+
- develop
6+
types: [opened, synchronize, reopened, labeled, unlabeled, edited]
7+
jobs:
8+
check_label:
9+
runs-on: ubuntu-latest
10+
name: Check PR Category and Type
11+
steps:
12+
- name: Checking for correct number of required github pr labels
13+
uses: mheap/github-action-required-labels@v2
14+
with:
15+
mode: exactly
16+
count: 1
17+
labels: "New Feature, Enhancement, Bug-Fix, Not-Yet-Enabled, Skip-Release-Notes"
18+
19+
- name: "Checking for PR Category in PR title. Should be like '<category>: <pr title>'."
20+
run: |
21+
if [[ ! "${{ github.event.pull_request.title }}" =~ ^.{2,}\:.{2,} ]]; then
22+
echo "## PR Category is missing from PR title. Please add it like '<category>: <pr title>'." >> GITHUB_STEP_SUMMARY
23+
exit 1
24+
fi

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
unit:
2-
mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.transactions.keyreg or @unit.responses or @unit.applications or @unit.applications.boxes or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.algod.ledger_refactoring or @unit.indexer.ledger_refactoring or @unit.dryrun.trace.application"
2+
mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.transactions.keyreg or @unit.responses or @unit.applications or @unit.applications.boxes or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.algod.ledger_refactoring or @unit.indexer.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap"
33

44
integration:
5-
mvn test -Dcucumber.filter.tags="@algod or @assets or @auction or @kmd or @send or @send.keyregtxn or @indexer or @rekey or @applications.verified or @applications or @applications.boxes or @compile or @dryrun or @indexer.applications or @indexer.231 or @abi or @c2c"
5+
mvn test \
6+
-Dtest=com.algorand.algosdk.integration.RunCucumberIntegrationTest \
7+
-Dcucumber.filter.tags="@algod or @assets or @auction or @kmd or @send or @send.keyregtxn or @indexer or @rekey_v1 or @applications.verified or @applications or @applications.boxes or @compile or @dryrun or @indexer.applications or @indexer.231 or @abi or @c2c or @compile.sourcemap"
68

79
docker-test:
810
./run_integration_tests.sh

src/main/java/com/algorand/algosdk/logic/Logic.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,14 @@ public static ProgramData readProgram(byte[] program, List<byte[]> args) throws
250250
}
251251
// costs calculated dynamically starting in v4
252252
if (version < 4 && cost > MAX_COST) {
253-
throw new IllegalArgumentException("program too costly for Teal version < 4. consider using v4.");
253+
throw new IllegalArgumentException("program too costly for version < 4. consider using v4.");
254254
}
255255

256256
return new ProgramData(true, ints, bytes);
257257
}
258258

259259
/**
260-
* Retrieves TEAL supported version
260+
* Retrieves supported program version
261261
* @return int
262262
* @throws IOException
263263
*/
@@ -269,7 +269,7 @@ public static int getLogicSigVersion() throws IOException {
269269
}
270270

271271
/**
272-
* Retrieves max supported version of TEAL evaluator
272+
* Retrieves max supported program version of evaluator
273273
* @return int
274274
* @throws IOException
275275
*/
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package com.algorand.algosdk.logic;
2+
3+
import java.lang.Integer;
4+
import java.util.ArrayList;
5+
import java.util.HashMap;
6+
7+
/**
8+
* SourceMap class provides parser for source map from
9+
* algod compile endpoint
10+
*/
11+
public class SourceMap {
12+
13+
public int version;
14+
public String file;
15+
public String[] sources;
16+
public String[] names;
17+
public String mappings;
18+
19+
public HashMap<Integer, Integer> pcToLine;
20+
public HashMap<Integer, ArrayList<Integer>> lineToPc;
21+
22+
public SourceMap(HashMap<String,Object> sourceMap) {
23+
int version = (int) sourceMap.get("version");
24+
if(version != 3){
25+
throw new IllegalArgumentException("Only source map version 3 is supported");
26+
}
27+
this.version = version;
28+
29+
this.file = (String) sourceMap.get("file");
30+
this.mappings = (String) sourceMap.get("mappings");
31+
32+
this.lineToPc = new HashMap<>();
33+
this.pcToLine = new HashMap<>();
34+
35+
Integer lastLine = 0;
36+
String[] vlqs = this.mappings.split(";");
37+
for(int i=0; i<vlqs.length; i++){
38+
ArrayList<Integer> vals = VLQDecoder.decodeSourceMapLine(vlqs[i]);
39+
40+
// If the vals length >= 3 the lineDelta
41+
if(vals.size() >= 3){
42+
lastLine = lastLine + vals.get(2);
43+
}
44+
45+
if(!this.lineToPc.containsKey(lastLine)){
46+
this.lineToPc.put(lastLine, new ArrayList<Integer>());
47+
}
48+
49+
ArrayList<Integer> currList = this.lineToPc.get(lastLine);
50+
currList.add(i);
51+
this.lineToPc.put(lastLine, currList);
52+
53+
this.pcToLine.put(i, lastLine);
54+
}
55+
56+
}
57+
58+
/**
59+
* Returns the Integer line number for the passed PC or null if not found
60+
* @param pc the pc (program counter) of the assembled file
61+
* @return the line number or null if not found
62+
*/
63+
public Integer getLineForPc(Integer pc) {
64+
return this.pcToLine.get(pc);
65+
}
66+
67+
/**
68+
* Returns the List of PCs for the passed line number
69+
* @param line the line number of the source file
70+
* @return the list of PCs that line generated or empty array if not found
71+
*/
72+
public ArrayList<Integer> getPcsForLine(Integer line) {
73+
if(!this.pcToLine.containsKey(line)){
74+
return new ArrayList<Integer>();
75+
}
76+
return this.lineToPc.get(line);
77+
}
78+
79+
private static class VLQDecoder {
80+
// VLQDecoder for decoding the VLQ values returned for source map
81+
// based on the decoder implementation here: https://github.com/algorand/go-algorand-sdk/blob/develop/logic/source_map.go
82+
83+
private static final String b64table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
84+
private static final int vlqShiftSize = 5;
85+
private static final int vlqFlag = 1 << vlqShiftSize;
86+
private static final int vlqMask = vlqFlag - 1;
87+
88+
public static ArrayList<Integer> decodeSourceMapLine(String vlq) {
89+
90+
ArrayList<Integer> results = new ArrayList<>();
91+
int value = 0;
92+
int shift = 0;
93+
94+
for(int i=0; i<vlq.length(); i++){
95+
int digit = b64table.indexOf(vlq.charAt(i));
96+
97+
value |= (digit & vlqMask) << shift;
98+
99+
if((digit & vlqFlag) > 0) {
100+
shift += vlqShiftSize;
101+
continue;
102+
}
103+
104+
if((value&1)>0){
105+
value = (value >> 1) * -1;
106+
}else{
107+
value = value >> 1;
108+
}
109+
110+
results.add(value);
111+
112+
// Reset
113+
value = 0;
114+
shift = 0;
115+
}
116+
117+
return results;
118+
}
119+
}
120+
121+
}

src/main/java/com/algorand/algosdk/v2/client/model/Enums.java

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.algorand.algosdk.v2.client.model;
22

3+
import com.fasterxml.jackson.annotation.JsonCreator;
34
import com.fasterxml.jackson.annotation.JsonProperty;
45

56
public class Enums {
@@ -10,7 +11,8 @@ public class Enums {
1011
public enum AddressRole {
1112
@JsonProperty("sender") SENDER("sender"),
1213
@JsonProperty("receiver") RECEIVER("receiver"),
13-
@JsonProperty("freeze-target") FREEZETARGET("freeze-target");
14+
@JsonProperty("freeze-target") FREEZETARGET("freeze-target"),
15+
@JsonProperty("") UNKNOWN("");
1416

1517
final String serializedName;
1618
AddressRole(String name) {
@@ -21,6 +23,17 @@ public enum AddressRole {
2123
public String toString() {
2224
return this.serializedName;
2325
}
26+
27+
@JsonCreator
28+
public static AddressRole forValue(String value) {
29+
for (AddressRole t : values()) {
30+
if (t.serializedName.equalsIgnoreCase(value)) {
31+
return t;
32+
}
33+
}
34+
return UNKNOWN;
35+
}
36+
2437
}
2538

2639
/**
@@ -34,7 +47,8 @@ public enum Exclude {
3447
@JsonProperty("created-assets") CREATEDASSETS("created-assets"),
3548
@JsonProperty("apps-local-state") APPSLOCALSTATE("apps-local-state"),
3649
@JsonProperty("created-apps") CREATEDAPPS("created-apps"),
37-
@JsonProperty("none") NONE("none");
50+
@JsonProperty("none") NONE("none"),
51+
@JsonProperty("") UNKNOWN("");
3852

3953
final String serializedName;
4054
Exclude(String name) {
@@ -45,6 +59,17 @@ public enum Exclude {
4559
public String toString() {
4660
return this.serializedName;
4761
}
62+
63+
@JsonCreator
64+
public static Exclude forValue(String value) {
65+
for (Exclude t : values()) {
66+
if (t.serializedName.equalsIgnoreCase(value)) {
67+
return t;
68+
}
69+
}
70+
return UNKNOWN;
71+
}
72+
4873
}
4974

5075
/**
@@ -54,7 +79,8 @@ public String toString() {
5479
*/
5580
public enum Hashtype {
5681
@JsonProperty("sha512_256") SHA512_256("sha512_256"),
57-
@JsonProperty("sha256") SHA256("sha256");
82+
@JsonProperty("sha256") SHA256("sha256"),
83+
@JsonProperty("") UNKNOWN("");
5884

5985
final String serializedName;
6086
Hashtype(String name) {
@@ -65,6 +91,17 @@ public enum Hashtype {
6591
public String toString() {
6692
return this.serializedName;
6793
}
94+
95+
@JsonCreator
96+
public static Hashtype forValue(String value) {
97+
for (Hashtype t : values()) {
98+
if (t.serializedName.equalsIgnoreCase(value)) {
99+
return t;
100+
}
101+
}
102+
return UNKNOWN;
103+
}
104+
68105
}
69106

70107
/**
@@ -84,7 +121,8 @@ public enum OnCompletion {
84121
@JsonProperty("closeout") CLOSEOUT("closeout"),
85122
@JsonProperty("clear") CLEAR("clear"),
86123
@JsonProperty("update") UPDATE("update"),
87-
@JsonProperty("delete") DELETE("delete");
124+
@JsonProperty("delete") DELETE("delete"),
125+
@JsonProperty("") UNKNOWN("");
88126

89127
final String serializedName;
90128
OnCompletion(String name) {
@@ -95,6 +133,17 @@ public enum OnCompletion {
95133
public String toString() {
96134
return this.serializedName;
97135
}
136+
137+
@JsonCreator
138+
public static OnCompletion forValue(String value) {
139+
for (OnCompletion t : values()) {
140+
if (t.serializedName.equalsIgnoreCase(value)) {
141+
return t;
142+
}
143+
}
144+
return UNKNOWN;
145+
}
146+
98147
}
99148

100149
/**
@@ -107,7 +156,8 @@ public String toString() {
107156
public enum SigType {
108157
@JsonProperty("sig") SIG("sig"),
109158
@JsonProperty("msig") MSIG("msig"),
110-
@JsonProperty("lsig") LSIG("lsig");
159+
@JsonProperty("lsig") LSIG("lsig"),
160+
@JsonProperty("") UNKNOWN("");
111161

112162
final String serializedName;
113163
SigType(String name) {
@@ -118,6 +168,17 @@ public enum SigType {
118168
public String toString() {
119169
return this.serializedName;
120170
}
171+
172+
@JsonCreator
173+
public static SigType forValue(String value) {
174+
for (SigType t : values()) {
175+
if (t.serializedName.equalsIgnoreCase(value)) {
176+
return t;
177+
}
178+
}
179+
return UNKNOWN;
180+
}
181+
121182
}
122183

123184
/**
@@ -137,7 +198,8 @@ public enum TxType {
137198
@JsonProperty("acfg") ACFG("acfg"),
138199
@JsonProperty("axfer") AXFER("axfer"),
139200
@JsonProperty("afrz") AFRZ("afrz"),
140-
@JsonProperty("appl") APPL("appl");
201+
@JsonProperty("appl") APPL("appl"),
202+
@JsonProperty("") UNKNOWN("");
141203

142204
final String serializedName;
143205
TxType(String name) {
@@ -148,6 +210,17 @@ public enum TxType {
148210
public String toString() {
149211
return this.serializedName;
150212
}
213+
214+
@JsonCreator
215+
public static TxType forValue(String value) {
216+
for (TxType t : values()) {
217+
if (t.serializedName.equalsIgnoreCase(value)) {
218+
return t;
219+
}
220+
}
221+
return UNKNOWN;
222+
}
223+
151224
}
152225

153226
}

src/test/java/com/algorand/algosdk/integration/Applications.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void sendTransactionWithTransientAccountAndCheckForError(String error) th
143143

144144
@Given("I wait for the transaction to be confirmed.")
145145
public void waitForTransactionToBeConfirmed() throws Exception {
146-
Utils.waitForConfirmation(clients.v2Client, txId, 5);
146+
Utils.waitForConfirmation(clients.v2Client, txId, 1);
147147
}
148148

149149
// TODO: Use V2 Pending Transaction endpoint when it is available.
@@ -173,7 +173,7 @@ public void fundAppAccount(Integer amount) throws Exception {
173173
SignedTransaction stx = base.signWithAddress(tx, sender);
174174

175175
Response<PostTransactionsResponse> rPost = clients.v2Client.RawTransaction().rawtxn(Encoder.encodeToMsgPack(stx)).execute();
176-
Utils.waitForConfirmation(clients.v2Client, rPost.body().txId, 5);
176+
Utils.waitForConfirmation(clients.v2Client, rPost.body().txId, 1);
177177
}
178178

179179
@Then("I get the account address for the current application and see that it matches the app id's hash")

0 commit comments

Comments
 (0)