Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
joshua-kim committed Oct 10, 2024
1 parent bbe7785 commit f27a7be
Show file tree
Hide file tree
Showing 136 changed files with 2,772 additions and 1,970 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* @aaronbuchwald @joshua-kim
.github/ @richardpringle
/x/contracts/ @iFrostizz @richardpringle @samliok
/x/contracts/ @richardpringle @samliok
Cargo.toml @richardpringle @samliok
13 changes: 1 addition & 12 deletions .github/workflows/hypersdk-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ concurrency:
cancel-in-progress: true

jobs:
mock-gen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: ./.github/actions/install-go
- shell: bash
run: scripts/mock.gen.sh
- shell: bash
run: scripts/tests.clean.sh

go-mod-tidy:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -90,7 +79,7 @@ jobs:

hypersdk-tests:
runs-on: ubuntu-latest
needs: [mock-gen, go-mod-tidy, hypersdk-lint, hypersdk-unit-tests]
needs: [go-mod-tidy, hypersdk-lint, hypersdk-unit-tests]
outputs:
only_contracts_changed: ${{ steps.check_changes.outputs.only_contracts_changed }}
steps:
Expand Down
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ linters-settings:
deny:
- pkg: "container/list"
desc: github.com/ava-labs/avalanchego/utils/linked should be used instead.
- pkg: "github.com/golang/mock/gomock"
desc: go.uber.org/mock/gomock should be used instead.
- pkg: "github.com/stretchr/testify/assert"
desc: github.com/stretchr/testify/require should be used instead.
- pkg: "io/ioutil"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"x/contracts/test/contracts/*",
"x/contracts/simulator",
"x/contracts/examples/tutorial",
"x/contracts/examples/multisig",
]
resolver = "2"

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

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

## Supported Primitive Types

| Type | Range/Description | JSON Serialization | Binary Serialization |
|----------|----------------------------------------------------------|--------------------|---------------------------------------|
| `bool` | true or false | boolean | 1 byte |
| `uint8` | numbers from 0 to 255 | number | 1 byte |
| `uint16` | numbers from 0 to 65535 | number | 2 bytes |
| `uint32` | numbers from 0 to 4294967295 | number | 4 bytes |
| `uint64` | numbers from 0 to 18446744073709551615 | number | 8 bytes |
| `int8` | numbers from -128 to 127 | number | 1 byte |
| `int16` | numbers from -32768 to 32767 | number | 2 bytes |
| `int32` | numbers from -2147483648 to 2147483647 | number | 4 bytes |
| `int64` | numbers from -9223372036854775808 to 9223372036854775807 | number | 8 bytes |
| `Address`| 33 byte array | base64 | 33 bytes |
| `Bytes` | byte array | base64 | uint32 length + bytes |
| `string` | string | string | uint16 length + bytes |
| `[]T` | for any `T` in the above list, serialized as an array | array | uint32 length + elements |
| Type | Range/Description | JSON Serialization | Binary Serialization |
|-----------|----------------------------------------------------------|--------------------|---------------------------------------|
| `bool` | true or false | boolean | 1 byte |
| `uint8` | numbers from 0 to 255 | number | 1 byte |
| `uint16` | numbers from 0 to 65535 | number | 2 bytes |
| `uint32` | numbers from 0 to 4294967295 | number | 4 bytes |
| `uint64` | numbers from 0 to 18446744073709551615 | number | 8 bytes |
| `int8` | numbers from -128 to 127 | number | 1 byte |
| `int16` | numbers from -32768 to 32767 | number | 2 bytes |
| `int32` | numbers from -2147483648 to 2147483647 | number | 4 bytes |
| `int64` | numbers from -9223372036854775808 to 9223372036854775807 | number | 8 bytes |
| `Address` | 33 byte array | base64 | 33 bytes |
| `string` | string | string | uint16 length + bytes |
| `[]T` | for any `T` in the above list, serialized as an array | array | uint32 length + elements |
| `[x]T` | for any `T` in the above list, serialized as an array | array | uint32 length + elements |
| `[]uint8` | byte slice | base64 | uint32 length + bytes |
| `[x]uint8`| byte array | array of numbers | x bytes |

13 changes: 9 additions & 4 deletions abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,18 @@ func describeStruct(t reflect.Type) ([]Field, []reflect.Type, error) {
} else {
arrayPrefix := ""

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

typeName := arrayPrefix + fieldType.Name()
Expand Down
1 change: 1 addition & 0 deletions abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestNewABI(t *testing.T) {
MockActionWithTransferArray{},
Outer{},
ActionWithOutput{},
FixedBytes{},
}, []codec.Typed{
ActionOutput{},
})
Expand Down
4 changes: 3 additions & 1 deletion abi/auto_marshal_abi_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"
"testing"

