Skip to content

Commit f27a7be

Browse files
committed
Squashed commit of the following:
commit fee360f Author: Tsachi Herman <24438559+tsachiherman@users.noreply.github.com> Date: Fri Oct 4 11:23:58 2024 -0400 refactor marshalActions implementation (#1631) commit 2cb5530 Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Thu Oct 3 18:49:12 2024 -0400 Add block indexing to Indexer API (#1606) commit f1bcc59 Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Thu Oct 3 18:31:39 2024 -0400 Add JSON marshalling to Result (#1627) commit 2ea784a Author: Richard Pringle <richard.pringle@avalabs.org> Date: Thu Oct 3 12:54:10 2024 -0400 Implement multisig example (#1581) commit 6bbf236 Author: Richard Pringle <richard.pringle@avalabs.org> Date: Thu Oct 3 12:43:41 2024 -0400 Update codeowners (#1629) commit 47849d8 Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Thu Oct 3 08:34:51 2024 -0400 Re-mark pubsub tests as flaky (#1625) commit d847132 Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Wed Oct 2 14:23:24 2024 -0400 Reduce tests.unit.sh timeout value less than CI job (#1623) commit 404e74f Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Wed Oct 2 14:07:04 2024 -0400 Add JSON marshalling for fee dimensions (#1622) commit 7e53003 Author: Joshua Kim <20001595+joshua-kim@users.noreply.github.com> Date: Wed Oct 2 12:38:34 2024 -0400 Replace usage of `internal/network` with `p2p` (#1613) Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com> commit 79f363e Author: containerman17 <8990432+containerman17@users.noreply.github.com> Date: Wed Oct 2 11:53:59 2024 +0900 Standardize decimals (#1620) commit e191c88 Author: Joshua Kim <20001595+joshua-kim@users.noreply.github.com> Date: Tue Oct 1 20:02:30 2024 -0400 Update to avalanchego@v1.11.12-rc.2 (#1614) Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com> commit 59c84d7 Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Tue Oct 1 17:19:17 2024 -0400 Add ExecutedBlock type (#1601) commit 165a455 Author: Tsachi Herman <24438559+tsachiherman@users.noreply.github.com> Date: Tue Oct 1 09:26:32 2024 -0400 validate buffer length prior to calling Uint64 (#1588) commit c24f0d8 Author: rodrigo <77309055+RodrigoVillar@users.noreply.github.com> Date: Tue Oct 1 09:25:18 2024 -0400 Fix VM-With-Contracts Unit Tests (#1602) commit 8ab9d83 Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Mon Sep 30 16:57:29 2024 -0400 Minor nits on pubsub implementation (#1593) commit 592cd7a Author: rodrigo <77309055+RodrigoVillar@users.noreply.github.com> Date: Mon Sep 30 12:46:35 2024 -0400 Remove `StateKeysMaxChunks()` (#1607) commit 3e358c1 Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Mon Sep 30 12:46:20 2024 -0400 Update ActionBenchmark to use single ExpectedOutput (#1608) commit e78841e Author: Franfran <51274081+iFrostizz@users.noreply.github.com> Date: Mon Sep 30 16:42:00 2024 +0200 Write FIFO cache unit tests (#1201) * write FIFO cache unit tests * invert expected / actual * add limit parameter and cache fail on 0 size * simplify test table and create new test for empty cache * simpler tests by having a limit of 2 * fix test cases * typos * backout uselesss change * add a "not an LRU" test case * use switch in fifo unit tests commit f1150a1 Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Fri Sep 27 17:46:28 2024 -0400 Update tx indexer to include tx action outputs (#1597) commit 6a3fd63 Author: Joshua Kim <20001595+joshua-kim@users.noreply.github.com> Date: Thu Sep 26 15:44:56 2024 -0400 Remove usage of mockgen (#1591) Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com> commit 49376bd Author: rodrigo <77309055+RodrigoVillar@users.noreply.github.com> Date: Thu Sep 26 14:39:59 2024 -0400 Fix benchmarks (#1590) commit 77a73ba Author: Richard Pringle <richard.pringle@avalabs.org> Date: Tue Sep 24 12:38:27 2024 -0400 Ignore gas on mock-function-call (#1585) commit 1bbab7b Author: containerman17 <8990432+containerman17@users.noreply.github.com> Date: Tue Sep 24 23:19:18 2024 +0900 Remove special cases for Bytes, add arrays support (#1587) commit 3410599 Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Mon Sep 23 12:34:55 2024 -0400 Add spam cmd to morpheus readme (#1577) commit dfefd27 Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Mon Sep 23 12:34:32 2024 -0400 Improve chain comments (#1579) commit 6c15244 Author: Richard Pringle <richard.pringle@avalabs.org> Date: Fri Sep 20 16:10:21 2024 -0400 Series of changes that improve development (#1583) commit e0a3324 Author: Richard Pringle <richard.pringle@avalabs.org> Date: Fri Sep 20 13:12:58 2024 -0400 Use repr(packed) with state-keys (#1580) commit 75c6cfd Author: aaronbuchwald <aaron.buchwald56@gmail.com> Date: Thu Sep 19 07:58:39 2024 -0400 Separate proposer monitor from vm into internal package (#1574) Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
1 parent bbe7785 commit f27a7be

File tree

136 files changed

+2772
-1970
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+2772
-1970
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* @aaronbuchwald @joshua-kim
22
.github/ @richardpringle
3-
/x/contracts/ @iFrostizz @richardpringle @samliok
3+
/x/contracts/ @richardpringle @samliok
4+
Cargo.toml @richardpringle @samliok

.github/workflows/hypersdk-ci.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
jobs:
13-
mock-gen:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- uses: actions/checkout@v4
17-
- name: Set up Go
18-
uses: ./.github/actions/install-go
19-
- shell: bash
20-
run: scripts/mock.gen.sh
21-
- shell: bash
22-
run: scripts/tests.clean.sh
23-
2413
go-mod-tidy:
2514
runs-on: ubuntu-latest
2615
steps:
@@ -90,7 +79,7 @@ jobs:
9079

9180
hypersdk-tests:
9281
runs-on: ubuntu-latest
93-
needs: [mock-gen, go-mod-tidy, hypersdk-lint, hypersdk-unit-tests]
82+
needs: [go-mod-tidy, hypersdk-lint, hypersdk-unit-tests]
9483
outputs:
9584
only_contracts_changed: ${{ steps.check_changes.outputs.only_contracts_changed }}
9685
steps:

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ linters-settings:
8989
deny:
9090
- pkg: "container/list"
9191
desc: github.com/ava-labs/avalanchego/utils/linked should be used instead.
92-
- pkg: "github.com/golang/mock/gomock"
93-
desc: go.uber.org/mock/gomock should be used instead.
9492
- pkg: "github.com/stretchr/testify/assert"
9593
desc: github.com/stretchr/testify/require should be used instead.
9694
- pkg: "io/ioutil"

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010
"x/contracts/test/contracts/*",
1111
"x/contracts/simulator",
1212
"x/contracts/examples/tutorial",
13+
"x/contracts/examples/multisig",
1314
]
1415
resolver = "2"
1516

