Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.

Commit 0708b48

Browse files
author
Casey Kuhlman
authored
Merge pull request #1451 from hyperledger/evm-ints
Fix vent EVM-to-SQL integral number type mapping
2 parents 02921f5 + 7c33192 commit 0708b48

File tree

9 files changed

+146
-86
lines changed

9 files changed

+146
-86
lines changed

.github/workflows/develop.yaml

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,54 @@ name: develop
22
on:
33
push:
44
branches:
5-
- master
6-
- release
5+
- develop
6+
tags-ignore:
7+
- 'v*'
78

89
jobs:
9-
cover:
10-
name: coverage
10+
js:
11+
name: npm
1112
runs-on: ubuntu-latest
1213
steps:
13-
- uses: actions/setup-go@v1
14-
with:
15-
go-version: 1.15
16-
id: go
17-
- uses: actions/checkout@v2
18-
- run: make test
19-
env:
20-
GO_TEST_ARGS: "-coverprofile=coverage.txt -covermode=atomic"
21-
- uses: codecov/[email protected]
22-
with:
23-
token: ${{ secrets.CODECOV_TOKEN }}
24-
file: ./coverage.txt
14+
- uses: actions/checkout@v2
15+
- run: git fetch --unshallow --prune
16+
- uses: actions/setup-node@v1
17+
with:
18+
always-auth: true
19+
node-version: '14.x'
20+
registry-url: 'https://registry.npmjs.org'
21+
- name: publish
22+
env:
23+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
24+
run: |
25+
git config --global user.email "${GITHUB_ACTOR}"
26+
git config --global user.name "${GITHUB_ACTOR}"
27+
make publish_js
2528
2629
docker:
2730
name: docker
2831
runs-on: ubuntu-latest
2932
steps:
30-
- uses: actions/checkout@v2
31-
- run: make docker_build
32-
- name: publish monax
33-
env:
34-
DOCKER_REPO: "hyperledger/burrow"
35-
DOCKER_REPO_DEV: "quay.io/monax/burrow"
36-
DOCKER_PASS_DEV: ${{ secrets.DOCKER_PASS_DEV }}
37-
DOCKER_USER_DEV: ${{ secrets.DOCKER_USER_DEV }}
38-
run: |
39-
version=$(./scripts/local_version.sh)
40-
echo ${DOCKER_PASS_DEV} | docker login --username ${DOCKER_USER_DEV} ${DOCKER_REPO_DEV} --password-stdin
41-
docker tag ${DOCKER_REPO}:${version} ${DOCKER_REPO_DEV}:${version}
42-
docker push --all-tags ${DOCKER_REPO_DEV}
43-
- name: publish hyperledger
44-
env:
45-
DOCKER_REPO: "hyperledger/burrow"
46-
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
47-
DOCKER_USER: ${{ secrets.DOCKER_USER }}
48-
run: |
49-
version=$(./scripts/local_version.sh)
50-
echo ${DOCKER_PASS} | docker login --username ${DOCKER_USER} --password-stdin
51-
docker tag ${DOCKER_REPO}:${version} ${DOCKER_REPO}:latest
52-
docker push ${DOCKER_REPO}:latest
33+
- uses: actions/checkout@v2
34+
- run: make docker_build
35+
- name: publish monax
36+
env:
37+
DOCKER_REPO: "hyperledger/burrow"
38+
DOCKER_REPO_DEV: "quay.io/monax/burrow"
39+
DOCKER_PASS_DEV: ${{ secrets.DOCKER_PASS_DEV }}
40+
DOCKER_USER_DEV: ${{ secrets.DOCKER_USER_DEV }}
41+
run: |
42+
version=$(./scripts/local_version.sh)
43+
echo ${DOCKER_PASS_DEV} | docker login --username ${DOCKER_USER_DEV} ${DOCKER_REPO_DEV} --password-stdin
44+
docker tag ${DOCKER_REPO}:${version} ${DOCKER_REPO_DEV}:${version}
45+
docker push --all-tags ${DOCKER_REPO_DEV}
46+
- name: publish hyperledger
47+
env:
48+
DOCKER_REPO: "hyperledger/burrow"
49+
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
50+
DOCKER_USER: ${{ secrets.DOCKER_USER }}
51+
run: |
52+
version=$(./scripts/local_version.sh)
53+
echo ${DOCKER_PASS} | docker login --username ${DOCKER_USER} --password-stdin
54+
docker tag ${DOCKER_REPO}:${version} ${DOCKER_REPO}:latest
55+
docker push ${DOCKER_REPO}:latest

