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

Commit f4192e3

Browse files
author
Silas Davis
committed
Upgrade to Go 1.16
Signed-off-by: Silas Davis <[email protected]>
1 parent b6820f7 commit f4192e3

29 files changed

+322
-273
lines changed

.github/Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM golang:1.15-alpine3.13
1+
FROM golang:1.16-alpine3.13
22
MAINTAINER Monax <[email protected]>
33

4-
ENV DOCKER_VERSION "17.12.1-ce"
5-
ENV GORELEASER_VERSION "v0.104.1"
4+
ENV DOCKER_VERSION "20.10.6"
5+
ENV GORELEASER_VERSION "v0.166.1"
66
# This is the image used by the Circle CI config
77
# Update remote with 'make push_ci_image'
88
RUN apk add --update --no-cache \
@@ -22,8 +22,8 @@ RUN apk add --update --no-cache \
2222
libffi-dev \
2323
openssl-dev \
2424
python3-dev \
25-
py-pip
26-
RUN pip3 install docker-compose
25+
py-pip \
26+
docker-compose
2727
# get docker client
2828
WORKDIR /usr/bin
2929
RUN curl -sS -L https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_VERSION.tgz | tar xz --strip-components 1 docker/docker

.github/workflows/main.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
- uses: actions/setup-go@v1
1313
with:
14-
go-version: 1.15
14+
go-version: 1.16
1515
id: go
1616
- uses: actions/checkout@v2
1717
- run: make test

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- run: git fetch --prune --unshallow
1414
- uses: actions/setup-go@v1
1515
with:
16-
go-version: 1.15
16+
go-version: 1.16
1717
- uses: goreleaser/goreleaser-action@v1
1818
with:
1919
version: latest

.github/workflows/test.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
- uses: actions/setup-go@v1
1313
with:
14-
go-version: 1.15
14+
go-version: 1.16
1515
id: go
1616
- uses: actions/checkout@v2
1717
- run: git fetch --unshallow --prune
@@ -27,7 +27,7 @@ jobs:
2727
steps:
2828
- uses: actions/setup-go@v1
2929
with:
30-
go-version: 1.15
30+
go-version: 1.16
3131
id: go
3232
- uses: actions/checkout@v1
3333
- run: make test_integration

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# For solc binary
2-
FROM ethereum/solc:0.5.12 as solc-builder
2+
FROM ethereum/solc:0.5.15 as solc-builder
33
# We use a multistage build to avoid bloating our deployment image with build dependencies
4-
FROM golang:1.15-alpine3.12 as builder
4+
FROM golang:1.16-alpine3.13 as builder
55

66
RUN apk add --no-cache --update git bash make musl-dev gcc libc6-compat
77

@@ -13,7 +13,7 @@ WORKDIR $REPO
1313
RUN make build
1414

1515
# This will be our base container image
16-
FROM alpine:3.11
16+
FROM alpine:3.13
1717

1818
# Variable arguments to populate labels
1919
ARG USER=burrow

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ REPO := $(shell pwd)
1515

1616
# Our own Go files containing the compiled bytecode of solidity files as a constant
1717

18-
export CI_IMAGE=hyperledger/burrow:ci-2
18+
export CI_IMAGE=hyperledger/burrow:ci-3
1919

2020
VERSION := $(shell scripts/version.sh)
2121
# Gets implicit default GOPATH if not set

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/hyperledger/burrow
22

3-
go 1.15
3+
go 1.16
44