abi/README.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ This enables frontends to provide a verifiable display of what they are asking u
6262
## Constraints
6363
- Actions require an ID, other structs / types do not require one
6464
- Multiple structs with the same name from different packages are not supported
65-
- Maps are not supported; use slices (arrays) instead
66-
- Built-in types include the special case type aliases: `codec.Address` and `codec.Bytes`
65+
- Maps are not supported; use slices or arrays instead
66+
- Built-in type `codec.Address` included as a special case
6767

6868
## Generating Golang Bindings
6969
Use cmd/abigen to automatically generate Go bindings from an ABI's JSON.
@@ -78,19 +78,21 @@ This should generate the same code that is present in `./abi/mockabi_test.go`.
7878

7979
## Supported Primitive Types
8080

81-
| Type | Range/Description | JSON Serialization | Binary Serialization |
82-
|----------|----------------------------------------------------------|--------------------|---------------------------------------|
83-
| `bool` | true or false | boolean | 1 byte |
84-
| `uint8` | numbers from 0 to 255 | number | 1 byte |
85-
| `uint16` | numbers from 0 to 65535 | number | 2 bytes |
86-
| `uint32` | numbers from 0 to 4294967295 | number | 4 bytes |
87-
| `uint64` | numbers from 0 to 18446744073709551615 | number | 8 bytes |
88-
| `int8` | numbers from -128 to 127 | number | 1 byte |
89-
| `int16` | numbers from -32768 to 32767 | number | 2 bytes |
90-
| `int32` | numbers from -2147483648 to 2147483647 | number | 4 bytes |
91-
| `int64` | numbers from -9223372036854775808 to 9223372036854775807 | number | 8 bytes |
92-
| `Address`| 33 byte array | base64 | 33 bytes |
93-
| `Bytes` | byte array | base64 | uint32 length + bytes |
94-
| `string` | string | string | uint16 length + bytes |
95-
| `[]T` | for any `T` in the above list, serialized as an array | array | uint32 length + elements |
81+
| Type | Range/Description | JSON Serialization | Binary Serialization |
82+
|-----------|----------------------------------------------------------|--------------------|---------------------------------------|
83+
| `bool` | true or false | boolean | 1 byte |
84+
| `uint8` | numbers from 0 to 255 | number | 1 byte |
85+
| `uint16` | numbers from 0 to 65535 | number | 2 bytes |
86+
| `uint32` | numbers from 0 to 4294967295 | number | 4 bytes |
87+
| `uint64` | numbers from 0 to 18446744073709551615 | number | 8 bytes |
88+
| `int8` | numbers from -128 to 127 | number | 1 byte |
89+
| `int16` | numbers from -32768 to 32767 | number | 2 bytes |
90+
| `int32` | numbers from -2147483648 to 2147483647 | number | 4 bytes |
91+
| `int64` | numbers from -9223372036854775808 to 9223372036854775807 | number | 8 bytes |
92+
| `Address` | 33 byte array | base64 | 33 bytes |
93+
| `string` | string | string | uint16 length + bytes |
94+
| `[]T` | for any `T` in the above list, serialized as an array | array | uint32 length + elements |
95+
| `[x]T` | for any `T` in the above list, serialized as an array | array | uint32 length + elements |
96+
| `[]uint8` | byte slice | base64 | uint32 length + bytes |
97+
| `[x]uint8`| byte array | array of numbers | x bytes |
9698

