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

Commit a934952

Browse files
author
Silas Davis
committed
Fix broken decoding on RLP
Use this to fix eth tests Signed-off-by: Silas Davis <[email protected]>
1 parent fd78e37 commit a934952

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+946
-612
lines changed

acm/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818

1919
var GlobalPermissionsAddress = crypto.Address(binary.Zero160)
2020

21-
func NewAccount(pubKey crypto.PublicKey) *Account {
21+
func NewAccount(pubKey *crypto.PublicKey) *Account {
2222
return &Account{
2323
Address: pubKey.GetAddress(),
2424
PublicKey: pubKey,

acm/acm.pb.go

Lines changed: 53 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acm/balance/balance.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ func NativeToWei(n uint64) *big.Int {
137137
return new(big.Int).Mul(x, eth)
138138
}
139139

140-
func WeiToNative(n []byte) *big.Int {
141-
x := new(big.Int).SetBytes(n)
140+
func WeiToNative(x *big.Int) *big.Int {
142141
return new(big.Int).Div(x, eth)
143142
}

acm/balance/balance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ func TestSort(t *testing.T) {
2424
func TestEtherConversion(t *testing.T) {
2525
wei := NativeToWei(1)
2626
assert.Equal(t, wei.String(), "1000000000000000000", "must equal one ether")
27-
native := WeiToNative(wei.Bytes())
27+
native := WeiToNative(wei)
2828
assert.Equal(t, native.Uint64(), uint64(1))
2929
}

acm/private_account.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func (pa *PrivateAccount) GetAddress() crypto.Address {
2424
return pa.concretePrivateAccount.Address
2525
}
2626

27-
func (pa *PrivateAccount) GetPublicKey() crypto.PublicKey {
28-
return pa.concretePrivateAccount.PublicKey
27+
func (pa *PrivateAccount) GetPublicKey() *crypto.PublicKey {
28+
return &pa.concretePrivateAccount.PublicKey
2929
}
3030

3131
func (pa *PrivateAccount) Sign(msg []byte) (*crypto.Signature, error) {
@@ -78,7 +78,7 @@ func PrivateAccountFromPrivateKey(privateKey crypto.PrivateKey) *PrivateAccount
7878
return &PrivateAccount{
7979
concretePrivateAccount: &ConcretePrivateAccount{
8080
PrivateKey: privateKey,
81-
PublicKey: publicKey,
81+
PublicKey: *publicKey,
8282
Address: publicKey.GetAddress(),
8383
},
8484
}
@@ -102,7 +102,7 @@ func GeneratePrivateAccount(ct crypto.CurveType) (*PrivateAccount, error) {
102102
publicKey := privateKey.GetPublicKey()
103103
return ConcretePrivateAccount{
104104
Address: publicKey.GetAddress(),
105-
PublicKey: publicKey,
105+
PublicKey: *publicKey,
106106
PrivateKey: privateKey,
107107
}.PrivateAccount(), nil
108108
}
@@ -111,7 +111,7 @@ func privateAccount(privateKey crypto.PrivateKey) *PrivateAccount {
111111
publicKey := privateKey.GetPublicKey()
112112
return ConcretePrivateAccount{
113113
Address: publicKey.GetAddress(),
114-
PublicKey: publicKey,
114+
PublicKey: *publicKey,
115115
PrivateKey: privateKey,
116116
}.PrivateAccount()
117117
}

acm/validator/bucket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (vc *Bucket) Power(id crypto.Address) (*big.Int, error) {
4747
}
4848

4949
// SetPower ensures that validator power would not change too quickly in a single block
50-
func (vc *Bucket) SetPower(id crypto.PublicKey, power *big.Int) (*big.Int, error) {
50+
func (vc *Bucket) SetPower(id *crypto.PublicKey, power *big.Int) (*big.Int, error) {
5151
const errHeader = "Bucket.SetPower():"
5252
err := checkPower(power)
5353
if err != nil {

acm/validator/ring.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (vc *Ring) GetPower(id crypto.Address) *big.Int {
6363
return vc.Head().Previous.GetPower(id)
6464
}
6565

66-
func (vc *Ring) SetPower(id crypto.PublicKey, power *big.Int) (*big.Int, error) {
66+
func (vc *Ring) SetPower(id *crypto.PublicKey, power *big.Int) (*big.Int, error) {
6767
return vc.Head().SetPower(id, power)
6868
}
6969

acm/validator/set.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ func NewTrimSet() *Set {
4444
}
4545

4646
// Implements Writer, but will never error
47-
func (vs *Set) SetPower(id crypto.PublicKey, power *big.Int) (*big.Int, error) {
47+
func (vs *Set) SetPower(id *crypto.PublicKey, power *big.Int) (*big.Int, error) {
4848
return vs.ChangePower(id, power), nil
4949
}
5050

5151
// Add the power of a validator and returns the flow into that validator
52-
func (vs *Set) ChangePower(id crypto.PublicKey, power *big.Int) *big.Int {
52+
func (vs *Set) ChangePower(id *crypto.PublicKey, power *big.Int) *big.Int {
5353
address := id.GetAddress()
5454
// Calculate flow into this validator (positive means in, negative means out)
5555
flow := vs.Flow(id, power)
@@ -78,7 +78,7 @@ func (vs *Set) MaxFlow() *big.Int {
7878
}
7979

8080
// Returns the flow that would be induced by a validator power change
81-
func (vs *Set) Flow(id crypto.PublicKey, power *big.Int) *big.Int {
81+
func (vs *Set) Flow(id *crypto.PublicKey, power *big.Int) *big.Int {
8282
return new(big.Int).Sub(power, vs.GetPower(id.GetAddress()))
8383
}
8484

acm/validator/set_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ func TestValidators_AlterPower(t *testing.T) {
2020
assertZero(t, vs.TotalPower())
2121
}
2222

23-
func pubKey(secret interface{}) crypto.PublicKey {
23+
func pubKey(secret interface{}) *crypto.PublicKey {
2424
return acm.NewAccountFromSecret(fmt.Sprintf("%v", secret)).PublicKey
2525
}

acm/validator/validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/hyperledger/burrow/acm"
1010
)
1111

12-
func New(publicKey crypto.PublicKey, power *big.Int) *Validator {
12+
func New(publicKey *crypto.PublicKey, power *big.Int) *Validator {
1313
v := &Validator{
1414
PublicKey: publicKey,
1515
Power: power.Uint64(),

0 commit comments

Comments
 (0)