Skip to content

Commit

Permalink
Merge pull request #10 from SiaFoundation/nate/update-nodes
Browse files Browse the repository at this point in the history
feat: Update hostd, renterd, and walletd dependencies
  • Loading branch information
n8maninger authored Dec 12, 2024
2 parents d118340 + 6aee83f commit 8d4e2ad
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 65 deletions.
2 changes: 1 addition & 1 deletion api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type (

// A Syncer can connect to other peers and synchronize the blockchain.
Syncer interface {
BroadcastHeader(bh gateway.BlockHeader)
BroadcastHeader(bh types.BlockHeader)
BroadcastTransactionSet(txns []types.Transaction)
BroadcastV2TransactionSet(index types.ChainIndex, txns []types.V2Transaction)
BroadcastV2BlockOutline(bo gateway.V2BlockOutline)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func main() {
defer syncerListener.Close()

_, port, err := net.SplitHostPort(syncerListener.Addr().String())
s := syncer.New(syncerListener, cm, testutil.NewMemPeerStore(), gateway.Header{
s := syncer.New(syncerListener, cm, testutil.NewEphemeralPeerStore(), gateway.Header{
GenesisID: genesis.ID(),
UniqueID: gateway.GenerateUniqueID(),
NetAddress: "127.0.0.1:" + port,
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ go 1.23.1
toolchain go1.23.2

require (
go.sia.tech/core v0.6.2
go.sia.tech/coreutils v0.7.0
go.sia.tech/hostd v1.1.3-0.20241126153600-d590d9259987
go.sia.tech/core v0.7.2-0.20241210224920-0534a5928ddb
go.sia.tech/coreutils v0.7.1-0.20241211045514-6881993d8806
go.sia.tech/hostd v1.1.3-0.20241212215223-9e3440475bed
go.sia.tech/jape v0.12.1
go.sia.tech/renterd v1.1.0-beta.5.0.20241203123141-50c650a896c2
go.sia.tech/walletd v0.8.1-0.20241120185708-2f26e9b843f1
go.sia.tech/renterd v1.1.1-0.20241212160145-9b05f245be23
go.sia.tech/walletd v0.8.1-0.20241210081245-ca3d83da2781
go.uber.org/zap v1.27.0
lukechampine.com/frand v1.5.1
)

require (
github.com/aws/aws-sdk-go v1.55.5 // indirect
github.com/cloudflare/cloudflare-go v0.110.0 // indirect
github.com/cloudflare/cloudflare-go v0.111.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.7 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
Expand All @@ -36,10 +36,10 @@ require (
go.sia.tech/gofakes3 v0.0.5 // indirect
go.sia.tech/mux v1.3.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.8.0 // indirect
golang.org/x/tools v0.23.0 // indirect
)
44 changes: 22 additions & 22 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU=
github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
github.com/cloudflare/cloudflare-go v0.110.0 h1:aBKKUXwRWqErd4rITsnCLESOacxxset/BcpdXn23900=
github.com/cloudflare/cloudflare-go v0.110.0/go.mod h1:2ZZ+EkmThmd6pkZ56UKGXWpz2wsjeqoTg93P4+VSmMg=
github.com/cloudflare/cloudflare-go v0.111.0 h1:bFgl5OyR7iaV9DkTaoI2jU8X4rXDzEaFDaPfMTp+Ewo=
github.com/cloudflare/cloudflare-go v0.111.0/go.mod h1:w5c4Vm00JjZM+W0mPi6QOC+eWLncGQPURtgDck3z5xU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -45,50 +45,50 @@ github.com/shabbyrobe/gocovmerge v0.0.0-20230507112040-c3350d9342df/go.mod h1:dc
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
go.sia.tech/core v0.6.2 h1:8NEjxyD93A+EhZopsBy/LvuHH+zUSjRNKnf9rXgtIwU=
go.sia.tech/core v0.6.2/go.mod h1:4v+aT/33857tMfqa5j5OYlAoLsoIrd4d7qMlgeP+VGk=
go.sia.tech/coreutils v0.7.0 h1:YpgOUD4vrpDz0KC7FJz+UCOaKaqV5EkX3gMUUmJoz5s=
go.sia.tech/coreutils v0.7.0/go.mod h1:eMoqzqO4opKQ6n9tTTxHQmccfNlj+8RFOYuDSL/Qd4g=
go.sia.tech/core v0.7.2-0.20241210224920-0534a5928ddb h1:JHX+qWKS9sAXmEroICAu2jPQkr3CYUF7iWd/zlATsBM=
go.sia.tech/core v0.7.2-0.20241210224920-0534a5928ddb/go.mod h1:tM9tPD+1jp8d+dqVpX6idTyv5RpI0GEh5L5SyuOpqlc=
go.sia.tech/coreutils v0.7.1-0.20241211045514-6881993d8806 h1:zmLtpmFQPKMukYMiQByZzOODvMshriyLhK12BnIsmU8=
go.sia.tech/coreutils v0.7.1-0.20241211045514-6881993d8806/go.mod h1:6z3oHrQqcLoFEAT/l6XnvOivEGXgIfWBKcq0OqsouWA=
go.sia.tech/gofakes3 v0.0.5 h1:vFhVBUFbKE9ZplvLE2w4TQxFMQyF8qvgxV4TaTph+Vw=
go.sia.tech/gofakes3 v0.0.5/go.mod h1:LXEzwGw+OHysWLmagleCttX93cJZlT9rBu/icOZjQ54=
go.sia.tech/hostd v1.1.3-0.20241126153600-d590d9259987 h1:PBPbQ6SyZu9CEMgKo1Vou7PLDIJH4/X1Yoxqf1hPfE8=
go.sia.tech/hostd v1.1.3-0.20241126153600-d590d9259987/go.mod h1:mlX0X3KpJd/YcOSFZdY1HdEma9UHkN1W5OgHYqyVhbU=
go.sia.tech/hostd v1.1.3-0.20241212215223-9e3440475bed h1:C42AxWwwoP13EhZsdWwR17Rc9S7gXI4JnRN0AyZRxc8=
go.sia.tech/hostd v1.1.3-0.20241212215223-9e3440475bed/go.mod h1:6wTgoXKmsLQT22lUcHI4/dUcb3mhXFR+9zYWIki8Qho=
go.sia.tech/jape v0.12.1 h1:xr+o9V8FO8ScRqbSaqYf9bjj1UJ2eipZuNcI1nYousU=
go.sia.tech/jape v0.12.1/go.mod h1:wU+h6Wh5olDjkPXjF0tbZ1GDgoZ6VTi4naFw91yyWC4=
go.sia.tech/mux v1.3.0 h1:hgR34IEkqvfBKUJkAzGi31OADeW2y7D6Bmy/Jcbop9c=
go.sia.tech/mux v1.3.0/go.mod h1:I46++RD4beqA3cW9Xm9SwXbezwPqLvHhVs9HLpDtt58=
go.sia.tech/renterd v1.1.0-beta.5.0.20241203123141-50c650a896c2 h1:NOuw/yVzBKn3hhOK/RJIIsKsLoOI2tzgogu6mjLSfIw=
go.sia.tech/renterd v1.1.0-beta.5.0.20241203123141-50c650a896c2/go.mod h1:TBO18j+T36sPlOdnIndHdLcKiojpXHtyqNYm+CvI0ew=
go.sia.tech/walletd v0.8.1-0.20241120185708-2f26e9b843f1 h1:YWyRj37ZhPsHtLKgJq3gAo0zCWYl3fM24WVIBTS//yA=
go.sia.tech/walletd v0.8.1-0.20241120185708-2f26e9b843f1/go.mod h1:IMK3pD/UVpTHrExrOJLvaNSuE6lJ0pxcAvwpQ977aCM=
go.sia.tech/renterd v1.1.1-0.20241212160145-9b05f245be23 h1:xxQy3FPDEO/QVJqXRVIC9VlkAwUkEwtj6b2HbcyOVo0=
go.sia.tech/renterd v1.1.1-0.20241212160145-9b05f245be23/go.mod h1:DHf0cJuZed56t18XUU73fSYBhzlp6v48XLK4BWLyKWc=
go.sia.tech/walletd v0.8.1-0.20241210081245-ca3d83da2781 h1:3yBtVEHVj9GLZx2OmmaP3CeemZoOCgPWe9fNTzByPrI=
go.sia.tech/walletd v0.8.1-0.20241210081245-ca3d83da2781/go.mod h1:iW50oOq4TJrKC6jyfbiaiiegjzQ8rrKY5lbqwZdpwuY=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20190829051458-42f498d34c4d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand Down
49 changes: 41 additions & 8 deletions nodes/hostd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"go.sia.tech/core/types"
"go.sia.tech/coreutils"
"go.sia.tech/coreutils/chain"
rhp4 "go.sia.tech/coreutils/rhp/v4"
"go.sia.tech/coreutils/syncer"
"go.sia.tech/coreutils/testutil"
"go.sia.tech/coreutils/wallet"
Expand All @@ -38,6 +39,18 @@ import (
"go.uber.org/zap"
)

func parseListenerPort(addr string) (uint16, error) {
_, portStr, err := net.SplitHostPort(addr)
if err != nil {
return 0, fmt.Errorf("failed to split address: %w", err)
}
port, err := strconv.ParseUint(portStr, 10, 16)
if err != nil {
return 0, fmt.Errorf("failed to parse port: %w", err)
}
return uint16(port), nil
}

// StartHostd starts a new hostd node. It listens on random ports and registers
// itself with the Manager. This function blocks until the context is
// canceled. All restources will be cleaned up before the funcion returns.
Expand Down Expand Up @@ -114,10 +127,10 @@ func (m *Manager) StartHostd(ctx context.Context, sk types.PrivateKey, ready cha
if err != nil {
return fmt.Errorf("failed to split syncer address: %w", err)
}
s = syncer.New(syncerListener, cm, testutil.NewMemPeerStore(), gateway.Header{
s = syncer.New(syncerListener, cm, testutil.NewEphemeralPeerStore(), gateway.Header{
GenesisID: genesisIndex.ID,
UniqueID: gateway.GenerateUniqueID(),
NetAddress: "127.0.0.1:" + port,
NetAddress: "127.0.0.1" + port,
}, syncer.WithLogger(log.Named("syncer")),
syncer.WithPeerDiscoveryInterval(5*time.Second),
syncer.WithSyncInterval(5*time.Second),
Expand Down Expand Up @@ -166,22 +179,39 @@ func (m *Manager) StartHostd(ctx context.Context, sk types.PrivateKey, ready cha
}
defer rhp2Listener.Close()

rhp2Port, err := parseListenerPort(rhp2Listener.Addr().String())
if err != nil {
return fmt.Errorf("failed to parse rhp2 port: %w", err)
}

rhp3Listener, err := rhp.Listen("tcp", ":0")
if err != nil {
return fmt.Errorf("failed to listen on rhp3 addr: %w", err)
}
defer rhp3Listener.Close()

_, rhp3PortStr, err := net.SplitHostPort(rhp3Listener.Addr().String())
rhp3Port, err := parseListenerPort(rhp3Listener.Addr().String())
if err != nil {
return fmt.Errorf("failed to split rhp3 address: %w", err)
return fmt.Errorf("failed to parse rhp3 port: %w", err)
}
rhp3Port, err := strconv.ParseUint(rhp3PortStr, 10, 16)

rhp4Listener, err := rhp.Listen("tcp", ":0")
if err != nil {
return fmt.Errorf("failed to parse rhp3 port: %w", err)
return fmt.Errorf("failed to listen on rhp4 addr: %w", err)
}
defer rhp4Listener.Close()

cfm, err := settings.NewConfigManager(sk, store, cm, s, vm, wm, settings.WithAlertManager(am), settings.WithLog(log.Named("settings")), settings.WithValidateNetAddress(false), settings.WithAnnounceInterval(144*30), settings.WithRHP3Port(uint16(rhp3Port)))
rhp4Port, err := parseListenerPort(rhp4Listener.Addr().String())
if err != nil {
return fmt.Errorf("failed to parse rhp4 port: %w", err)
}

cfm, err := settings.NewConfigManager(sk, store, cm, s, vm, wm, settings.WithAlertManager(am), settings.WithLog(log.Named("settings")),
settings.WithValidateNetAddress(false),
settings.WithAnnounceInterval(144*30),
settings.WithRHP2Port(rhp2Port),
settings.WithRHP3Port(rhp3Port),
settings.WithRHP4Port(rhp4Port))
if err != nil {
return fmt.Errorf("failed to create settings manager: %w", err)
}
Expand All @@ -193,7 +223,7 @@ func (m *Manager) StartHostd(ctx context.Context, sk types.PrivateKey, ready cha
settings.StoragePrice = types.Siacoins(1).Div64(4320).Div64(1e9) // 1 SC / TB / Month
settings.CollateralMultiplier = 2
settings.MaxCollateral = types.Siacoins(100000)
settings.NetAddress = rhp2Listener.Addr().String()
settings.NetAddress = "localhost"
if err := cfm.UpdateSettings(settings); err != nil {
return fmt.Errorf("failed to update settings: %w", err)
}
Expand Down Expand Up @@ -227,6 +257,9 @@ func (m *Manager) StartHostd(ctx context.Context, sk types.PrivateKey, ready cha
go rhp3.Serve()
defer rhp3.Close()

rhp4 := rhp4.NewServer(sk, cm, s, contractManager, wm, cfm, vm, rhp4.WithPriceTableValidity(10*time.Minute), rhp4.WithContractProofWindowBuffer(10))
go rhp.ServeRHP4SiaMux(rhp4Listener, rhp4, log.Named("rhp4"))

ex := explorer.New("https://api.siascan.com")
pm, err := pin.NewManager(store, cfm, ex, pin.WithLogger(log.Named("pin")))
if err != nil {
Expand Down
7 changes: 1 addition & 6 deletions nodes/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,7 @@ func (m *Manager) MineBlocks(ctx context.Context, n int, rewardAddress types.Add
}

if b.V2 == nil {
m.syncer.BroadcastHeader(gateway.BlockHeader{
ParentID: b.ParentID,
Nonce: b.Nonce,
Timestamp: b.Timestamp,
MerkleRoot: b.MerkleRoot(),
})
m.syncer.BroadcastHeader(b.Header())
} else {
m.syncer.BroadcastV2BlockOutline(gateway.OutlineBlock(b, m.chain.PoolTransactions(), m.chain.V2PoolTransactions()))
}
Expand Down
17 changes: 4 additions & 13 deletions nodes/mine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package nodes

import (
"context"
"encoding/binary"
"errors"

"go.sia.tech/core/types"
Expand Down Expand Up @@ -50,20 +49,13 @@ func mineBlock(ctx context.Context, cm *chain.Manager, addr types.Address) (type
b.V2.Commitment = cs.Commitment(cs.TransactionsCommitment(b.Transactions, b.V2Transactions()), addr)
}

b.Nonce = 0
buf := make([]byte, 32+8+8+32)
binary.LittleEndian.PutUint64(buf[32:], b.Nonce)
binary.LittleEndian.PutUint64(buf[40:], uint64(b.Timestamp.Unix()))
if b.V2 != nil {
copy(buf[:32], "sia/id/block|")
copy(buf[48:], b.V2.Commitment[:])
} else {
root := b.MerkleRoot()
copy(buf[:32], b.ParentID[:])
copy(buf[48:], root[:])
b.V2.Commitment = cs.Commitment(cs.TransactionsCommitment(b.Transactions, b.V2Transactions()), addr)
}

b.Nonce = 0
factor := cs.NonceFactor()
for types.BlockID(types.HashBytes(buf)).CmpWork(cs.ChildTarget) < 0 {
for b.ID().CmpWork(cs.ChildTarget) < 0 {
select {
case <-ctx.Done():
return types.Block{}, ctx.Err()
Expand All @@ -76,7 +68,6 @@ func mineBlock(ctx context.Context, cm *chain.Manager, addr types.Address) (type
}

b.Nonce += factor
binary.LittleEndian.PutUint64(buf[32:], b.Nonce)
}
return b, nil
}
8 changes: 4 additions & 4 deletions nodes/renterd.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (m *Manager) StartRenterd(ctx context.Context, sk types.PrivateKey, ready c
if err != nil {
return fmt.Errorf("failed to split syncer address: %w", err)
}
s = syncer.New(syncerListener, cm, testutil.NewMemPeerStore(), gateway.Header{
s = syncer.New(syncerListener, cm, testutil.NewEphemeralPeerStore(), gateway.Header{
GenesisID: genesisIndex.ID,
UniqueID: gateway.GenerateUniqueID(),
NetAddress: "127.0.0.1:" + port,
Expand Down Expand Up @@ -338,9 +338,9 @@ func (m *Manager) StartRenterd(ctx context.Context, sk types.PrivateKey, ready c

HostBlockHeightLeeway: 240, // amount of leeway given to host block height

MinPriceTableValidity: 10 * time.Second, // minimum value for price table validity
MinAccountExpiry: time.Hour, // minimum value for account expiry
MinMaxEphemeralAccountBalance: types.Siacoins(1), // 1SC
MinPriceTableValidity: api.DurationMS(10 * time.Second), // minimum value for price table validity
MinAccountExpiry: api.DurationMS(time.Hour), // minimum value for account expiry
MinMaxEphemeralAccountBalance: types.Siacoins(1), // 1SC
})
if err != nil {
return fmt.Errorf("failed to update setting: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion nodes/walletd.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (m *Manager) StartWalletd(ctx context.Context, ready chan<- struct{}) (err
if err != nil {
return fmt.Errorf("failed to split syncer address: %w", err)
}
s = syncer.New(syncerListener, cm, testutil.NewMemPeerStore(), gateway.Header{
s = syncer.New(syncerListener, cm, testutil.NewEphemeralPeerStore(), gateway.Header{
GenesisID: genesisIndex.ID,
UniqueID: gateway.GenerateUniqueID(),
NetAddress: "127.0.0.1:" + port,
Expand Down

0 comments on commit 8d4e2ad

Please sign in to comment.