Skip to content

Commit c273bee

Browse files
author
algoidan
committed
Merge branch 'master' into add-batch-verification-algorithm
2 parents 66e64e8 + 93a372d commit c273bee

File tree

25 files changed

+614
-365
lines changed

25 files changed

+614
-365
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ commands:
196196
shell: bash.exe
197197
command: |
198198
choco install -y msys2 pacman make wget --force
199-
choco install -y golang --version=1.16.11 --force
199+
choco install -y golang --version=1.14.7 --force
200200
choco install -y python3 --version=3.7.3 --force
201201
export msys2='cmd //C RefreshEnv.cmd '
202202
export msys2+='& set MSYS=winsymlinks:nativestrict '

.github/workflows/reviewdog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: Install specific golang
4545
uses: actions/setup-go@v2
4646
with:
47-
go-version: '1.16.11'
47+
go-version: '1.16.6'
4848
- name: Create folders for golangci-lint
4949
run: mkdir -p cicdtmp/golangci-lint
5050
- name: Check if custom golangci-lint is already built

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ else
88
export GOPATH := $(shell go env GOPATH)
99
GOPATH1 := $(firstword $(subst :, ,$(GOPATH)))
1010
endif
11+
export GO111MODULE := on
1112
export GOPROXY := direct
1213
SRCPATH := $(shell pwd)
1314
ARCH := $(shell ./scripts/archtype.sh)

