Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
upgrade gh action workers
Browse files Browse the repository at this point in the history
ot
  • Loading branch information
itsdevbear committed Sep 4, 2023
1 parent c4d4f86 commit 54bddb3
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 49 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ on:
branches:
- main

jobs:
jobs:
build-base:
strategy:
matrix:
namespace: [cosmos]
docker-version: [base]
os: [ubuntu-latest]
os: [polaris-linux-latest]
go-version: [1.21.0]
go-arch: [amd64]
image-name: ['polard/base:v0.0.0']
image-name: ["polard/base:v0.0.0"]
export-name: [base-image]
runs-on: ubuntu-latest
runs-on: polaris-linux-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
go-version: ${{ matrix.go-version }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Run ${{ matrix.namespace }}:docker ${{ matrix.docker-version }} ${{ matrix.go-arch }}
Expand All @@ -68,11 +68,11 @@ jobs:
matrix:
namespace: [cosmos]
docker-version: [localnet]
os: [ubuntu-latest]
os: [polaris-linux-latest]
go-version: [1.21.0]
go-arch: [amd64]
base-image: [base-image]
image-name: ['polard/localnet:v0.0.0']
image-name: ["polard/localnet:v0.0.0"]
export-name: [localnet]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -81,7 +81,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
go-version: ${{ matrix.go-version }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download image artifact
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
matrix:
simulator: [polaris/rpc, polaris/graphql]
namespace: [cosmos]
os: [ubuntu-latest]
os: [polaris-linux-latest]
go-version: [1.21.0]
base-image: [base-image]
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -151,8 +151,8 @@ jobs:
needs: build-localnet
strategy:
matrix:
namespace: ['', 'localnet']
os: [ubuntu-latest]
namespace: ["", "localnet"]
os: [polaris-linux-latest]
go-version: [1.21.0]
base-image: [localnet]
runs-on: ${{ matrix.os }}
Expand Down
14 changes: 4 additions & 10 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,8 @@ jobs:
ci:
strategy:
matrix:
args:
[
"build",
"lint",
"testunitrace",
"testunitcover",
]
os: [ubuntu-latest]
args: ["build", "lint", "testunitrace", "testunitcover"]
os: [polaris-linux-latest]
go-version: [1.21.0]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -77,8 +71,8 @@ jobs:
if: ${{ matrix.args == 'testunitcover' }}

codecov:
name: codecov(uploader, ubuntu-latest)
runs-on: ubuntu-latest
name: codecov(uploader, polaris-linux-latest)
runs-on: polaris-linux-latest
needs: ci
steps:
- name: Checkout
Expand Down
8 changes: 4 additions & 4 deletions eth/core/precompile/factories.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ func (sf *StatefulFactory) Build(
// This function matches each Go implementation of the precompile to the ABI's respective function.
// It searches for the ABI function in the Go precompile contract and performs basic validation on
// the implemented function.
func buildIdsToMethods(si StatefulImpl, contractImpl reflect.Value) (map[[4]byte]*method, error) {
func buildIdsToMethods(si StatefulImpl, contractImpl reflect.Value) (map[string]*method, error) {
precompileABI := si.ABIMethods()
contractImplType := contractImpl.Type()
idsToMethods := make(map[[4]byte]*method)
idsToMethods := make(map[string]*method)
for m := 0; m < contractImplType.NumMethod(); m++ {
implMethod := contractImplType.Method(m)

Expand All @@ -127,12 +127,12 @@ func buildIdsToMethods(si StatefulImpl, contractImpl reflect.Value) (map[[4]byte
}

method := newMethod(si, precompileABI[methodName], implMethod)
idsToMethods[[4]byte(precompileABI[methodName].ID)] = method
idsToMethods[utils.UnsafeBytesToStr(precompileABI[methodName].ID)] = method

Check failure on line 130 in eth/core/precompile/factories.go

View workflow job for this annotation

GitHub Actions / ci (build, polaris-linux-latest, 1.21.0)

undefined: utils.UnsafeBytesToStr
}

// verify that every abi method has a corresponding precompile implementation
for _, abiMethod := range precompileABI {
if _, found := idsToMethods[[4]byte(abiMethod.ID)]; !found {
if _, found := idsToMethods[utils.UnsafeBytesToStr(abiMethod.ID)]; !found {

Check failure on line 135 in eth/core/precompile/factories.go

View workflow job for this annotation

GitHub Actions / ci (build, polaris-linux-latest, 1.21.0)

undefined: utils.UnsafeBytesToStr
return nil, errorslib.Wrap(ErrNoPrecompileMethodForABIMethod, abiMethod.Name)
}
}
Expand Down
11 changes: 0 additions & 11 deletions eth/core/precompile/method_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,6 @@ var _ = Describe("Method", func() {
})
})

var _ = Describe("Test MethoID", func() {
It("should work", func() {
x := make([]byte, 0)
x = append(x, 0x12)
x = append(x, 0x34)
x = append(x, 0x56)
x = append(x, 0x78)
Expect([4]byte(x)).To(Equal([4]byte{0x12, 0x34, 0x56, 0x78}))
})
})

// MOCKS BELOW.

type mockStatefulWithMethod struct {
Expand Down
3 changes: 2 additions & 1 deletion eth/core/precompile/method_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func validateArg(implMethodVar reflect.Value, abiMethodVar reflect.Value) error
implMethodVarType := implMethodVar.Type()
abiMethodVarType := abiMethodVar.Type()

switch implMethodVarType.Kind() { //nolint:exchaustive // todo verify its okay.
//nolint:exhaustive // only the ones we need.
switch implMethodVarType.Kind() {
case reflect.Array, reflect.Slice:
if implMethodVarType.Elem() != abiMethodVarType.Elem() {
// If the array is not a slice/array of structs, return an error.
Expand Down
9 changes: 4 additions & 5 deletions eth/core/precompile/stateful_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"pkg.berachain.dev/polaris/eth/common"
"pkg.berachain.dev/polaris/eth/core/vm"
"pkg.berachain.dev/polaris/lib/utils"
)

// NumBytesMethodID is the number of bytes used to represent a ABI method's ID.
Expand All @@ -41,7 +42,7 @@ type statefulContainer struct {
// method signatures) to native precompile functions. The signature key is provided by the
// precompile creator and must exactly match the signature in the geth abi.Method.Sig field
// (geth abi format). Please check core/precompile/container/method.go for more information.
idsToMethods map[[4]byte]*method
idsToMethods map[string]*method
// receive *Method // TODO: implement
// fallback *Method // TODO: implement

Expand All @@ -50,7 +51,7 @@ type statefulContainer struct {
// NewStatefulContainer creates and returns a new `statefulContainer` with the given method ids
// precompile functions map.
func NewStatefulContainer(
si StatefulImpl, idsToMethods map[[4]byte]*method,
si StatefulImpl, idsToMethods map[string]*method,
) (vm.PrecompileContainer, error) {
if idsToMethods == nil {
return nil, ErrContainerHasNoMethods
Expand All @@ -77,9 +78,7 @@ func (sc *statefulContainer) Run(
}

// Extract the method ID from the input and load the method.

methodID := input[:NumBytesMethodID]
method, found := sc.idsToMethods[[4]byte(methodID)]
method, found := sc.idsToMethods[utils.UnsafeBytesToStr(input[:NumBytesMethodID])]

Check failure on line 81 in eth/core/precompile/stateful_container.go

View workflow job for this annotation

GitHub Actions / ci (build, polaris-linux-latest, 1.21.0)

undefined: utils.UnsafeBytesToStr
if !found {
return nil, ErrMethodNotFound
}
Expand Down
15 changes: 8 additions & 7 deletions eth/core/precompile/stateful_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"pkg.berachain.dev/polaris/eth/common"
"pkg.berachain.dev/polaris/eth/core/vm"
vmmock "pkg.berachain.dev/polaris/eth/core/vm/mock"
"pkg.berachain.dev/polaris/lib/utils"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -158,33 +159,33 @@ var (
contractFuncStrInputFunc, _ = reflect.TypeOf(mockStatefulDummy).MethodByName("ContractFuncStrInput")
overloadedFunc, _ = reflect.TypeOf(mockStatefulDummy).MethodByName("OverloadedFunc")
overloadedFunc0, _ = reflect.TypeOf(mockStatefulDummy).MethodByName("OverloadedFunc0")
mockIdsToMethods = map[[4]byte]*method{
[4]byte(getOutputABI.ID): newMethod(
mockIdsToMethods = map[string]*method{
utils.UnsafeBytesToStr(getOutputABI.ID): newMethod(
mockStatefulDummy,
getOutputABI,
getOutputFunc,
),
[4]byte(getOutputPartialABI.ID): newMethod(
utils.UnsafeBytesToStr(getOutputPartialABI.ID): newMethod(
mockStatefulDummy,
getOutputPartialABI,
getOutputPartialFunc,
),
[4]byte(contractFuncAddrABI.ID): newMethod(
utils.UnsafeBytesToStr(contractFuncAddrABI.ID): newMethod(
mockStatefulDummy,
contractFuncAddrABI,
contractFuncAddrInputFunc,
),
[4]byte(contractFuncStrABI.ID): newMethod(
utils.UnsafeBytesToStr(contractFuncStrABI.ID): newMethod(
mockStatefulDummy,
contractFuncStrABI,
contractFuncStrInputFunc,
),
[4]byte(overloadedFuncABI.ID): newMethod(
utils.UnsafeBytesToStr(overloadedFuncABI.ID): newMethod(
mockStatefulDummy,
overloadedFuncABI,
overloadedFunc,
),
[4]byte(contractFuncStrABI.ID): newMethod(
utils.UnsafeBytesToStr(contractFuncStrABI.ID): newMethod(
mockStatefulDummy,
overloadedFunc0ABI,
overloadedFunc0,
Expand Down

0 comments on commit 54bddb3

Please sign in to comment.