abi/abi.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,18 @@ func describeStruct(t reflect.Type) ([]Field, []reflect.Type, error) {
168168
} else {
169169
arrayPrefix := ""
170170

171-
// Here we assume that all types without a name are slices.
171+
// Here we assume that all types without a name are slices or arrays.
172172
// We completely ignore the fact that maps exist as we don't support them.
173-
// Types like `type Bytes = []byte` are slices technically, but they have a name
173+
// Types like `type Address = [33]byte` are arrays technically, but they have a name
174174
// and we need them to be named types instead of slices.
175175
for fieldType.Name() == "" {
176-
arrayPrefix += "[]"
177-
fieldType = fieldType.Elem()
176+
if fieldType.Kind() == reflect.Array {
177+
arrayPrefix += fmt.Sprintf("[%d]", fieldType.Len())
178+
fieldType = fieldType.Elem()
179+
} else {
180+
arrayPrefix += "[]"
181+
fieldType = fieldType.Elem()
182+
}
178183
}
179184

180185
typeName := arrayPrefix + fieldType.Name()

abi/abi_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestNewABI(t *testing.T) {
2525
MockActionWithTransferArray{},
2626
Outer{},
2727
ActionWithOutput{},
28+
FixedBytes{},
2829
}, []codec.Typed{
2930
ActionOutput{},
3031
})