55
require (
66
github.com/BurntSushi/toml v0.3.1
@@ -52,7 +52,7 @@ require (
5252
github.com/xlab/treeprint v1.0.0
5353
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
5454
golang.org/x/net v0.0.0-20210119194325-5f4716e94777
55-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
55+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
5656
google.golang.org/grpc v1.35.0
5757
google.golang.org/protobuf v1.25.0
5858
gopkg.in/yaml.v2 v2.4.0

js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.33.1-dev.e4b5f85b9",
2+
"version": "0.33.1-dev.4b4d42399",
33
"name": "@hyperledger/burrow",
44
"description": "TypeScript library that calls a Hyperledger Burrow server over GRPC.",
55
"main": "./dist/index.js",

js/src/contracts/abi.ts

+31-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,37 @@ export type Address = string;
66

77
export type FunctionIO = FunctionInput & FunctionOutput;
88

9-
// TODO: replace with ethers js
9+
export namespace ABI {
10+
export type Func = {
11+
type: 'function' | 'constructor' | 'fallback';
12+
name: string;
13+
inputs?: Array<FunctionInput>;
14+
outputs?: Array<FunctionOutput>;
15+
stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable';
16+
payable?: boolean;
17+
constant?: boolean;
18+
};
19+
20+
export type Event = {
21+
type: 'event';
22+
name: string;
23+
inputs: Array<EventInput>;
24+
anonymous: boolean;
25+
};
26+
27+
export type FunctionInput = {
28+
name: string;
29+
type: string;
30+
components?: FunctionInput[];
31+
internalType?: string;
32+
};
33+
34+
export type FunctionOutput = FunctionInput;
35+
export type EventInput = FunctionInput & { indexed?: boolean };
36+
37+
export type FunctionIO = FunctionInput & FunctionOutput;
38+
export type FunctionOrEvent = Func | Event;
39+
}
1040

1141
export function transformToFullName(abi: SolidityFunction | Event): string {
1242
if (abi.name.indexOf('(') !== -1) {
@@ -15,18 +45,3 @@ export function transformToFullName(abi: SolidityFunction | Event): string {
1545
const typeName = (abi.inputs as Array<EventInput | FunctionIO>).map((i) => i.type).join(',');
1646
return abi.name + '(' + typeName + ')';
1747
}
18-
19-
export function extractDisplayName(name: string): string {
20-
const length = name.indexOf('(');
21-
return length !== -1 ? name.substr(0, length) : name;
22-
}
23-
24-
export function extractTypeName(name: string): string {
25-
/// TODO: make it invulnerable
26-
const length = name.indexOf('(');
27-
return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : '';
28-
}
29-
30-
export function isFunction(abi: SolidityFunction | Event): abi is SolidityFunction {
31-
return abi.type === 'function' || abi.type === 'constructor';
32-
}
File renamed without changes.

js/src/contracts/compile.ts

+112
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import fs from 'fs';
2+
import { ResolvedImport } from 'solc';
13
import solc from 'solc_v5';
24
import { ABI } from './abi';
35
import { Contract } from './contract';
@@ -10,6 +12,62 @@ export type CompiledContract = {
1012
deployedBytecode?: string;
1113
};
1214

15+
export namespace Solidity {
16+
export type Bytecode = {
17+
linkReferences: any;
18+
object: string;
19+
opcodes: string;
20+
sourceMap: string;
21+
};
22+
23+
export type Contract = {
24+
assembly: any;
25+
evm: {
26+
bytecode: Bytecode;
27+
deployedBytecode: Bytecode;
28+
};
29+
functionHashes: any;
30+
gasEstimates: any;
31+
abi: ABI.FunctionOrEvent[];
32+
opcodes: string;
33+
runtimeBytecode: string;
34+
srcmap: string;
35+
srcmapRuntime: string;
36+
};
37+
38+
export type Source = {
39+
AST: any;
40+
};
41+
42+
export type InputDescription = {
43+
language: string;
44+
sources: Record<string, { content: string }>;
45+
settings: {
46+
outputSelection: Record<string, Record<string, Array<string>>>;
47+
};
48+
};
49+
50+
type Error = {
51+
sourceLocation?: {
52+
file: string;
53+
start: number;
54+
end: number;
55+
};
56+
type: string;
57+
component: string;
58+
severity: 'error' | 'warning';
59+
message: string;
60+
formattedMessage?: string;
61+
};
62+
63+
export type OutputDescription = {
64+
contracts: Record<string, Record<string, Contract>>;
65+
errors: Array<Error>;
66+
sourceList: Array<string>;
67+
sources: Record<string, Source>;
68+
};
69+
}
70+
1371
// Compile solidity source code
1472
export function compile<T = any>(
1573
source: string,
@@ -45,3 +103,57 @@ function getCompiledCode(contract: solc.Contract): Required<CompiledContract> {
45103
deployedBytecode: contract.evm.deployedBytecode.object,
46104
};
47105
}
106+
107+
function NewInputDescription(): Solidity.InputDescription {
108+
return {
109+
language: 'Solidity',
110+
sources: {},
111+
settings: { outputSelection: {} },
112+
};
113+
}
114+
115+
export function encodeInput(obj: Solidity.InputDescription): string {
116+
return JSON.stringify(obj);
117+
}
118+
119+
export function decodeOutput(str: string): Solidity.OutputDescription {
120+
return JSON.parse(str);
121+
}
122+
123+
export function inputDescriptionFromFiles(names: string[]): Solidity.InputDescription {
124+
const desc = NewInputDescription();
125+
names.map((name) => {
126+
desc.sources[name] = { content: fs.readFileSync(name).toString() };
127+
desc.settings.outputSelection[name] = {};
128+
desc.settings.outputSelection[name]['*'] = ['*'];
129+
});
130+
return desc;
131+
}
132+
133+
export function importLocal(path: string): ResolvedImport {
134+
return {
135+
contents: fs.readFileSync(path).toString(),
136+
};
137+
}
138+
139+
export function tokenizeLinks(links: Record<string, Record<string, unknown>>): string[] {
140+
const libraries: Array<string> = [];
141+
for (const file in links) {
142+
for (const library in links[file]) {
143+
libraries.push(file + ':' + library);
144+
}
145+
}
146+
return libraries;
147+
}
148+
149+
export function linker(bytecode: string, links: { name: string; address: string }[]): string {
150+
for (const { name, address } of links) {
151+
const paddedAddress = address + Array(40 - address.length + 1).join('0');
152+
const truncated = name.slice(0, 36);
153+
const label = '__' + truncated + Array(37 - truncated.length).join('_') + '__';
154+
while (bytecode.indexOf(label) >= 0) {
155+
bytecode = bytecode.replace(label, paddedAddress);
156+
}
157+
}
158+
return bytecode;
159+
}

js/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
export { Keccak } from 'sha3';
12
export * as Exec from '../proto/exec_pb';
23
export { CallTx, TxInput } from '../proto/payload_pb';
34
export { BlockRange } from '../proto/rpcevents_pb';
45
export { Client } from './client';
56
export { ContractCodec } from './codec';
67
export { Address } from './contracts/abi';
78
export { makeCallTx } from './contracts/call';
9+
export { linker } from './contracts/compile';
810
export { Contract } from './contracts/contract';
911
export { Result } from './convert';
1012
export {
@@ -21,4 +23,3 @@ export {
2123
} from './events';
2224
export { build } from './solts/build';
2325
export { Caller, defaultCall, Provider } from './solts/interface.gd';
24-
export { linker } from './solts/lib/compile';

js/src/solts/api.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ts, { factory } from 'typescript';
2-
import { ABI } from './lib/abi';
2+
import { ABI } from "../contracts/abi";
33
import { callerTypes, createCallerFunction } from './lib/caller';
44
import { declareContractType, generateContractObject } from './lib/contract';
55
import { generateDecodeObject } from './lib/decoder';
@@ -16,7 +16,7 @@ import { getContractMethods } from './lib/solidity';
1616
import { declareConstant, ExportToken, importBurrow, importReadable } from './lib/syntax';
1717
import Func = ABI.Func;
1818

19-
export { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles, tokenizeLinks } from './lib/compile';
19+
export { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles, tokenizeLinks } from '../contracts/compile';
2020

2121
export type Compiled = {
2222
name: string;
@@ -54,7 +54,7 @@ export function newFile(contracts: Compiled[], burrowImportPath: string): ts.Nod
5454
const deployMembers = contract.bytecode
5555
? [
5656
declareConstant(bytecodeName, factory.createStringLiteral(contract.bytecode, true), true),
57-
declareConstant(deployedBytecodeName, factory.createStringLiteral(contract.bytecode, true), true),
57+
declareConstant(deployedBytecodeName, factory.createStringLiteral(contract.deployedBytecode, true), true),
5858
generateDeployFunction(deploy, contract.links, provider, abiName, contractNames),
5959
generateDeployContractFunction(deploy, contract.links, provider),
6060
]

js/src/solts/build.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { promises as fs } from 'fs';
22
import * as path from 'path';
33
import * as solcv5 from 'solc_v5';
44
import * as solcv8 from 'solc_v8';
5+
import { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles, Solidity } from '../contracts/compile';
56
import { Compiled, newFile, printNodes, tokenizeLinks } from './api';
6-
import { decodeOutput, encodeInput, importLocal, inputDescriptionFromFiles, Solidity } from './lib/compile';
77

88
const solcCompilers = {
99
v5: solcv5,
@@ -29,7 +29,10 @@ export type BuildOptions = typeof defaultBuildOptions;
2929
* - Outputs the ABI files into bin to be later included in the distribution (for Vent and other ABI-consuming services)
3030
*/
3131
export async function build(srcPathOrFiles: string | string[], opts?: Partial<BuildOptions>): Promise<void> {
32-
const { solcVersion, binPath, basePath, burrowImportPath, abiExt } = { ...defaultBuildOptions, ...opts };
32+
const { solcVersion, binPath, basePath, burrowImportPath, abiExt } = {
33+
...defaultBuildOptions,
34+
...opts,
35+
};
3336
const basePathPrefix = new RegExp(
3437
'^' + path.resolve(basePath ?? (typeof srcPathOrFiles === 'string' ? srcPathOrFiles : process.cwd())),
3538
);

js/src/solts/lib/abi.ts

-31
This file was deleted.

0 commit comments

Comments
 (0)