From 1685ef700af3dee798cbcf66dca46d56694ee98d Mon Sep 17 00:00:00 2001 From: Jim Zhang Date: Tue, 29 Oct 2024 11:43:21 -0400 Subject: [PATCH 1/6] Update solidity compiler version to 0.8.27 Signed-off-by: Jim Zhang --- solidity/hardhat.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solidity/hardhat.config.ts b/solidity/hardhat.config.ts index 277581e..8544b8a 100644 --- a/solidity/hardhat.config.ts +++ b/solidity/hardhat.config.ts @@ -29,7 +29,7 @@ const keys = [ const config: HardhatUserConfig = { solidity: { - version: "0.8.20", + version: "0.8.27", settings: { optimizer: { enabled: false, From fabacb4c02ac215ca750c52e45a38c1738bb271a Mon Sep 17 00:00:00 2001 From: Jim Zhang Date: Tue, 29 Oct 2024 11:49:47 -0400 Subject: [PATCH 2/6] Replace local array sort impl with openzeppelin util Signed-off-by: Jim Zhang --- solidity/contracts/lib/common.sol | 78 -------------------------- solidity/contracts/lib/zeto_common.sol | 5 +- 2 files changed, 3 insertions(+), 80 deletions(-) diff --git a/solidity/contracts/lib/common.sol b/solidity/contracts/lib/common.sol index f99c4ce..7b3d712 100644 --- a/solidity/contracts/lib/common.sol +++ b/solidity/contracts/lib/common.sol @@ -59,82 +59,4 @@ library Commonlib { return keccak256(abi.encodePacked(inputs)); } - - // copied from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Arrays.sol - // until it's available in a new release - function sort( - uint256[] memory array - ) internal pure returns (uint256[] memory) { - bytes32[] memory bytes32Array = _castToBytes32Array(array); - _quickSort(_begin(bytes32Array), _end(bytes32Array), _defaultComp); - return array; - } - - function _castToBytes32Array( - uint256[] memory input - ) private pure returns (bytes32[] memory output) { - assembly { - output := input - } - } - - function _defaultComp(bytes32 a, bytes32 b) private pure returns (bool) { - return a < b; - } - - function _begin(bytes32[] memory array) private pure returns (uint256 ptr) { - /// @solidity memory-safe-assembly - assembly { - ptr := add(array, 0x20) - } - } - - function _end(bytes32[] memory array) private pure returns (uint256 ptr) { - unchecked { - return _begin(array) + array.length * 0x20; - } - } - - function _mload(uint256 ptr) private pure returns (bytes32 value) { - assembly { - value := mload(ptr) - } - } - - function _swap(uint256 ptr1, uint256 ptr2) private pure { - assembly { - let value1 := mload(ptr1) - let value2 := mload(ptr2) - mstore(ptr1, value2) - mstore(ptr2, value1) - } - } - - function _quickSort( - uint256 begin, - uint256 end, - function(bytes32, bytes32) pure returns (bool) comp - ) private pure { - unchecked { - if (end - begin < 0x40) return; - - // Use first element as pivot - bytes32 pivot = _mload(begin); - // Position where the pivot should be at the end of the loop - uint256 pos = begin; - - for (uint256 it = begin + 0x20; it < end; it += 0x20) { - if (comp(_mload(it), pivot)) { - // If the value stored at the iterator's position comes before the pivot, we increment the - // position of the pivot and move the value there. - pos += 0x20; - _swap(pos, it); - } - } - - _swap(begin, pos); // Swap pivot into place - _quickSort(begin, pos, comp); // Sort the left side of the pivot - _quickSort(pos + 0x20, end, comp); // Sort the right side of the pivot - } - } } diff --git a/solidity/contracts/lib/zeto_common.sol b/solidity/contracts/lib/zeto_common.sol index 03d607e..79013a1 100644 --- a/solidity/contracts/lib/zeto_common.sol +++ b/solidity/contracts/lib/zeto_common.sol @@ -17,6 +17,7 @@ pragma solidity ^0.8.20; import {Commonlib} from "./common.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; +import {Arrays} from "@openzeppelin/contracts/utils/Arrays.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; /// @title A sample base implementation of a Zeto based token contract @@ -101,8 +102,8 @@ abstract contract ZetoCommon is OwnableUpgradeable { for (uint256 i = 0; i < outputs.length; ++i) { sortedOutputs[i] = outputs[i]; } - sortedInputs = Commonlib.sort(sortedInputs); - sortedOutputs = Commonlib.sort(sortedOutputs); + sortedInputs = Arrays.sort(sortedInputs); + sortedOutputs = Arrays.sort(sortedOutputs); return (sortedInputs, sortedOutputs); } } From 488a60b49f82030bab146fd6e9401a2f4d9fb8c2 Mon Sep 17 00:00:00 2001 From: Jim Zhang Date: Tue, 29 Oct 2024 12:44:44 -0400 Subject: [PATCH 3/6] Update golang version in actions setup to 1.23 Signed-off-by: Jim Zhang --- .github/workflows/golang.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 38f505b..237b12f 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -20,7 +20,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.22 + go-version: 1.23 - name: Build and Test working-directory: go-sdk From 991a4dbc234216dc61adebeba0425cae5af4d1d9 Mon Sep 17 00:00:00 2001 From: Jim Zhang Date: Tue, 29 Oct 2024 13:08:55 -0400 Subject: [PATCH 4/6] Update to actions/setup-go@v5 Signed-off-by: Jim Zhang --- .github/workflows/e2e.yaml | 5 +++++ .github/workflows/golang.yaml | 2 +- go-sdk/go.sum | 8 -------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index ae49335..7b9193e 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -61,6 +61,11 @@ jobs: npm install npm run gen + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.23 + - name: Run golang e2e tests env: PROVING_KEYS_ROOT: ${{ runner.temp }}/zeto-artifacts diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 237b12f..0517fca 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -18,7 +18,7 @@ jobs: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.23 diff --git a/go-sdk/go.sum b/go-sdk/go.sum index 596c7e2..d979ca1 100644 --- a/go-sdk/go.sum +++ b/go-sdk/go.sum @@ -88,8 +88,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg= github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= @@ -99,16 +97,10 @@ golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= -golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 6e92a7a9cecdfd61a26b74380a86b678273c9f99 Mon Sep 17 00:00:00 2001 From: Jim Zhang Date: Tue, 29 Oct 2024 13:24:07 -0400 Subject: [PATCH 5/6] install the latest version of golang-lint Signed-off-by: Jim Zhang --- go-sdk/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-sdk/Makefile b/go-sdk/Makefile index e1f5d6b..c079eaa 100644 --- a/go-sdk/Makefile +++ b/go-sdk/Makefile @@ -18,7 +18,7 @@ coverage: test coverage.html lint: ${LINT} GOGC=20 $(LINT) run -v --timeout 5m ${LINT}: - $(VGO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.0 + $(VGO) install github.com/golangci/golangci-lint/cmd/golangci-lint go-mod-tidy: .ALWAYS $(VGO) mod tidy e2e: test From 81aff0fda72aa9398f3025f5e03f9fdd3b16420f Mon Sep 17 00:00:00 2001 From: Jim Zhang Date: Tue, 29 Oct 2024 13:26:49 -0400 Subject: [PATCH 6/6] install the v1.61.1 version of golang-lint Signed-off-by: Jim Zhang --- go-sdk/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-sdk/Makefile b/go-sdk/Makefile index c079eaa..48f8981 100644 --- a/go-sdk/Makefile +++ b/go-sdk/Makefile @@ -18,7 +18,7 @@ coverage: test coverage.html lint: ${LINT} GOGC=20 $(LINT) run -v --timeout 5m ${LINT}: - $(VGO) install github.com/golangci/golangci-lint/cmd/golangci-lint + $(VGO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 go-mod-tidy: .ALWAYS $(VGO) mod tidy e2e: test