"github.com/ava-labs/avalanchego/utils/wrappers"
"github.com/stretchr/testify/require"

"github.com/ava-labs/hypersdk/chain"
Expand Down Expand Up @@ -58,6 +59,7 @@ func TestMarshalSpecs(t *testing.T) {
{"strBytesEmpty", &MockObjectStringAndBytes{}},
{"strOnly", &MockObjectStringAndBytes{}},
{"outer", &Outer{}},
{"fixedBytes", &FixedBytes{}},
}

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

// Unmarshal the object
err = codec.LinearCodec.Unmarshal(objectBytes, unmarshaledFromBytes)
err = codec.LinearCodec.UnmarshalFrom(&wrappers.Packer{Bytes: objectBytes}, unmarshaledFromBytes)
require.NoError(err)

// Compare unmarshaled object with the original
Expand Down
4 changes: 1 addition & 3 deletions abi/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func GenerateGoStructs(abi ABI, packageName string) (string, error) {
var sb strings.Builder

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

processed := set.Set[string]{}

Expand Down Expand Up @@ -70,8 +70,6 @@ func convertToGoType(abiType string) string {
return abiType
case "Address":
return "codec.Address"
case "Bytes":
return "codec.Bytes"
default:
if strings.HasPrefix(abiType, "[]") {
return "[]" + convertToGoType(strings.TrimPrefix(abiType, "[]"))
Expand Down
15 changes: 11 additions & 4 deletions abi/mockabi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package abi

import (
"github.com/ava-labs/hypersdk/codec"
)
import "github.com/ava-labs/hypersdk/codec"

type MockObjectSingleNumber struct {
Field1 uint16 `serialize:"true"`
Expand All @@ -14,7 +12,7 @@ type MockObjectSingleNumber struct {
type MockActionTransfer struct {
To codec.Address `serialize:"true" json:"to"`
Value uint64 `serialize:"true" json:"value"`
Memo codec.Bytes `serialize:"true" json:"memo"`
Memo []uint8 `serialize:"true" json:"memo"`
}

type MockObjectAllNumbers struct {
Expand Down Expand Up @@ -67,6 +65,11 @@ type ActionWithOutput struct {
Field1 uint8 `serialize:"true" json:"field1"`
}

type FixedBytes struct {
TwoBytes [2]uint8 `serialize:"true" json:"twoBytes"`
ThirtyTwoBytes [32]uint8 `serialize:"true" json:"thirtyTwoBytes"`
}

type ActionOutput struct {
Field1 uint16 `serialize:"true" json:"field1"`
}
Expand Down Expand Up @@ -107,6 +110,10 @@ func (ActionWithOutput) GetTypeID() uint8 {
return 8
}

func (FixedBytes) GetTypeID() uint8 {
return 9
}

func (ActionOutput) GetTypeID() uint8 {
return 0
}
2 changes: 1 addition & 1 deletion abi/testdata/abi.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
]
}
]
}
}
2 changes: 1 addition & 1 deletion abi/testdata/abi.hash.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bffd5b2422e5c0fcdfff1b2c073efcac65ab0b5225461ca9a665638d41378e8e
075005590e3e3e39dffbf8e5a6d77559b8a33e621078782571695f60938126d3
21 changes: 19 additions & 2 deletions abi/testdata/abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
{
"id": 8,
"name": "ActionWithOutput"
},
{
"id": 9,
"name": "FixedBytes"
}
],
"outputs": [
Expand Down Expand Up @@ -66,7 +70,7 @@
},
{
"name": "memo",
"type": "Bytes"
"type": "[]uint8"
}
]
},
Expand Down Expand Up @@ -214,6 +218,19 @@
],
"name": "ActionWithOutput"
},
{
"fields": [
{
"name": "twoBytes",
"type": "[2]uint8"
},
{
"name": "thirtyTwoBytes",
"type": "[32]uint8"
}
],
"name": "FixedBytes"
},
{
"fields": [
{
Expand All @@ -224,4 +241,4 @@
"name": "ActionOutput"
}
]
}
}
1 change: 1 addition & 0 deletions abi/testdata/fixedBytes.hex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
01020100000000000000000002000000000000000000030000000000000000000400
40 changes: 40 additions & 0 deletions abi/testdata/fixedBytes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"twoBytes": [
1,
2
],
"thirtyTwoBytes": [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
3,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0
]
}
79 changes: 0 additions & 79 deletions api/indexer/api.go

This file was deleted.

Loading

0 comments on commit f27a7be

Please sign in to comment.