daemon/algod/api/algod.oas2.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@
593593
"operationId": "DeleteParticipationKeyByID",
594594
"responses": {
595595
"200": {
596-
"$ref": "#/responses/DeleteParticipationIdResponse"
596+
"description": "Participation key got deleted by ID"
597597
},
598598
"400": {
599599
"description": "Bad Request",
@@ -2639,7 +2639,6 @@
26392639
}
26402640
}
26412641
},
2642-
26432642
"ParticipationKeysResponse": {
26442643
"description": "A list of participation keys",
26452644
"schema": {
@@ -2655,9 +2654,6 @@
26552654
"$ref": "#/definitions/ParticipationKey"
26562655
}
26572656
},
2658-
"DeleteParticipationIdResponse" : {
2659-
"description": "Participation key got deleted by ID"
2660-
},
26612657
"PostParticipationResponse" : {
26622658
"description": "Participation ID of the submission",
26632659
"schema": {

daemon/algod/api/algod.oas3.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,6 @@
341341
},
342342
"description": "Teal compile Result"
343343
},
344-
"DeleteParticipationIdResponse": {
345-
"content": {},
346-
"description": "Participation key got deleted by ID"
347-
},
348344
"DryrunResponse": {
349345
"content": {
350346
"application/json": {

daemon/algod/api/server/v2/generated/private/routes.go

Lines changed: 138 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

daemon/algod/api/server/v2/generated/routes.go

Lines changed: 172 additions & 173 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data/abi/abi_encode.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ import (
2525
"strings"
2626
)
2727

28+
// bigIntToBytes casts non-negative big integer to byte slice with specific byte length
29+
// DEPRECATED: THIS IS A WORKAROUND FOR `fillBytes` METHOD BEFORE GOLANG 1.15+
30+
// SHOULD BE REMOVED AFTER WE MOVE TO HIGHER VERSION
31+
func bigIntToBytes(x *big.Int, byteLen uint) ([]byte, error) {
32+
if x.Cmp(big.NewInt(0)) < 0 {
33+
return nil, fmt.Errorf("ABI: big Int To Bytes error: should pass in non-negative integer")
34+
}
35+
if uint(x.BitLen()) > byteLen*8 {
36+
return nil, fmt.Errorf("ABI: big Int To Bytes error: integer byte length > given byte length")
37+
}
38+
39+
buffer := make([]byte, byteLen)
40+
intBytes := x.Bytes()
41+
copy(buffer[int(byteLen)-len(intBytes):], intBytes)
42+
return buffer, nil
43+
}
44+
2845
// typeCastToTuple cast an array-like ABI type into an ABI tuple type.
2946
func (t Type) typeCastToTuple(tupLen ...int) (Type, error) {
3047
var childT []Type
@@ -170,13 +187,14 @@ func encodeInt(intValue interface{}, bitSize uint16) ([]byte, error) {
170187
return nil, fmt.Errorf("passed in numeric value should be non negative")
171188
}
172189

173-
castedBytes := make([]byte, bitSize/8)
174-
175190
if bigInt.Cmp(new(big.Int).Lsh(big.NewInt(1), uint(bitSize))) >= 0 {
176191
return nil, fmt.Errorf("input value bit size %d > abi type bit size %d", bigInt.BitLen(), bitSize)
177192
}
178193

179-
bigInt.FillBytes(castedBytes)
194+
castedBytes, err := bigIntToBytes(bigInt, uint(bitSize/8))
195+
if err != nil {
196+
return nil, err
197+
}
180198
return castedBytes, nil
181199
}
182200

data/abi/abi_encode_test.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ func TestEncodeValid(t *testing.T) {
8383
randomInt, err := rand.Int(rand.Reader, upperLimit)
8484
require.NoError(t, err, "cryptographic random int init fail")
8585

86-
expected := make([]byte, intSize/8)
87-
randomInt.FillBytes(expected)
86+
expected, err := bigIntToBytes(randomInt, uint(intSize/8))
87+
require.NoError(t, err, "big int to byte conversion error")
8888

8989
uintEncode, err := uintType.Encode(randomInt)
9090
require.NoError(t, err, "encoding from uint type fail")
@@ -122,8 +122,9 @@ func TestEncodeValid(t *testing.T) {
122122
encodedUfixed, err := typeUfixed.Encode(randomInt)
123123
require.NoError(t, err, "ufixed encode fail")
124124

125-
expected := make([]byte, size/8)
126-
randomInt.FillBytes(expected)
125+
expected, err := bigIntToBytes(randomInt, uint(size/8))
126+
require.NoError(t, err, "big int to byte conversion error")
127+
127128
require.Equal(t, expected, encodedUfixed, "encode ufixed not match with expected")
128129
}
129130
// (2^[bitSize] - 1) / (10^[precision]) test
@@ -141,8 +142,8 @@ func TestEncodeValid(t *testing.T) {
141142
randomAddrInt, err := rand.Int(rand.Reader, upperLimit)
142143
require.NoError(t, err, "cryptographic random int init fail")
143144

144-
addrBytesExpected := make([]byte, addressByteSize)
145-
randomAddrInt.FillBytes(addrBytesExpected)
145+
addrBytesExpected, err := bigIntToBytes(randomAddrInt, uint(addressByteSize))
146+
require.NoError(t, err, "big int to byte conversion error")
146147

147148
addrBytesActual, err := addressType.Encode(addrBytesExpected)
148149
require.NoError(t, err, "address encode fail")
@@ -421,8 +422,8 @@ func TestDecodeValid(t *testing.T) {
421422
randomAddrInt, err := rand.Int(rand.Reader, upperLimit)
422423
require.NoError(t, err, "cryptographic random int init fail")
423424

424-
expected := make([]byte, addressByteSize)
425-
randomAddrInt.FillBytes(expected)
425+
expected, err := bigIntToBytes(randomAddrInt, uint(addressByteSize))
426+
require.NoError(t, err, "big int to byte conversion error")
426427

427428
actual, err := addressType.Decode(expected)
428429
require.NoError(t, err, "decoding address should not return error")
@@ -951,8 +952,10 @@ func addPrimitiveRandomValues(t *testing.T, pool *map[BaseType][]testUnit) {
951952
for i := 0; i < addressTestCaseCount; i++ {
952953
randAddrVal, err := rand.Int(rand.Reader, maxAddress)
953954
require.NoError(t, err, "generate random value for address, should be no error")
954-
addrBytes := make([]byte, addressByteSize)
955-
randAddrVal.FillBytes(addrBytes)
955+
956+
addrBytes, err := bigIntToBytes(randAddrVal, uint(addressByteSize))
957+
require.NoError(t, err, "big int to byte conversion error")
958+
956959
(*pool)[Address][i] = testUnit{serializedType: addressType.String(), value: addrBytes}
957960
}
958961
categorySelfRoundTripTest(t, (*pool)[Address])
@@ -1162,7 +1165,7 @@ func TestParseArgJSONtoByteSlice(t *testing.T) {
11621165

11631166
for i, test := range tests {
11641167
t.Run(fmt.Sprintf("index=%d", i), func(t *testing.T) {
1165-
applicationArgs := [][]byte{}
1168+
applicationArgs := make([][]byte, 0)
11661169
err := ParseArgJSONtoByteSlice(test.argTypes, test.jsonArgs, &applicationArgs)
11671170
require.NoError(t, err)
11681171
require.Equal(t, test.expectedAppArgs, applicationArgs)

data/abi/abi_json_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ func TestRandomAddressEquality(t *testing.T) {
3131

3232
upperLimit := new(big.Int).Lsh(big.NewInt(1), addressByteSize<<3)
3333
var addrBasics basics.Address
34-
var addrABI []byte = make([]byte, addressByteSize)
34+
var addrABI = make([]byte, addressByteSize)
3535

3636
for testCaseIndex := 0; testCaseIndex < addressTestCaseCount; testCaseIndex++ {
3737
randomAddrInt, err := rand.Int(rand.Reader, upperLimit)
3838
require.NoError(t, err, "cryptographic random int init fail")
3939

40-
randomAddrInt.FillBytes(addrBasics[:])
41-
randomAddrInt.FillBytes(addrABI)
40+
expected, err := bigIntToBytes(randomAddrInt, uint(addressByteSize))
41+
require.NoError(t, err, "big int to byte conversion error")
42+
43+
copy(addrABI[:], expected)
44+
copy(addrBasics[:], expected)
4245

4346
checkSumBasics := addrBasics.GetChecksum()
4447
checkSumABI, err := addressCheckSum(addrABI)

0 commit comments

Comments
 (0)