diff --git a/Makefile b/Makefile index 1b4ebb1e3bf839458c594ccbfc8e32a43481a240..2960d4051ddb028fc785f2318ca0277b89c352c8 100644 --- a/Makefile +++ b/Makefile @@ -154,9 +154,10 @@ docker_build: check commit_hash ### Testing github.com/hyperledger/burrow + # Solidity fixtures -%.sol.go: %.sol scripts/solc_compile_go.sh - scripts/solc_compile_go.sh $< $@ +%.sol.go: %.sol + @go run ./deploy/compile/solgo/main.go $^ .PHONY: solidity solidity: $(SOLIDITY_GO_FILES) diff --git a/deploy/compile/compilers.go b/deploy/compile/compilers.go index 15976c926c8f0cfa4123235b2d002e4870d7862f..60da5b5fc2cbd2bca7e781aa99c31baafa15ef53 100644 --- a/deploy/compile/compilers.go +++ b/deploy/compile/compilers.go @@ -207,8 +207,6 @@ func Compile(file string, optimize bool, libraries map[string]string) (*Response Error: errors, } - PrintResponse(resp, false) - return &resp, nil } diff --git a/deploy/compile/solgo/main.go b/deploy/compile/solgo/main.go new file mode 100644 index 0000000000000000000000000000000000000000..0229cd5d4b3dcaf0ec0f8557a093b3a63f66ec61 --- /dev/null +++ b/deploy/compile/solgo/main.go @@ -0,0 +1,46 @@ +package main + +import ( + "fmt" + "os" + "path" + + "github.com/hyperledger/burrow/deploy/compile" +) + +func main() { + for _, solfile := range os.Args[1:] { + resp, err := compile.Compile(solfile, false, nil) + + if err != nil { + fmt.Printf("failed compile solidity: %v\n", err) + os.Exit(1) + } + + if resp.Error != "" { + fmt.Print(resp.Error) + os.Exit(1) + } + + if resp.Warning != "" { + fmt.Print(resp.Warning) + os.Exit(1) + } + + f, err := os.Create(solfile + ".go") + if err != nil { + fmt.Printf("failed to create go file: %v\n", err) + os.Exit(1) + } + + f.WriteString(fmt.Sprintf("package %s\n\n", path.Base(path.Dir(solfile)))) + f.WriteString("import \"github.com/tmthrgd/go-hex\"\n\n") + + for _, c := range resp.Objects { + f.WriteString(fmt.Sprintf("var Bytecode_%s = hex.MustDecodeString(\"%s\")\n", + c.Objectname, c.Binary.Evm.Bytecode.Object)) + f.WriteString(fmt.Sprintf("var Abi_%s = `%s`\n", + c.Objectname, c.Binary.Abi)) + } + } +} diff --git a/execution/solidity/revert.sol.go b/execution/solidity/revert.sol.go index 1e5c6e5d662223cc6f97f702b21e42d2429ce357..0298b821afdf4eb6b0d80d428430993c6c961164 100644 --- a/execution/solidity/revert.sol.go +++ b/execution/solidity/revert.sol.go @@ -2,4 +2,5 @@ package solidity import "github.com/tmthrgd/go-hex" -var Bytecode_revert = hex.MustDecodeString("608060405234801561001057600080fd5b506101f4806100206000396000f300608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680635b202afb14610046575b600080fd5b34801561005257600080fd5b50610077600480360381019080803563ffffffff169060200190929190505050610079565b005b60008163ffffffff1614156100f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f492068617665207265766572746564000000000000000000000000000000000081525060200191505060405180910390fd5b8080600190039150508063ffffffff167ff7f0feb5b4ac5276c55faa8936d962de931ebe8333a2efdc0506878de3979ba960405160405180910390a23073ffffffffffffffffffffffffffffffffffffffff16635b202afb826040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808263ffffffff1663ffffffff168152602001915050600060405180830381600087803b1580156101ad57600080fd5b505af11580156101c1573d6000803e3d6000fd5b50505050505600a165627a7a723058204c781ff474f3b4fc9e46f86df7ab670d2b47ea7ae8515d2d6f19e5ac0afc46170029") +var Bytecode_Revert = hex.MustDecodeString("608060405234801561001057600080fd5b506101f4806100206000396000f300608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680635b202afb14610046575b600080fd5b34801561005257600080fd5b50610077600480360381019080803563ffffffff169060200190929190505050610079565b005b60008163ffffffff1614156100f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f492068617665207265766572746564000000000000000000000000000000000081525060200191505060405180910390fd5b8080600190039150508063ffffffff167ff7f0feb5b4ac5276c55faa8936d962de931ebe8333a2efdc0506878de3979ba960405160405180910390a23073ffffffffffffffffffffffffffffffffffffffff16635b202afb826040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808263ffffffff1663ffffffff168152602001915050600060405180830381600087803b1580156101ad57600080fd5b505af11580156101c1573d6000803e3d6000fd5b50505050505600a165627a7a7230582024a36efd1abf70d00acdeea9b7cebd6e23cb5739c56ac17f65054c1d5711e9bf0029") +var Abi_Revert = `[{"constant":false,"inputs":[{"name":"i","type":"uint32"}],"name":"RevertAt","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"i","type":"uint32"}],"name":"NotReverting","type":"event"}]` diff --git a/execution/solidity/strange_loop.sol.go b/execution/solidity/strange_loop.sol.go index 8b3de508e519852d6016abc16ba503b7a7d9e44e..018ac53cd07b3ff2a83ef709358a5e269b4ba8cd 100644 --- a/execution/solidity/strange_loop.sol.go +++ b/execution/solidity/strange_loop.sol.go @@ -2,4 +2,5 @@ package solidity import "github.com/tmthrgd/go-hex" -var Bytecode_strange_loop = hex.MustDecodeString("60806040526017600055602260015560116002556001600360006101000a81548160ff02191690831515021790555034801561003a57600080fd5b506103da8061004a6000396000f300608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063ebb384dd14610046575b600080fd5b34801561005257600080fd5b5061005b610071565b6040518082815260200191505060405180910390f35b60006002549050600360009054906101000a900460ff161561026b5760015460025412156101a5576002600081548092919060010191905055506002547f55707369652100000000000000000000000000000000000000000000000000007f3ff0b1eac80ecf8e93d1a2d7982a9230f8ea7693439fd548687b08a5e292b09760405160405180910390a360025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561016457600080fd5b505af1158015610178573d6000803e3d6000fd5b505050506040513d602081101561018e57600080fd5b810190808051906020019092919050505050610266565b6000600360006101000a81548160ff02191690831515021790555060025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561022957600080fd5b505af115801561023d573d6000803e3d6000fd5b505050506040513d602081101561025357600080fd5b8101908080519060200190929190505050505b6103aa565b600054600254131561038457600260008154809291906001900391905055506002547f446f776e736965210000000000000000000000000000000000000000000000007f3ff0b1eac80ecf8e93d1a2d7982a9230f8ea7693439fd548687b08a5e292b09760405160405180910390a360025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561034357600080fd5b505af1158015610357573d6000803e3d6000fd5b505050506040513d602081101561036d57600080fd5b8101908080519060200190929190505050506103a9565b6001600360006101000a81548160ff02191690831515021790555060025490506103ab565b5b5b905600a165627a7a7230582046f1e2c57a1e3ec2048f615b415c4f36aae08def8ebdd0e9c561770039925ac60029") +var Bytecode_StrangeLoop = hex.MustDecodeString("60806040526017600055602260015560116002556001600360006101000a81548160ff02191690831515021790555034801561003a57600080fd5b506103da8061004a6000396000f300608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063ebb384dd14610046575b600080fd5b34801561005257600080fd5b5061005b610071565b6040518082815260200191505060405180910390f35b60006002549050600360009054906101000a900460ff161561026b5760015460025412156101a5576002600081548092919060010191905055506002547f55707369652100000000000000000000000000000000000000000000000000007f3ff0b1eac80ecf8e93d1a2d7982a9230f8ea7693439fd548687b08a5e292b09760405160405180910390a360025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561016457600080fd5b505af1158015610178573d6000803e3d6000fd5b505050506040513d602081101561018e57600080fd5b810190808051906020019092919050505050610266565b6000600360006101000a81548160ff02191690831515021790555060025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561022957600080fd5b505af115801561023d573d6000803e3d6000fd5b505050506040513d602081101561025357600080fd5b8101908080519060200190929190505050505b6103aa565b600054600254131561038457600260008154809291906001900391905055506002547f446f776e736965210000000000000000000000000000000000000000000000007f3ff0b1eac80ecf8e93d1a2d7982a9230f8ea7693439fd548687b08a5e292b09760405160405180910390a360025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561034357600080fd5b505af1158015610357573d6000803e3d6000fd5b505050506040513d602081101561036d57600080fd5b8101908080519060200190929190505050506103a9565b6001600360006101000a81548160ff02191690831515021790555060025490506103ab565b5b5b905600a165627a7a723058208a36392c4111612b78f5e50934eb54c073f518a40cb7424d0b06303cdfdd93440029") +var Abi_StrangeLoop = `[{"constant":false,"inputs":[],"name":"UpsieDownsie","outputs":[{"name":"i","type":"int256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"direction","type":"bytes32"},{"indexed":true,"name":"newDepth","type":"int256"}],"name":"ChangeLevel","type":"event"}]` diff --git a/execution/solidity/zero_reset.sol.go b/execution/solidity/zero_reset.sol.go index 0d8485bcd3a26432aeb1520bad709e6e7ba976bc..cf034e0cf622e581350a5689abfae3dc28388e52 100644 --- a/execution/solidity/zero_reset.sol.go +++ b/execution/solidity/zero_reset.sol.go @@ -2,4 +2,5 @@ package solidity import "github.com/tmthrgd/go-hex" -var Bytecode_zero_reset = hex.MustDecodeString("608060405234801561001057600080fd5b506101c0806100206000396000f300608060405260043610610077576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680620267a41461007c5780634ef65c3b146100a757806362738998146100d4578063747586b8146100ff578063987dc8201461012c578063b15a0d5f14610143575b600080fd5b34801561008857600080fd5b5061009161015a565b6040518082815260200191505060405180910390f35b3480156100b357600080fd5b506100d260048036038101908080359060200190929190505050610164565b005b3480156100e057600080fd5b506100e961016e565b6040518082815260200191505060405180910390f35b34801561010b57600080fd5b5061012a60048036038101908080359060200190929190505050610177565b005b34801561013857600080fd5b50610141610181565b005b34801561014f57600080fd5b5061015861018a565b005b6000600154905090565b8060018190555050565b60008054905090565b8060008190555050565b60008081905550565b60006001819055505600a165627a7a72305820d63e4279f8c63b4166dedc146f1f7d426ebe1fd9985100f43ff6a601607275440029") +var Bytecode_ZeroReset = hex.MustDecodeString("608060405234801561001057600080fd5b506101c0806100206000396000f300608060405260043610610077576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680620267a41461007c5780634ef65c3b146100a757806362738998146100d4578063747586b8146100ff578063987dc8201461012c578063b15a0d5f14610143575b600080fd5b34801561008857600080fd5b5061009161015a565b6040518082815260200191505060405180910390f35b3480156100b357600080fd5b506100d260048036038101908080359060200190929190505050610164565b005b3480156100e057600080fd5b506100e961016e565b6040518082815260200191505060405180910390f35b34801561010b57600080fd5b5061012a60048036038101908080359060200190929190505050610177565b005b34801561013857600080fd5b50610141610181565b005b34801561014f57600080fd5b5061015861018a565b005b6000600154905090565b8060018190555050565b60008054905090565b8060008190555050565b60008081905550565b60006001819055505600a165627a7a72305820c19c71b6113c0b546a6cf9c093b61a1e9c9f42f62811bb4ebaff2f02b860a43e0029") +var Abi_ZeroReset = `[{"constant":true,"inputs":[],"name":"getUint","outputs":[{"name":"retUint","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"setUint","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getInt","outputs":[{"name":"retInt","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"x","type":"int256"}],"name":"setInt","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"setIntToZero","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"setUintToZero","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]` diff --git a/integration/core/kernel_test.go b/integration/core/kernel_test.go index d28572ed6153bae2b4a10c2af881aa9af48b38d0..374cf4b9913bee6beb4d23acc4e3ecd5ed5c9fbc 100644 --- a/integration/core/kernel_test.go +++ b/integration/core/kernel_test.go @@ -142,7 +142,7 @@ func bootWaitBlocksShutdown(t testing.TB, privValidator tmTypes.PrivValidator, t tcli := rpctest.NewTransactClient(t, testConfig.RPC.GRPC.ListenAddress) // Generate a few transactions for i := 0; i < 3; i++ { - rpctest.CreateContract(t, tcli, inputAddress, solidity.Bytecode_strange_loop) + rpctest.CreateContract(t, tcli, inputAddress, solidity.Bytecode_Strangeloop) } subID := event.GenSubID() diff --git a/integration/rpcevents/execution_events_server_test.go b/integration/rpcevents/execution_events_server_test.go index 6faf1e9da94a0e6479cec585615ce5523af45922..bc867e339f31828391969e4fdb611ad9a947f46b 100644 --- a/integration/rpcevents/execution_events_server_test.go +++ b/integration/rpcevents/execution_events_server_test.go @@ -131,7 +131,7 @@ func TestGetEventsSendFiltered(t *testing.T) { func TestRevert(t *testing.T) { tcli := rpctest.NewTransactClient(t, testConfig.RPC.GRPC.ListenAddress) - txe := rpctest.CreateContract(t, tcli, inputAddress, rpctest.Bytecode_revert) + txe := rpctest.CreateContract(t, tcli, inputAddress, rpctest.Bytecode_Revert) functionID := abi.GetFunctionID("RevertAt(uint32)") contractAddress := txe.Receipt.ContractAddress txe = rpctest.CallContract(t, tcli, inputAddress, contractAddress, diff --git a/integration/rpctransact/call_test.go b/integration/rpctransact/call_test.go index 9459cd361ebbf8daf7d00750f4873015bf22cc2d..4628b110c9471c830d766f334ecb81806407123a 100644 --- a/integration/rpctransact/call_test.go +++ b/integration/rpctransact/call_test.go @@ -66,7 +66,7 @@ func TestCreateContract(t *testing.T) { Amount: 2, }, Address: nil, - Data: solidity.Bytecode_strange_loop, + Data: solidity.Bytecode_Strangeloop, Fee: 2, GasLimit: 10000, }) @@ -91,7 +91,7 @@ func BenchmarkCreateContract(b *testing.B) { Amount: 2, }, Address: nil, - Data: solidity.Bytecode_strange_loop, + Data: solidity.Bytecode_Strangeloop, Fee: 2, GasLimit: 10000, }) @@ -109,7 +109,7 @@ func TestCallTxSync(t *testing.T) { for i := 0; i < numGoroutines; i++ { go func() { for j := 0; j < numRuns; j++ { - createTxe := rpctest.CreateContract(t, cli, inputAddress, solidity.Bytecode_strange_loop) + createTxe := rpctest.CreateContract(t, cli, inputAddress, solidity.Bytecode_Strangeloop) callTxe := rpctest.CallContract(t, cli, inputAddress, lastCall(createTxe.Events).CallData.Callee, functionID[:]) depth := binary.Uint64FromWord256(binary.LeftPadWord256(lastCall(callTxe.Events).Return)) @@ -248,7 +248,7 @@ func TestNestedCall(t *testing.T) { func TestCallEvents(t *testing.T) { cli := rpctest.NewTransactClient(t, testConfig.RPC.GRPC.ListenAddress) - createTxe := rpctest.CreateContract(t, cli, inputAddress, solidity.Bytecode_strange_loop) + createTxe := rpctest.CreateContract(t, cli, inputAddress, solidity.Bytecode_Strangeloop) address := lastCall(createTxe.Events).CallData.Callee functionID := abi.GetFunctionID("UpsieDownsie()") callTxe := rpctest.CallContract(t, cli, inputAddress, address, functionID[:]) @@ -261,7 +261,7 @@ func TestCallEvents(t *testing.T) { func TestLogEvents(t *testing.T) { cli := rpctest.NewTransactClient(t, testConfig.RPC.GRPC.ListenAddress) - createTxe := rpctest.CreateContract(t, cli, inputAddress, solidity.Bytecode_strange_loop) + createTxe := rpctest.CreateContract(t, cli, inputAddress, solidity.Bytecode_Strangeloop) address := lastCall(createTxe.Events).CallData.Callee functionID := abi.GetFunctionID("UpsieDownsie()") callTxe := rpctest.CallContract(t, cli, inputAddress, address, functionID[:]) @@ -276,7 +276,7 @@ func TestLogEvents(t *testing.T) { func TestRevert(t *testing.T) { cli := rpctest.NewTransactClient(t, testConfig.RPC.GRPC.ListenAddress) - txe := rpctest.CreateContract(t, cli, inputAddress, solidity.Bytecode_revert) + txe := rpctest.CreateContract(t, cli, inputAddress, solidity.Bytecode_Revert) functionID := abi.GetFunctionID("RevertAt(uint32)") txe = rpctest.CallContract(t, cli, inputAddress, txe.Receipt.ContractAddress, bc.MustSplice(functionID, binary.Int64ToWord256(4))) diff --git a/integration/rpctransact/transact_server_test.go b/integration/rpctransact/transact_server_test.go index 20e96b7b541c7dbf195050bc926d1808fc50376b..e452d398654419f6eba1f82375e38a1ad29b1e53 100644 --- a/integration/rpctransact/transact_server_test.go +++ b/integration/rpctransact/transact_server_test.go @@ -49,7 +49,7 @@ func TestInputAccountPublicKeySet(t *testing.T) { assert.False(t, acc.PublicKey.IsSet()) // Sign with this account - should set public key - rpctest.CreateContract(t, tcli, input.Address(), solidity.Bytecode_strange_loop) + rpctest.CreateContract(t, tcli, input.Address(), solidity.Bytecode_Strangeloop) acc, err = qcli.GetAccount(context.Background(), &rpcquery.GetAccountParam{Address: input.Address()}) // Check public key set diff --git a/scripts/solc_compile_go.sh b/scripts/solc_compile_go.sh deleted file mode 100755 index 997b7b08bce9dfbdc92c31b17e77ef0d767f9b78..0000000000000000000000000000000000000000 --- a/scripts/solc_compile_go.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -solidity_file="$1" -solidity_name=$(basename $1) -go_file="$2" -package=$(basename $(dirname "$go_file")) -solidity_bin=$(solc --bin "$solidity_file" | tail -1) - -cat << GOFILE > "$go_file" -package ${package} - -import "github.com/tmthrgd/go-hex" - -var Bytecode_${solidity_name%%.sol} = hex.MustDecodeString("${solidity_bin}") -GOFILE -