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

Commit

Permalink
Merge pull request #1330 from hyperledger/fix-1326
Browse files Browse the repository at this point in the history
ABI: failure to convert crypto.Address to EVMAddress
  • Loading branch information
Greg Hill authored Feb 11, 2020
2 parents bfa9180 + 4a8fdc4 commit 6205f48
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion NOTES.md
Original file line number Diff line number Diff line change
@@ -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)

10 changes: 9 additions & 1 deletion execution/evm/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"},
Expand Down Expand Up @@ -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:])
Expand Down
31 changes: 12 additions & 19 deletions execution/evm/abi/primitives.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions project/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6205f48

Please sign in to comment.