abi/auto_marshal_abi_spec_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"strings"
1313
"testing"
1414

15+
"github.com/ava-labs/avalanchego/utils/wrappers"
1516
"github.com/stretchr/testify/require"
1617

1718
"github.com/ava-labs/hypersdk/chain"
@@ -58,6 +59,7 @@ func TestMarshalSpecs(t *testing.T) {
5859
{"strBytesEmpty", &MockObjectStringAndBytes{}},
5960
{"strOnly", &MockObjectStringAndBytes{}},
6061
{"outer", &Outer{}},
62+
{"fixedBytes", &FixedBytes{}},
6163
}
6264

6365
for _, tc := range testCases {
@@ -83,7 +85,7 @@ func TestMarshalSpecs(t *testing.T) {
8385
require.Equal(expectedHex, hex.EncodeToString(objectBytes))
8486

8587
// Unmarshal the object
86-
err = codec.LinearCodec.Unmarshal(objectBytes, unmarshaledFromBytes)
88+
err = codec.LinearCodec.UnmarshalFrom(&wrappers.Packer{Bytes: objectBytes}, unmarshaledFromBytes)
8789
require.NoError(err)
8890

8991
// Compare unmarshaled object with the original

abi/codegen.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func GenerateGoStructs(abi ABI, packageName string) (string, error) {
1616
var sb strings.Builder
1717

1818
sb.WriteString(fmt.Sprintf("package %s\n\n", packageName))
19-
sb.WriteString("import (\n\t\"github.com/ava-labs/hypersdk/codec\"\n)\n\n")
19+
sb.WriteString("import \"github.com/ava-labs/hypersdk/codec\"\n\n")
2020

2121
processed := set.Set[string]{}
2222

@@ -70,8 +70,6 @@ func convertToGoType(abiType string) string {
7070
return abiType
7171
case "Address":
7272
return "codec.Address"
73-
case "Bytes":
74-
return "codec.Bytes"
7573
default:
7674
if strings.HasPrefix(abiType, "[]") {
7775
return "[]" + convertToGoType(strings.TrimPrefix(abiType, "[]"))

abi/mockabi_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
package abi
55

6-
import (
7-
"github.com/ava-labs/hypersdk/codec"
8-
)
6+
import "github.com/ava-labs/hypersdk/codec"
97

108
type MockObjectSingleNumber struct {
119
Field1 uint16 `serialize:"true"`
@@ -14,7 +12,7 @@ type MockObjectSingleNumber struct {
1412
type MockActionTransfer struct {
1513
To codec.Address `serialize:"true" json:"to"`
1614
Value uint64 `serialize:"true" json:"value"`
17-
Memo codec.Bytes `serialize:"true" json:"memo"`
15+
Memo []uint8 `serialize:"true" json:"memo"`
1816
}
1917

2018
type MockObjectAllNumbers struct {
@@ -67,6 +65,11 @@ type ActionWithOutput struct {
6765
Field1 uint8 `serialize:"true" json:"field1"`
6866
}
6967

68+
type FixedBytes struct {
69+
TwoBytes [2]uint8 `serialize:"true" json:"twoBytes"`
70+
ThirtyTwoBytes [32]uint8 `serialize:"true" json:"thirtyTwoBytes"`
71+
}
72+
7073
type ActionOutput struct {
7174
Field1 uint16 `serialize:"true" json:"field1"`
7275
}
@@ -107,6 +110,10 @@ func (ActionWithOutput) GetTypeID() uint8 {
107110
return 8
108111
}
109112

113+
func (FixedBytes) GetTypeID() uint8 {
114+
return 9
115+
}
116+
110117
func (ActionOutput) GetTypeID() uint8 {
111118
return 0
112119
}

0 commit comments

Comments
 (0)