Skip to content

Commit

Permalink
Update avalanchego to v1.9.9-rc.3 (#1191)
Browse files Browse the repository at this point in the history
* Update avalanchego to v1.9.9-rc.2

* bump avalanchego version
  • Loading branch information
StephenButtolph authored Feb 20, 2023
1 parent fd0e0d2 commit d3b4d9a
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 167 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/VictoriaMetrics/fastcache v1.10.0
github.com/ava-labs/avalanchego v1.9.8
github.com/ava-labs/avalanchego v1.9.9-rc.3
github.com/cespare/cp v0.1.0
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set v1.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0=
github.com/ava-labs/avalanchego v1.9.8 h1:5SHKqkWpBn9Pqxg2qpzDZ7FQqYFapzaCZwArapBdqAA=
github.com/ava-labs/avalanchego v1.9.8/go.mod h1:t9+R55TgRJxYCekRf/EicIjHBeeEQT04TQxpaF98+yM=
github.com/ava-labs/avalanchego v1.9.9-rc.3 h1:PKxLivTARExhTd9chSLV9jvRmxpoTDw45iojH8m3Mfs=
github.com/ava-labs/avalanchego v1.9.9-rc.3/go.mod h1:Xw2i8k6FjAaMyETEpn8zCTHtOeA6IFw/R14ThCt1SxU=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down
10 changes: 5 additions & 5 deletions plugin/evm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/ava-labs/avalanchego/api"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/crypto"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/utils/formatting"
"github.com/ava-labs/avalanchego/utils/rpc"

Expand All @@ -28,8 +28,8 @@ type Client interface {
GetAtomicTx(ctx context.Context, txID ids.ID) ([]byte, error)
GetAtomicUTXOs(ctx context.Context, addrs []string, sourceChain string, limit uint32, startAddress, startUTXOID string) ([][]byte, api.Index, error)
ListAddresses(ctx context.Context, userPass api.UserPass) ([]string, error)
ExportKey(ctx context.Context, userPass api.UserPass, addr string) (*crypto.PrivateKeySECP256K1R, string, error)
ImportKey(ctx context.Context, userPass api.UserPass, privateKey *crypto.PrivateKeySECP256K1R) (string, error)
ExportKey(ctx context.Context, userPass api.UserPass, addr string) (*secp256k1.PrivateKey, string, error)
ImportKey(ctx context.Context, userPass api.UserPass, privateKey *secp256k1.PrivateKey) (string, error)
Import(ctx context.Context, userPass api.UserPass, to string, sourceChain string) (ids.ID, error)
ExportAVAX(ctx context.Context, userPass api.UserPass, amount uint64, to string) (ids.ID, error)
Export(ctx context.Context, userPass api.UserPass, amount uint64, to string, assetID string) (ids.ID, error)
Expand Down Expand Up @@ -135,7 +135,7 @@ func (c *client) ListAddresses(ctx context.Context, user api.UserPass) ([]string

// ExportKey returns the private key corresponding to [addr] controlled by [user]
// in both Avalanche standard format and hex format
func (c *client) ExportKey(ctx context.Context, user api.UserPass, addr string) (*crypto.PrivateKeySECP256K1R, string, error) {
func (c *client) ExportKey(ctx context.Context, user api.UserPass, addr string) (*secp256k1.PrivateKey, string, error) {
res := &ExportKeyReply{}
err := c.requester.SendRequest(ctx, "avax.exportKey", &ExportKeyArgs{
UserPass: user,
Expand All @@ -145,7 +145,7 @@ func (c *client) ExportKey(ctx context.Context, user api.UserPass, addr string)
}

// ImportKey imports [privateKey] to [user]
func (c *client) ImportKey(ctx context.Context, user api.UserPass, privateKey *crypto.PrivateKeySECP256K1R) (string, error) {
func (c *client) ImportKey(ctx context.Context, user api.UserPass, privateKey *secp256k1.PrivateKey) (string, error) {
res := &api.JSONAddress{}
err := c.requester.SendRequest(ctx, "avax.importKey", &ImportKeyArgs{
UserPass: user,
Expand Down
13 changes: 4 additions & 9 deletions plugin/evm/export_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/crypto"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
"github.com/ava-labs/avalanchego/utils/math"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/utils/wrappers"
Expand Down Expand Up @@ -229,15 +229,10 @@ func (utx *UnsignedExportTx) SemanticVerify(
if len(cred.Sigs) != 1 {
return fmt.Errorf("expected one signature for EVM Input Credential, but found: %d", len(cred.Sigs))
}
pubKeyIntf, err := vm.secpFactory.RecoverPublicKey(utx.Bytes(), cred.Sigs[0][:])
pubKey, err := vm.secpFactory.RecoverPublicKey(utx.Bytes(), cred.Sigs[0][:])
if err != nil {
return err
}
pubKey, ok := pubKeyIntf.(*crypto.PublicKeySECP256K1R)
if !ok {
// This should never happen
return fmt.Errorf("expected *crypto.PublicKeySECP256K1R but got %T", pubKeyIntf)
}
if input.Address != PublicKeyToEthAddress(pubKey) {
return errPublicKeySignatureMismatch
}
Expand Down Expand Up @@ -287,7 +282,7 @@ func (vm *VM) newExportTx(
chainID ids.ID, // Chain to send the UTXOs to
to ids.ShortID, // Address of chain recipient
baseFee *big.Int, // fee to use post-AP3
keys []*crypto.PrivateKeySECP256K1R, // Pay the fee and provide the tokens
keys []*secp256k1.PrivateKey, // Pay the fee and provide the tokens
) (*Tx, error) {
outs := []*avax.TransferableOutput{{
Asset: avax.Asset{ID: assetID},
Expand All @@ -304,7 +299,7 @@ func (vm *VM) newExportTx(
var (
avaxNeeded uint64 = 0
ins, avaxIns []EVMInput
signers, avaxSigners [][]*crypto.PrivateKeySECP256K1R
signers, avaxSigners [][]*secp256k1.PrivateKey
err error
)

Expand Down
Loading

0 comments on commit d3b4d9a

Please sign in to comment.