Skip to content

Commit

Permalink
Merge pull request #2409 from iotaledger/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
karimodm authored Aug 31, 2022
2 parents b9806c5 + de8af2a commit 622d1d5
Show file tree
Hide file tree
Showing 105 changed files with 4,877 additions and 2,974 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# v0.9.5 - 2022-08-31

> This release introduces a warpsync plugin for fast epochs retrieval, a simplified faucet, local snapshot improvements, and network and general bug fixes.
- WarpSync: simplify & fix send on closed channel (#2407)
- Fix network and warpsync bugs & reset genesis time (#2406)
- Mana vector fixes (#2396)
- Implement simplified faucet (#2391)
- Update to latest hive.go (#2400)
- Warpsync: epoch syncing (#2367)
- Activity committments and activity log based on epochs (#2345)
- Implement solid entry points (#2373)

# v0.9.4 - 2022-08-08

> This release mostly include maintenance changes to the deployment scripts and minor bug fixes.
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ proto: $(PROTO_GO_FILES)
# If $GOPATH/bin/protoc-gen-go does not exist, we'll run this command to install it.
$(PROTOC_GEN_GO):
go install google.golang.org/protobuf/cmd/protoc-gen-go
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc

# Implicit compile rule for GRPC/proto files
%.pb.go: %.proto | $(PROTOC_GEN_GO)
protoc $< --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:.
protoc $< --go_out=paths=source_relative:.

.PHONY: clean_proto
clean_proto:
Expand Down
4 changes: 2 additions & 2 deletions client/wallet/packages/address/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func (a Address) Base58() string {

func (a Address) String() string {
return stringify.Struct("Address",
stringify.StructField("Address", a.Address()),
stringify.StructField("Index", a.Index),
stringify.NewStructField("Address", a.Address()),
stringify.NewStructField("Index", a.Index),
)
}

Expand Down
22 changes: 22 additions & 0 deletions client/wallet/packages/sendoptions/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sendoptions

import (
"context"
"time"

"github.com/cockroachdb/errors"
Expand Down Expand Up @@ -65,6 +66,25 @@ func Remainder(addr address.Address) SendFundsOption {
}
}

// Sources is an option for the SendFunds call that allows to specify the addresses from which the outputs for the
// transfer should be sourced.
func Sources(addr ...address.Address) SendFundsOption {
return func(options *SendFundsOptions) error {
options.SourceAddresses = addr

return nil
}
}

// Context is an option for SendFunds call that allows to specify a context that is used in case of waiting for
// transaction acceptance.
func Context(ctx context.Context) SendFundsOption {
return func(options *SendFundsOptions) error {
options.Context = ctx
return nil
}
}

// AccessManaPledgeID is an option for SendFunds call that defines the nodeID to pledge access mana to.
func AccessManaPledgeID(nodeID string) SendFundsOption {
return func(options *SendFundsOptions) error {
Expand Down Expand Up @@ -143,6 +163,8 @@ type SendFundsOptions struct {
ConsensusManaPledgeID string
WaitForConfirmation bool
UsePendingOutputs bool
SourceAddresses []address.Address
Context context.Context
}

// RequiredFunds derives how much funds are needed based on the Destinations to fund the transfer.
Expand Down
45 changes: 29 additions & 16 deletions client/wallet/wallet.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wallet

import (
"context"
"reflect"
"time"
"unsafe"
Expand Down Expand Up @@ -115,7 +116,7 @@ func (wallet *Wallet) SendFunds(options ...sendoptions.SendFundsOption) (tx *dev
// how much funds will we need to fund this transfer?
requiredFunds := sendOptions.RequiredFunds()
// collect that many outputs for funding
consumedOutputs, err := wallet.collectOutputsForFunding(requiredFunds, sendOptions.UsePendingOutputs)
consumedOutputs, err := wallet.collectOutputsForFunding(requiredFunds, sendOptions.UsePendingOutputs, sendOptions.SourceAddresses...)
if err != nil {
if errors.Is(err, ErrTooManyOutputs) {
err = errors.Errorf("consolidate funds and try again: %w", err)
Expand Down Expand Up @@ -169,7 +170,7 @@ func (wallet *Wallet) SendFunds(options ...sendoptions.SendFundsOption) (tx *dev
return nil, err
}
if sendOptions.WaitForConfirmation {
err = wallet.WaitForTxAcceptance(tx.ID())
err = wallet.WaitForTxAcceptance(tx.ID(), sendOptions.Context)
}

return tx, err
Expand Down Expand Up @@ -1815,20 +1816,30 @@ func (wallet *Wallet) ExportState() []byte {
// region WaitForTxAcceptance //////////////////////////////////////////////////////////////////////////////////////////

// WaitForTxAcceptance waits for the given tx to be accepted.
func (wallet *Wallet) WaitForTxAcceptance(txID utxo.TransactionID) (err error) {
func (wallet *Wallet) WaitForTxAcceptance(txID utxo.TransactionID, optionalCtx ...context.Context) (err error) {
ctx := context.Background()
if len(optionalCtx) == 1 && optionalCtx[0] != nil {
ctx = optionalCtx[0]
}

ticker := time.NewTicker(wallet.ConfirmationPollInterval)
timeoutCounter := time.Duration(0)
for {
time.Sleep(wallet.ConfirmationPollInterval)
timeoutCounter += wallet.ConfirmationPollInterval
confirmationState, fetchErr := wallet.connector.GetTransactionConfirmationState(txID)
if fetchErr != nil {
return fetchErr
}
if confirmationState.IsAccepted() {
return
}
if timeoutCounter > wallet.ConfirmationTimeout {
return errors.Errorf("transaction %s did not confirm within %d seconds", txID.Base58(), wallet.ConfirmationTimeout/time.Second)
select {
case <-ctx.Done():
return errors.Errorf("context cancelled")
case <-ticker.C:
timeoutCounter += wallet.ConfirmationPollInterval
confirmationState, fetchErr := wallet.connector.GetTransactionConfirmationState(txID)
if fetchErr != nil {
return fetchErr
}
if confirmationState.IsAccepted() {
return
}
if timeoutCounter > wallet.ConfirmationTimeout {
return errors.Errorf("transaction %s did not confirm within %d seconds", txID.Base58(), wallet.ConfirmationTimeout/time.Second)
}
}
}
}
Expand Down Expand Up @@ -1968,13 +1979,15 @@ func (wallet *Wallet) findStateControlledAliasOutputByAliasID(id *devnetvm.Alias

// collectOutputsForFunding tries to collect unspent outputs to fund fundingBalance.
// It may collect pending outputs according to flag.
func (wallet *Wallet) collectOutputsForFunding(fundingBalance map[devnetvm.Color]uint64, includePending bool) (OutputsByAddressAndOutputID, error) {
func (wallet *Wallet) collectOutputsForFunding(fundingBalance map[devnetvm.Color]uint64, includePending bool, addresses ...address.Address) (OutputsByAddressAndOutputID, error) {
if fundingBalance == nil {
return nil, errors.Errorf("can't collect fund: empty fundingBalance provided")
}

_ = wallet.outputManager.Refresh()
addresses := wallet.addressManager.Addresses()
if len(addresses) == 0 {
addresses = wallet.addressManager.Addresses()
}
unspentOutputs := wallet.outputManager.UnspentValueOutputs(includePending, addresses...)

collected := make(map[devnetvm.Color]uint64)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ services:
{% endif %}
--autoPeering.entryNodes=
--analysis.client.serverAddress=
--node.disablePlugins=activity,analysisClient,chat,consensus,dashboard,faucet,gossip,firewall,issuer,mana,manualpeering,blockLayer,metrics,networkdelay,portcheck,pow,syncBeaconFollower,webAPIBroadcastDataEndpoint,WebAPIDataEndpoint,WebAPIHealthzEndpoint,WebAPIFaucetRequestEndpoint,webAPIFindTransactionHashesEndpoint,webAPIGetNeighborsEndpoint,webAPIGetTransactionObjectsByHashEndpoint,webAPIGetTransactionTrytesByHashEndpoint,WebAPIInfoEndpoint,WebAPILedgerstateEndpoint,WebAPIBlockEndpoint,WebAPIToolsBlockEndpoint,WebAPIWeightProviderEndpoint,remotelog,remotelogmetrics,DAGsVisualizer,WebAPIRateSetterEndpoint,WebAPISchedulerEndpoint,ManaInitializer,Notarization,EpochStorage,WebAPIEpochEndpoint,BootstrapManager
--node.disablePlugins=activity,analysisClient,chat,consensus,dashboard,faucet,gossip,firewall,issuer,mana,manualpeering,blockLayer,metrics,networkdelay,portcheck,pow,syncBeaconFollower,webAPIBroadcastDataEndpoint,WebAPIDataEndpoint,WebAPIHealthzEndpoint,WebAPIFaucetRequestEndpoint,webAPIFindTransactionHashesEndpoint,webAPIGetNeighborsEndpoint,webAPIGetTransactionObjectsByHashEndpoint,webAPIGetTransactionTrytesByHashEndpoint,WebAPIInfoEndpoint,WebAPILedgerstateEndpoint,WebAPIBlockEndpoint,WebAPIToolsBlockEndpoint,WebAPIWeightProviderEndpoint,remotelog,remotelogmetrics,DAGsVisualizer,WebAPIRateSetterEndpoint,WebAPISchedulerEndpoint,ManaInitializer,Notarization,EpochStorage,WebAPIEpochEndpoint,BootstrapManager,Warpsync,Snapshot
--logger.level={{ logLevel }}
--logger.outputPaths=stdout
20 changes: 11 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ require (
github.com/gin-gonic/gin v1.7.7
github.com/go-resty/resty/v2 v2.6.0
github.com/gorilla/websocket v1.5.0
github.com/iotaledger/hive.go/core v0.0.0-20220804174551-efbca20a83e4
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-20220804174551-efbca20a83e4
github.com/iotaledger/hive.go/core v1.0.0-beta.3.0.20220825155653-0a69188181ca
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-beta.2.0.20220825155653-0a69188181ca
github.com/labstack/echo v3.3.10+incompatible
github.com/labstack/gommon v0.3.0
github.com/libp2p/go-libp2p v0.15.0
github.com/libp2p/go-libp2p-core v0.9.0
github.com/libp2p/go-yamux/v2 v2.2.0
github.com/magiconair/properties v1.8.6
github.com/markbates/pkger v0.17.1
github.com/mr-tron/base58 v1.2.0
github.com/multiformats/go-multiaddr v0.4.1
github.com/multiformats/go-varint v0.0.6
github.com/panjf2000/ants/v2 v2.5.0
github.com/paulbellamy/ratecounter v0.2.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.1
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible
github.com/spf13/pflag v1.0.5
Expand All @@ -52,6 +52,7 @@ require (
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/ethereum/go-ethereum v1.10.21 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
Expand All @@ -64,13 +65,14 @@ require (
github.com/go-stack/stack v1.8.0 // indirect
github.com/gobuffalo/here v0.6.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gohornet/grocksdb v1.7.1-0.20220426081058-60f50d7c59e8 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huin/goupnp v1.0.2 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/iotaledger/grocksdb v1.7.5-0.20220808142449-1dc0b8ac4d7d // indirect
github.com/ipfs/go-cid v0.0.7 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-log v1.0.5 // indirect
Expand Down Expand Up @@ -123,6 +125,7 @@ require (
github.com/libp2p/go-stream-muxer-multistream v0.3.0 // indirect
github.com/libp2p/go-tcp-transport v0.2.8 // indirect
github.com/libp2p/go-ws-transport v0.5.0 // indirect
github.com/libp2p/go-yamux/v2 v2.2.0 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
Expand Down Expand Up @@ -151,7 +154,6 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/petermattis/goid v0.0.0-20220712135657-ac599d9cba15 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.30.0 // indirect
Expand Down Expand Up @@ -180,10 +182,10 @@ require (
go.dedis.ch/fixbuf v1.0.3 // indirect
go.mongodb.org/mongo-driver v1.5.1 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/net v0.0.0-20220802222814-0bcc04d9c69b // indirect
go.uber.org/zap v1.22.0 // indirect
golang.org/x/net v0.0.0-20220809012201-f428fae20770 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.0.0-20220803195053-6e608f9ce704 // indirect
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
Expand Down
Loading

0 comments on commit 622d1d5

Please sign in to comment.