.github/workflows/master.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: master
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
jobs:
8+
cover:
9+
name: coverage
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/setup-go@v1
13+
with:
14+
go-version: 1.15
15+
id: go
16+
- uses: actions/checkout@v2
17+
- run: make test
18+
env:
19+
GO_TEST_ARGS: "-coverprofile=coverage.txt -covermode=atomic"
20+
- uses: codecov/[email protected]
21+
with:
22+
token: ${{ secrets.CODECOV_TOKEN }}
23+
file: ./coverage.txt
24+
25+
docker:
26+
name: docker
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v2
30+
- run: make docker_build
31+
- name: publish monax
32+
env:
33+
DOCKER_REPO: "hyperledger/burrow"
34+
DOCKER_REPO_DEV: "quay.io/monax/burrow"
35+
DOCKER_PASS_DEV: ${{ secrets.DOCKER_PASS_DEV }}
36+
DOCKER_USER_DEV: ${{ secrets.DOCKER_USER_DEV }}
37+
run: |
38+
version=$(./scripts/local_version.sh)
39+
echo ${DOCKER_PASS_DEV} | docker login --username ${DOCKER_USER_DEV} ${DOCKER_REPO_DEV} --password-stdin
40+
docker tag ${DOCKER_REPO}:${version} ${DOCKER_REPO_DEV}:${version}
41+
docker push --all-tags ${DOCKER_REPO_DEV}
42+
- name: publish hyperledger
43+
env:
44+
DOCKER_REPO: "hyperledger/burrow"
45+
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
46+
DOCKER_USER: ${{ secrets.DOCKER_USER }}
47+
run: |
48+
version=$(./scripts/local_version.sh)
49+
echo ${DOCKER_PASS} | docker login --username ${DOCKER_USER} --password-stdin
50+
docker tag ${DOCKER_REPO}:${version} ${DOCKER_REPO}:latest
51+
docker push ${DOCKER_REPO}:latest

.github/workflows/release.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ jobs:
3838
run: |
3939
git config --global user.email "${GITHUB_ACTOR}"
4040
git config --global user.name "${GITHUB_ACTOR}"
41-
cd js
42-
yarn install
43-
yarn version --no-git-tag-version --new-version $(git describe --tags)
44-
yarn build
45-
yarn publish --access public
41+
make publish_js
4642
4743
4844
docker:

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ PROTO_GEN_TS_PATH = ${BURROW_TS_PATH}/proto
7979
NODE_BIN = ${BURROW_TS_PATH}/node_modules/.bin
8080

8181
# To access Tendermint bundled protobuf files from go module cache
82-
TENDERMINT_MOD=github.com/tendermint/tendermint
83-
TENDERMINT_VERSION=$(shell go list -m -f '{{ .Version }}' $(TENDERMINT_MOD))
84-
TENDERMINT_SRC=$(shell go env GOMODCACHE)/$(TENDERMINT_MOD)@$(TENDERMINT_VERSION)
85-
TENDERMINT_PROTO=$(TENDERMINT_SRC)/proto
82+
TENDERMINT_MOD?=github.com/tendermint/tendermint
83+
TENDERMINT_VERSION?=$(shell go list -m -f '{{ .Version }}' $(TENDERMINT_MOD))
84+
TENDERMINT_SRC?=$(shell go env GOMODCACHE)/$(TENDERMINT_MOD)@$(TENDERMINT_VERSION)
85+
TENDERMINT_PROTO?=$(TENDERMINT_SRC)/proto
8686

