Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge/foundation release/1.10.2 resolved #357

Merged
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
1826708
params: begin v1.10.2 release cycle
karalabe Mar 8, 2021
be87f76
core/types: reduce allocations in GasPriceCmp (#22456)
MariusVanDerWijden Mar 8, 2021
3d299b7
les: fix errors in metric namespace (#22459)
holiman Mar 9, 2021
22082f9
cmd: extend dumpgenesis to support network flags on the cmd (#22406)
rjl493456442 Mar 9, 2021
aae7660
p2p/enr: fix decoding of incomplete lists (#22484)
fjl Mar 11, 2021
6387c52
cmd/geth: add ancient datadir flag to snapshot subcommands (#22486)
michael1011 Mar 12, 2021
3f74c8e
cmd/devp2p: better testcase failure output for ethtests (#22482)
holiman Mar 13, 2021
c6d4500
eth, les: properly init statedb accesslist during tracing (#22480)
holiman Mar 14, 2021
faacc8e
cmd/geth, eth/downloader: remove copydb command (#22501)
holiman Mar 15, 2021
bc47993
tests/fuzzers: fix goroutine leak in les fuzzer (#22455)
holiman Mar 16, 2021
9983072
core/types: improve comments in new EIP-2718 code (#22402)
lightclient Mar 16, 2021
7076e8e
cmd/clef: docs - link to ethereum org repo (#22400)
ligi Mar 16, 2021
7cbf1d7
cmd/clef (docs): fix image background (#22399)
ligi Mar 16, 2021
94ab4ea
core/rawdb: fix transaction indexing/unindexing hashing error (#22457)
holiman Mar 16, 2021
62d8022
les: fix UDP connection query (#22451)
zsfelfoldi Mar 16, 2021
6d9707a
les: fix UDP connection query (#22451)
zsfelfoldi Mar 16, 2021
91726e8
les: allow either full enode strings or raw hex ids in the API (#22423)
zsfelfoldi Mar 16, 2021
410089a
eth/protocols/snap, eth/downloader: don't use bloom filter in snap sync
holiman Mar 17, 2021
117fa7d
eth/protocols/snap: fix typo (#22530)
r1cs Mar 19, 2021
6a528fc
cmd/devp2p/internal/ethtest: return request ID in BlockHeaders respon…
renaynay Mar 19, 2021
aa8b218
ethclient: fix error handling for header test (#22514)
meowsbits Mar 19, 2021
38ea7f2
accounts/abi/bind: add NoSend transact option (#22446)
reds Mar 19, 2021
a90861a
go.mod: upgrade goleveldb to commit 64b5b1c (#22436)
ucwong Mar 19, 2021
345890a
go.mod: upgrade goupnp to commit 0ca76305 (#22479)
ucwong Mar 19, 2021
d50e9d2
consensus/ethash: remove unnecessary variable definition (#22512)
jacksoom Mar 19, 2021
e3a3f7c
cmd/devp2p: use AWS-SDK v2 (#22360)
qhenkart Mar 19, 2021
5bc0343
p2p/dnsdisc: fix flaw in dns size calculation (#22533)
holiman Mar 19, 2021
c454717
core: fix potential race in chainIndexerTest (#22346)
s1na Mar 19, 2021
d3040a8
cmd/devp2p/internal/ethtest: skip eth/66 tests when v66 not supported…
renaynay Mar 19, 2021
9429ab1
cmd/devp2p: add flag for AWS region (#22537)
fjl Mar 19, 2021
5bf6612
cmd/devp2p: fix error in updating the cursor when collecting records …
holiman Mar 20, 2021
36b51b8
cmd/devp2p: add old block announcement test to eth test suite (#22474)
renaynay Mar 20, 2021
ec73ec0
cmd/utils: fix compilation issue on openbsd (#22511)
tobias-hildebrandt Mar 20, 2021
eaccdba
core: fix method comment for `txpool.requestReset` (#22543)
derekchiang Mar 22, 2021
aab3560
accounts: eip-712 signing for ledger (#22378)
MrChico Mar 22, 2021
0c70b83
all: add read-only option to database (#22407)
rjl493456442 Mar 22, 2021
8d6cc16
cmd/geth: check block range against chain head in export cmd (#22387)
s1na Mar 22, 2021
a31f6d5
core/state/snapshot: fix panic on missing parent
karalabe Mar 22, 2021
f304290
Merge pull request #22551 from karalabe/snapshot-parent-get-panic
karalabe Mar 22, 2021
477ec75
Merge pull request #22513 from holiman/no_snap_bloom
karalabe Mar 23, 2021
e862cbf
internal/web3ext, node: migrate node admin API (Start|Stop)RPC->HTTP …
meowsbits Mar 23, 2021
5129cdc
cmd/devp2p: skip ENR field tails properly in nodeset filter (#22565)
fjl Mar 24, 2021
15e6c27
p2p: fix minor typo and remove fd parameter in checkInboundConn (#22547)
terasum Mar 24, 2021
ab8fd4d
p2p/dnsdisc: rate limit resolving before checking cache (#22566)
fjl Mar 24, 2021
c5df05b
eth/protocols/snap: fix the flaws in the snap sync (#22553)
rjl493456442 Mar 24, 2021
0fda25e
eth/tracers, core: use scopecontext in tracers, provide statedb in ca…
holiman Mar 25, 2021
497448b
core: fix condition on header verification
holiman Mar 25, 2021
bed74b3
cmd/devp2p: fix comparison of TXT record value (#22572)
fjl Mar 25, 2021
4adf0b9
Merge pull request #22573 from holiman/checkfreq
karalabe Mar 25, 2021
54c0d57
eth: dump rpc gas cap and tx fee cap (#22574)
MariusVanDerWijden Mar 25, 2021
6d7ff6a
eth/protocols, metrics, p2p: add handler performance metrics
karalabe Mar 26, 2021
efe0229
Merge pull request #22581 from karalabe/network-latency-monitoring
karalabe Mar 26, 2021
2550e46
eth/protocols, metrics: use resetting histograms for rare packets
karalabe Mar 26, 2021
6477ea6
Merge pull request #22586 from karalabe/resettting-histogram
karalabe Mar 26, 2021
9557271
eth: fix corner case in sync head determination (#21695)
zouguangxian Mar 26, 2021
cae6b55
cmd/geth, consensus/ethash: add support for --miner.notify.full flag …
fjl Mar 26, 2021
62379f0
metrics/influxdb: don't push empty histograms, no measurement != 0
karalabe Mar 26, 2021
063f78c
Merge pull request #22590 from karalabe/nil-histogram
karalabe Mar 26, 2021
099be04
eth/protocols/snap: add peer id and req id to the timeout logs
karalabe Mar 26, 2021
e7f3962
Merge pull request #22591 from karalabe/snap-detailed-timeout-logs
karalabe Mar 26, 2021
27056f6
cmd/devp2p: update to newer cloudflare API client (#22588)
fjl Mar 26, 2021
76700ac
core/state/pruner: move the compaction out of the pruning procedure (…
rjl493456442 Mar 29, 2021
7644795
eth/protocols/snap: try to prevent requests timing out
holiman Mar 29, 2021
b6912c1
core: add BlockGen.GetBalance method (#22589)
renaynay Mar 29, 2021
24588ba
cmd/puppeth: specify working directory for nodejs 15 (#22549)
MariusVanDerWijden Mar 29, 2021
43a3768
Merge pull request #22596 from holiman/snap_timelimits
karalabe Mar 30, 2021
59ac3c9
cmd/geth: add db dumptrie command (#22563)
holiman Mar 30, 2021
44fe466
core/vm: fix Byzantium address list (#22603)
nebojsa94 Mar 30, 2021
3faae5d
ethstats: avoid creating subscriptions on background goroutine (#22587)
MariusVanDerWijden Mar 30, 2021
61ff3e8
core/state/snapshot, ethdb: track deletions more accurately (#22582)
karalabe Mar 30, 2021
4a37ae5
rpc: tighter shutdown synchronization in client subscription (#22597)
fjl Mar 30, 2021
55300d4
all: fix miner hashRate -> hashrate on API calls
karalabe Mar 31, 2021
73ed689
Merge pull request #22604 from karalabe/hashrate-capitalization-fix
karalabe Mar 31, 2021
c79fc20
core/state/snapshot: fix data race in diff layer (#22540)
fxfactorial Apr 6, 2021
706683e
internal/ethapi: fix eth_chainId method (#22243)
piersy Apr 6, 2021
adf09ae
graphql: add support for tx types and tx access lists (#22491)
AmitBRD Apr 6, 2021
5338ce4
internal/debug: add JSON log format and rename logging flags (#22341)
s1na Apr 6, 2021
95219ae
cmd/utils: move cache sanity check to SetEthConfig (#22510)
petesimard Apr 6, 2021
e275b1a
consensus/ethash: replace a magic number with it's constant (#22618)
Evolution404 Apr 6, 2021
2d89fe0
les: move client pool to les/vflux/server (#22495)
zsfelfoldi Apr 6, 2021
a600dab
eth, les: fix tracers (#22473)
rjl493456442 Apr 7, 2021
9d10856
core, eth, internal/ethapi: create access list RPC API (#22550)
MariusVanDerWijden Apr 7, 2021
2a7c4b6
eth: fix tracing state retrieval if requesting the non-dirty genesis
karalabe Apr 7, 2021
264fff7
Merge pull request #22629 from karalabe/fix-chain-tracing-from-0
karalabe Apr 7, 2021
fd1278b
build: use env-aware bash shebangs for evmc-build scripts
meowsbits Apr 7, 2021
e3ff37c
params: update CHTs for v1.10.2
karalabe Apr 8, 2021
a665f5d
Merge pull request #22632 from karalabe/cht-1.10.2
karalabe Apr 8, 2021
97d11b0
params: release go-ethereum v1.10.2 stable
fjl Apr 8, 2021
f0803ea
Merge remote-tracking branch 'etclabscore/merge/foundation-release/1.…
meowsbits Apr 13, 2021
b4bebbf
Merge branch 'foundation-1.10.2' into merge/foundation-release/1.10.2…
meowsbits Apr 13, 2021
9eebb26
go.mod,go.sum: go get -d ./...
meowsbits Apr 13, 2021
25e2480
go.mod,go.sum: go mod tidy
meowsbits Apr 13, 2021
da22415
core/rawdb: fixup readonly vals for FreezerRemote
meowsbits Apr 13, 2021
56f050a
internal/ethapi: fixup precompiles list construction for config/blocknum
meowsbits Apr 13, 2021
28b9d9a
core/vm: implement missing tracer interface method CapturePreEVM
meowsbits Apr 13, 2021
07981a1
core/vm: remove disused ActivePrecompiles method
meowsbits Apr 13, 2021
6c359f4
cmd/puppeth: rm -rf cmd/puppeth
meowsbits Apr 13, 2021
56a6390
cmd/utils,node: fixup node database freezer remote readonly signature
meowsbits Apr 13, 2021
495beba
consensus/ethash: fixup ethash config construction sytax for test
meowsbits Apr 13, 2021
2495d5d
core/vm, eth/tracers: fix conflicts with Tracer interface
ziogaschr Apr 13, 2021
76cbc9f
eth/tracers: fix tracer related conflicts
ziogaschr Apr 13, 2021
c85f25b
eth/ethconfig: fix failed/broken merge
ziogaschr Apr 13, 2021
c3bcb93
cmd/echaindb: conform to NewLevelDBDatabase readonly mode
ziogaschr Apr 13, 2021
4ce1fd4
core/vm, eth/tracers: fix lint issues on tracers
ziogaschr Apr 13, 2021
75c651f
core: fix remote freezer tests for readonly Database
ziogaschr Apr 13, 2021
8a80969
graphql: fixup core.Genesis -> genesisT.Genesis imports
meowsbits Apr 13, 2021
2541056
graphql: type ChainConfigurator has no field ChainID
meowsbits Apr 13, 2021
fa5deae
core: [PTAL] remove have/want from error string
meowsbits Apr 13, 2021
0a065f5
ethclient: fix TestRPCDiscover test
ziogaschr Apr 14, 2021
b941602
core/vm: apply CREATE|CREATE2 instruction gas usage logic
ziogaschr Apr 14, 2021
caaa353
eth/tracers: continue using returnData in JS tracer CaptureState
ziogaschr Apr 14, 2021
96e61c9
eth/tracers: call_tracer_parity to use the blockNumber passed in result
ziogaschr Apr 15, 2021
82d0101
eth/tracers: use txTraceContext instead of taskExtraContext where pos…
ziogaschr Apr 15, 2021
2d009bd
core: simplify header chain nil check
meowsbits Apr 28, 2021
a7443c0
internal/debug: fix dropped deprecated (legacy) pprof flags
meowsbits Apr 28, 2021
49bd5e7
cmd/geth: add classic,mordor,kotti flags for dbcmd and chaincmd
meowsbits Apr 28, 2021
5527b93
build,cmd/echaindb: rm -rf and uses of echaindb command
meowsbits Apr 28, 2021
4e73750
Merge pull request #366 from etclabscore/merge/foundation-release/1.1…
meowsbits Apr 30, 2021
1ebe01b
Merge branch 'merge/foundation-release/1.10.1-resolved' into merge/fo…
meowsbits May 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type TransactOpts struct {
GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate)

Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)

NoSend bool // Do all transact steps but do not send the transaction
}

// FilterOpts is the collection of options to fine tune filtering for events
Expand Down Expand Up @@ -260,6 +262,9 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
if err != nil {
return nil, err
}
if opts.NoSend {
return signedTx, nil
}
if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil {
return nil, err
}
Expand Down
82 changes: 82 additions & 0 deletions accounts/usbwallet/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ const (
ledgerOpRetrieveAddress ledgerOpcode = 0x02 // Returns the public key and Ethereum address for a given BIP 32 path
ledgerOpSignTransaction ledgerOpcode = 0x04 // Signs an Ethereum transaction after having the user validate the parameters
ledgerOpGetConfiguration ledgerOpcode = 0x06 // Returns specific wallet application configuration
ledgerOpSignTypedMessage ledgerOpcode = 0x0c // Signs an Ethereum message following the EIP 712 specification

ledgerP1DirectlyFetchAddress ledgerParam1 = 0x00 // Return address directly from the wallet
ledgerP1InitTypedMessageData ledgerParam1 = 0x00 // First chunk of Typed Message data
ledgerP1InitTransactionData ledgerParam1 = 0x00 // First transaction data block for signing
ledgerP1ContTransactionData ledgerParam1 = 0x80 // Subsequent transaction data block for signing
ledgerP2DiscardAddressChainCode ledgerParam2 = 0x00 // Do not return the chain code along with the address
Expand Down Expand Up @@ -170,6 +172,24 @@ func (w *ledgerDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio
return w.ledgerSign(path, tx, chainID)
}

// SignTypedMessage implements usbwallet.driver, sending the message to the Ledger and
// waiting for the user to sign or deny the transaction.
//
// Note: this was introduced in the ledger 1.5.0 firmware
func (w *ledgerDriver) SignTypedMessage(path accounts.DerivationPath, domainHash []byte, messageHash []byte) ([]byte, error) {
// If the Ethereum app doesn't run, abort
if w.offline() {
return nil, accounts.ErrWalletClosed
}
// Ensure the wallet is capable of signing the given transaction
if w.version[0] < 1 && w.version[1] < 5 {
//lint:ignore ST1005 brand name displayed on the console
return nil, fmt.Errorf("Ledger version >= 1.5.0 required for EIP-712 signing (found version v%d.%d.%d)", w.version[0], w.version[1], w.version[2])
}
// All infos gathered and metadata checks out, request signing
return w.ledgerSignTypedMessage(path, domainHash, messageHash)
}

// ledgerVersion retrieves the current version of the Ethereum wallet app running
// on the Ledger wallet.
//
Expand Down Expand Up @@ -367,6 +387,68 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
return sender, signed, nil
}

// ledgerSignTypedMessage sends the transaction to the Ledger wallet, and waits for the user
// to confirm or deny the transaction.
//
// The signing protocol is defined as follows:
//
// CLA | INS | P1 | P2 | Lc | Le
// ----+-----+----+-----------------------------+-----+---
// E0 | 0C | 00 | implementation version : 00 | variable | variable
//
// Where the input is:
//
// Description | Length
// -------------------------------------------------+----------
// Number of BIP 32 derivations to perform (max 10) | 1 byte
// First derivation index (big endian) | 4 bytes
// ... | 4 bytes
// Last derivation index (big endian) | 4 bytes
// domain hash | 32 bytes
// message hash | 32 bytes
//
//
//
// And the output data is:
//
// Description | Length
// ------------+---------
// signature V | 1 byte
// signature R | 32 bytes
// signature S | 32 bytes
func (w *ledgerDriver) ledgerSignTypedMessage(derivationPath []uint32, domainHash []byte, messageHash []byte) ([]byte, error) {
// Flatten the derivation path into the Ledger request
path := make([]byte, 1+4*len(derivationPath))
path[0] = byte(len(derivationPath))
for i, component := range derivationPath {
binary.BigEndian.PutUint32(path[1+4*i:], component)
}
// Create the 712 message
payload := append(path, domainHash...)
payload = append(payload, messageHash...)

// Send the request and wait for the response
var (
op = ledgerP1InitTypedMessageData
reply []byte
err error
)

// Send the message over, ensuring it's processed correctly
reply, err = w.ledgerExchange(ledgerOpSignTypedMessage, op, 0, payload)

if err != nil {
return nil, err
}

// Extract the Ethereum signature and do a sanity validation
if len(reply) != crypto.SignatureLength {
return nil, errors.New("reply lacks signature")
}
signature := append(reply[1:], reply[0])
return signature, nil
}

// ledgerExchange performs a data exchange with the Ledger wallet, sending it a
// message and retrieving the response.
//
Expand Down
4 changes: 4 additions & 0 deletions accounts/usbwallet/trezor.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ func (w *trezorDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio
return w.trezorSign(path, tx, chainID)
}

func (w *trezorDriver) SignTypedMessage(path accounts.DerivationPath, domainHash []byte, messageHash []byte) ([]byte, error) {
return nil, accounts.ErrNotSupported
}

// trezorDerive sends a derivation request to the Trezor device and returns the
// Ethereum address located on that path.
func (w *trezorDriver) trezorDerive(derivationPath []uint32) (common.Address, error) {
Expand Down
43 changes: 42 additions & 1 deletion accounts/usbwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ type driver interface {
// SignTx sends the transaction to the USB device and waits for the user to confirm
// or deny the transaction.
SignTx(path accounts.DerivationPath, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error)

SignTypedMessage(path accounts.DerivationPath, messageHash []byte, domainHash []byte) ([]byte, error)
}

// wallet represents the common functionality shared by all USB hardware
Expand Down Expand Up @@ -524,7 +526,46 @@ func (w *wallet) signHash(account accounts.Account, hash []byte) ([]byte, error)

// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
func (w *wallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
return w.signHash(account, crypto.Keccak256(data))

// Unless we are doing 712 signing, simply dispatch to signHash
if !(mimeType == accounts.MimetypeTypedData && len(data) == 66 && data[0] == 0x19 && data[1] == 0x01) {
return w.signHash(account, crypto.Keccak256(data))
}

// dispatch to 712 signing if the mimetype is TypedData and the format matches
w.stateLock.RLock() // Comms have own mutex, this is for the state fields
defer w.stateLock.RUnlock()

// If the wallet is closed, abort
if w.device == nil {
return nil, accounts.ErrWalletClosed
}
// Make sure the requested account is contained within
path, ok := w.paths[account.Address]
if !ok {
return nil, accounts.ErrUnknownAccount
}
// All infos gathered and metadata checks out, request signing
<-w.commsLock
defer func() { w.commsLock <- struct{}{} }()

// Ensure the device isn't screwed with while user confirmation is pending
// TODO(karalabe): remove if hotplug lands on Windows
w.hub.commsLock.Lock()
w.hub.commsPend++
w.hub.commsLock.Unlock()

defer func() {
w.hub.commsLock.Lock()
w.hub.commsPend--
w.hub.commsLock.Unlock()
}()
// Sign the transaction
signature, err := w.driver.SignTypedMessage(path, data[2:34], data[34:66])
if err != nil {
return nil, err
}
return signature, nil
}

// SignDataWithPassphrase implements accounts.Wallet, attempting to sign the given
Expand Down
2 changes: 1 addition & 1 deletion build/aleth-interpreter.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -e

Expand Down
5 changes: 0 additions & 5 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ var (
"COPYING",
executablePath("abigen"),
executablePath("bootnode"),
executablePath("echaindb"),
executablePath("echainspec"),
executablePath("evm"),
executablePath("geth"),
Expand All @@ -93,10 +92,6 @@ var (
BinaryName: "bootnode",
Description: "Ethereum bootnode.",
},
{
BinaryName: "echaindb",
Description: "Developer utility to inspect and manage the chain database",
},
{
BinaryName: "echainspec",
Description: "Developer utility to manage chain external chain configuration",
Expand Down
2 changes: 1 addition & 1 deletion build/evmone.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion build/hera.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion build/ssvm.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion cmd/clef/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -919,4 +919,4 @@ There are a couple of implementation for a UI. We'll try to keep this list up to
| QtSigner| https://github.com/holiman/qtsigner/| Python3/QT-based| :+1:| :+1:| :+1:| :+1:| :+1:| :x: | :+1: (partially)|
| GtkSigner| https://github.com/holiman/gtksigner| Python3/GTK-based| :+1:| :x:| :x:| :+1:| :+1:| :x: | :x: |
| Frame | https://github.com/floating/frame/commits/go-signer| Electron-based| :x:| :x:| :x:| :x:| ?| :x: | :x: |
| Clef UI| https://github.com/kyokan/clef-ui| Golang/QT-based| :+1:| :+1:| :x:| :+1:| :+1:| :x: | :+1: (approve tx only)|
| Clef UI| https://github.com/ethereum/clef-ui| Golang/QT-based| :+1:| :+1:| :x:| :+1:| :+1:| :x: | :+1: (approve tx only)|
Binary file modified cmd/clef/sign_flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions cmd/devp2p/dns_cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package main

import (
"context"
"fmt"
"strings"

Expand Down Expand Up @@ -79,7 +80,7 @@ func (c *cloudflareClient) checkZone(name string) error {
c.zoneID = id
}
log.Info(fmt.Sprintf("Checking Permissions on zone %s", c.zoneID))
zone, err := c.ZoneDetails(c.zoneID)
zone, err := c.ZoneDetails(context.Background(), c.zoneID)
if err != nil {
return err
}
Expand Down Expand Up @@ -112,7 +113,7 @@ func (c *cloudflareClient) uploadRecords(name string, records map[string]string)
records = lrecords

log.Info(fmt.Sprintf("Retrieving existing TXT records on %s", name))
entries, err := c.DNSRecords(c.zoneID, cloudflare.DNSRecord{Type: "TXT"})
entries, err := c.DNSRecords(context.Background(), c.zoneID, cloudflare.DNSRecord{Type: "TXT"})
if err != nil {
return err
}
Expand All @@ -134,14 +135,15 @@ func (c *cloudflareClient) uploadRecords(name string, records map[string]string)
if path != name {
ttl = treeNodeTTL // Max TTL permitted by Cloudflare
}
_, err = c.CreateDNSRecord(c.zoneID, cloudflare.DNSRecord{Type: "TXT", Name: path, Content: val, TTL: ttl})
record := cloudflare.DNSRecord{Type: "TXT", Name: path, Content: val, TTL: ttl}
_, err = c.CreateDNSRecord(context.Background(), c.zoneID, record)
} else if old.Content != val {
// Entry already exists, only change its content.
log.Info(fmt.Sprintf("Updating %s from %q to %q", path, old.Content, val))
old.Content = val
err = c.UpdateDNSRecord(c.zoneID, old.ID, old)
err = c.UpdateDNSRecord(context.Background(), c.zoneID, old.ID, old)
} else {
log.Info(fmt.Sprintf("Skipping %s = %q", path, val))
log.Debug(fmt.Sprintf("Skipping %s = %q", path, val))
}
if err != nil {
return fmt.Errorf("failed to publish %s: %v", path, err)
Expand All @@ -155,7 +157,7 @@ func (c *cloudflareClient) uploadRecords(name string, records map[string]string)
}
// Stale entry, nuke it.
log.Info(fmt.Sprintf("Deleting %s = %q", path, entry.Content))
if err := c.DeleteDNSRecord(c.zoneID, entry.ID); err != nil {
if err := c.DeleteDNSRecord(context.Background(), c.zoneID, entry.ID); err != nil {
return fmt.Errorf("failed to delete %s: %v", path, err)
}
}
Expand Down
Loading