diff --git a/CHANGELOG.md b/CHANGELOG.md index c9615c63e..5ceb4e844 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # [Hyperledger Burrow](https://github.com/hyperledger/burrow) Changelog +## [0.29.8] - 2020-02-11 +### Fixed +- [ABI] Fix failure to convert crypto.Address to EVMAddress (https://github.com/hyperledger/burrow/issues/1326) + + ## [0.29.7] - 2020-01-27 ### Fixed - [Build] Updates to CI build process @@ -623,6 +628,7 @@ This release marks the start of Eris-DB as the full permissioned blockchain node - [Blockchain] Fix getBlocks to respect block height cap. +[0.29.8]: https://github.com/hyperledger/burrow/compare/v0.29.7...v0.29.8 [0.29.7]: https://github.com/hyperledger/burrow/compare/v0.29.6...v0.29.7 [0.29.6]: https://github.com/hyperledger/burrow/compare/v0.29.5...v0.29.6 [0.29.5]: https://github.com/hyperledger/burrow/compare/v0.29.4...v0.29.5 diff --git a/NOTES.md b/NOTES.md index a3b24ef28..6829c1922 100644 --- a/NOTES.md +++ b/NOTES.md @@ -1,3 +1,3 @@ ### Fixed -- [Build] Updates to CI build process +- [ABI] Fix failure to convert crypto.Address to EVMAddress (https://github.com/hyperledger/burrow/issues/1326) diff --git a/execution/evm/abi/abi_test.go b/execution/evm/abi/abi_test.go index 5c84aa495..cf61b6478 100644 --- a/execution/evm/abi/abi_test.go +++ b/execution/evm/abi/abi_test.go @@ -8,6 +8,7 @@ import ( "github.com/tmthrgd/go-hex" + "github.com/hyperledger/burrow/crypto" "github.com/hyperledger/burrow/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -25,6 +26,13 @@ func TestPacker(t *testing.T) { name string expectedOutput []byte }{ + // From: https://github.com/hyperledger/burrow/issues/1326 + { + `[{"constant":false,"inputs":[{"internalType":"address payable","name":"friend","type":"address"}],"name":"sendToAFriend","outputs":[],"payable":true,"stateMutability":"payable","type":"function"}]`, + []interface{}{crypto.Address{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}}, + "sendToAFriend", + pad([]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, 32, true), + }, { `[{"constant":false,"inputs":[{"name":"","type":"uint256"}],"name":"UInt","outputs":[],"payable":false,"type":"function"}]`, []interface{}{"1"}, @@ -127,7 +135,7 @@ func TestPacker(t *testing.T) { } { t.Log(test.args) if output, _, err := EncodeFunctionCall(test.ABI, test.name, logging.NewNoopLogger(), test.args...); err != nil { - t.Error("Unexpected error in ", test.name, ": ", err) + t.Errorf("Unexpected error in %s: %v", test.name, err) } else { if !bytes.Equal(output[4:], test.expectedOutput) { t.Errorf("Incorrect output,\n\t expected %v,\n\t got %v", test.expectedOutput, output[4:]) diff --git a/execution/evm/abi/primitives.go b/execution/evm/abi/primitives.go index 5f89715c6..2b386ceaa 100644 --- a/execution/evm/abi/primitives.go +++ b/execution/evm/abi/primitives.go @@ -514,29 +514,22 @@ func (e EVMAddress) GetSignature() string { } func (e EVMAddress) pack(v interface{}) ([]byte, error) { - var err error - a, ok := v.(crypto.Address) - if !ok { - s, ok := v.(string) - if ok { - a, err = crypto.AddressFromHexString(s) - if err != nil { - return nil, err - } - } - } else { - b, ok := v.([]byte) - if !ok { - return nil, fmt.Errorf("cannot map to %s to EVM address", reflect.ValueOf(v).Kind().String()) - } - - a, err = crypto.AddressFromBytes(b) + var bs []byte + switch a := v.(type) { + case crypto.Address: + bs = a[:] + case *crypto.Address: + bs = (*a)[:] + case []byte: + address, err := crypto.AddressFromBytes(a) if err != nil { return nil, err } + bs = address[:] + default: + return nil, fmt.Errorf("cannot map from %s to EVM address", reflect.ValueOf(v).Kind().String()) } - - return pad(a[:], ElementSize, true), nil + return pad(bs, ElementSize, true), nil } func (e EVMAddress) unpack(data []byte, offset int, v interface{}) (int, error) { diff --git a/project/history.go b/project/history.go index f5c40184e..6876c7ee9 100644 --- a/project/history.go +++ b/project/history.go @@ -48,6 +48,10 @@ func FullVersion() string { // release tagging script: ./scripts/tag_release.sh var History relic.ImmutableHistory = relic.NewHistory("Hyperledger Burrow", "https://github.com/hyperledger/burrow"). MustDeclareReleases( + "0.29.8 - 2020-02-11", + `### Fixed +- [ABI] Fix failure to convert crypto.Address to EVMAddress (https://github.com/hyperledger/burrow/issues/1326) +`, "0.29.7 - 2020-01-27", `### Fixed - [Build] Updates to CI build process