8787
PROTO_FILES = $(shell find . $(TENDERMINT_PROTO) -path $(BURROW_TS_PATH) -prune -o -path ./node_modules -prune -o -type f -name '*.proto' -print)
8888
PROTO_GO_FILES = $(patsubst %.proto, %.pb.go, $(PROTO_FILES))
@@ -210,6 +210,12 @@ yarn_install:
210210
test_js:
211211
@cd ${BURROW_TS_PATH} && yarn test
212212

213+
.PHONY: publish_js
214+
publish_js:
215+
yarn --cwd js install
216+
yarn --cwd js build
217+
yarn --cwd js publish --access public --non-interactive --no-git-tag-version --new-version $(shell ./scripts/local_version.sh)
218+
213219
.PHONY: test
214220
test: check bin/solc bin/solang
215221
@tests/scripts/bin_wrapper.sh go test ./... ${GO_TEST_ARGS}

cmd/burrow/commands/vent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func Vent(output Output) func(cmd *cli.Cmd) {
3434
httpAddrOpt := cmd.StringOpt("http-addr", cfg.HTTPListenAddress, "Address to bind the HTTP server")
3535
logLevelOpt := cmd.StringOpt("log-level", cfg.LogLevel, "Logging level (error, warn, info, debug)")
3636
watchAddressesOpt := cmd.StringsOpt("watch", nil, "Add contract address to global watch filter")
37-
minimumHeightOpt := cmd.IntOpt("minimum-height", 0, "Add contract address to global watch filter")
37+
minimumHeightOpt := cmd.IntOpt("minimum-height", 0, "Only process block greater than or equal to height passed")
3838
abiFileOpt := cmd.StringsOpt("abi", cfg.AbiFileOrDirs, "EVM Contract ABI file or folder")
3939
specFileOrDirOpt := cmd.StringsOpt("spec", cfg.SpecFileOrDirs, "SQLSol specification file or folder")
4040
dbBlockOpt := cmd.BoolOpt("blocks", false, "Create block tables and persist related data")

js/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"version": "0.0.0",
23
"name": "@hyperledger/burrow",
34
"description": "TypeScript library that calls a Hyperledger Burrow server over GRPC.",
45
"main": "./dist/index.js",

scripts/local_version.sh

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,35 @@ set -e
1111
REPO=${REPO:-"$PWD"}
1212
VERSION_REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$"
1313

14-
1514
version=$(go run "$REPO/project/cmd/version/main.go")
1615
tag=$(git tag --points-at HEAD)
1716

1817
function log() {
19-
echo "$*" >> /dev/stderr
18+
echo "$*" >>/dev/stderr
2019
}
2120

2221
# Gives RFC 3339 with T instead of space
2322
date=$(date -Idate)
2423

2524
commit=$(git rev-parse --short HEAD)
2625

27-
if [[ ${tag} =~ ${VERSION_REGEX} ]] ; then
28-
# Only label a build as a release version when the commit is tagged
29-
log "Building release version (tagged $tag)..."
30-
# Fail noisily when trying to build a release version that does not match code tag
31-
if [[ ! ${tag} = "v$version" ]]; then
32-
log "Build failure: version tag $tag does not match version/version.go version $version"
33-
exit 1
34-
fi
26+
if [[ ${tag} =~ ${VERSION_REGEX} ]]; then
27+
# Only label a build as a release version when the commit is tagged
28+
log "Building release version (tagged $tag)..."
29+
# Fail noisily when trying to build a release version that does not match code tag
30+
if [[ ! ${tag} == "v$version" ]]; then
31+
log "Build failure: version tag $tag does not match version/version.go version $version"
32+
exit 1
33+
fi
3534
else
36-
version="$version-dev-$date-$commit"
37-
log "Building non-release version $version..."
35+
# Semver pre-release build suffix
36+
prerelease="dev.$commit"
37+
prerelease=${prerelease//-/.}
38+
version="$version-$prerelease"
39+
log "Building non-release version $version..."
3840
fi
3941

4042
# for export
4143
date=$(date -Iseconds)
4244

43-
echo ${version}
45+
echo "$version"

vent/sqlsol/projection.go

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -262,35 +262,36 @@ func getSQLType(evmSignature string, bytesMapping BytesMapping) (types.SQLColumn
262262
// solidity string => sql text
263263
case evmSignature == types.EventFieldTypeString:
264264
return types.SQLColumnTypeText, 0, nil
265-
// solidity int or int256 => sql bigint
266-
// solidity int <= 32 => sql int
267-
// solidity int > 32 => sql numeric
265+
268266
case strings.HasPrefix(evmSignature, types.EventFieldTypeInt):
269-
if typeSize == 0 || typeSize == 256 {
270-
return types.SQLColumnTypeBigInt, 0, nil
271-
}
272-
if typeSize <= 32 {
273-
return types.SQLColumnTypeInt, 0, nil
274-
} else {
275-
return types.SQLColumnTypeNumeric, 0, nil
276-
}
277-
// solidity uint or uint256 => sql bigint
278-
// solidity uint <= 16 => sql int
279-
// solidity uint > 16 => sql numeric
267+
return evmIntegerSizeToSqlType(typeSize, true), 0, nil
268+
280269
case strings.HasPrefix(evmSignature, types.EventFieldTypeUInt):
281-
if typeSize == 0 || typeSize == 256 {
282-
return types.SQLColumnTypeBigInt, 0, nil
283-
}
284-
if typeSize <= 16 {
285-
return types.SQLColumnTypeInt, 0, nil
286-
} else {
287-
return types.SQLColumnTypeNumeric, 0, nil
288-
}
270+
return evmIntegerSizeToSqlType(typeSize, false), 0, nil
289271
default:
290272
return -1, 0, fmt.Errorf("do not know how to map evmSignature: %s ", evmSignature)
291273
}
292274
}
293275

276+
func evmIntegerSizeToSqlType(size int, signed bool) types.SQLColumnType {
277+
// Unsized ints default to 256-bit
278+
if size == 0 {
279+
return types.SQLColumnTypeNumeric
280+
}
281+
// since SQL integers are signed we need an extra bit headroom so high-order bit of a uint isn't interpreted as
282+
// the sign bit
283+
if !signed {
284+
size++
285+
}
286+
switch {
287+
case size <= 32:
288+
return types.SQLColumnTypeInt
289+
case size <= 64:
290+
return types.SQLColumnTypeBigInt
291+
}
292+
return types.SQLColumnTypeNumeric
293+
}
294+
294295
// getGlobalColumns returns global columns for event table structures,
295296
// these columns will be part of every SQL event table to relate data with source events
296297
func getGlobalFieldMappings() []*types.EventFieldMapping {

vent/sqlsol/projection_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ func TestGetColumn(t *testing.T) {
8383
column, err := projection.GetColumn("TEST_TABLE", "Block")
8484
require.NoError(t, err)
8585
require.Equal(t, "Block", column.Name)
86-
require.Equal(t, types.SQLColumnTypeBigInt, column.Type)
86+
require.Equal(t, types.SQLColumnTypeNumeric, column.Type)
8787
require.Equal(t, false, column.Primary)
8888

8989
column, err = projection.GetColumn("TEST_TABLE", "Instance")
9090
require.NoError(t, err)
9191
require.Equal(t, "Instance", column.Name)
92-
require.Equal(t, types.SQLColumnTypeBigInt, column.Type)
92+
require.Equal(t, types.SQLColumnTypeNumeric, column.Type)
9393
require.Equal(t, false, column.Primary)
9494

9595
})

0 commit comments

Comments
 (0)