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

all: fix some typos in comments and names #31023

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ const (
// of starting any background processes such as automatic key derivation.
WalletOpened

// WalletDropped
// WalletDropped is fired when a wallet is removed or disconnected, either via USB
// or due to a filesystem event in the keystore. This event indicates that the wallet
// is no longer available for operations.
WalletDropped
)

Expand Down
1 change: 1 addition & 0 deletions cmd/devp2p/internal/ethtest/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.

package ethtest

import (
Expand Down
18 changes: 9 additions & 9 deletions cmd/devp2p/internal/v4test/discv4tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func PingExtraData(t *utesting.T) {
}
}

// This test sends a PING packet with additional data and wrong 'from' field
// PingExtraDataWrongFrom sends a PING packet with additional data and wrong 'from' field
// and expects a PONG response.
func PingExtraDataWrongFrom(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2)
Expand All @@ -215,7 +215,7 @@ func PingExtraDataWrongFrom(t *utesting.T) {
}
}

// This test sends a PING packet with an expiration in the past.
// PingPastExpiration sends a PING packet with an expiration in the past.
// The remote node should not respond.
func PingPastExpiration(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2)
Expand All @@ -234,7 +234,7 @@ func PingPastExpiration(t *utesting.T) {
}
}

// This test sends an invalid packet. The remote node should not respond.
// WrongPacketType sends an invalid packet. The remote node should not respond.
func WrongPacketType(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2)
defer te.close()
Expand All @@ -252,7 +252,7 @@ func WrongPacketType(t *utesting.T) {
}
}

// This test verifies that the default behaviour of ignoring 'from' fields is unaffected by
// BondThenPingWithWrongFrom verifies that the default behaviour of ignoring 'from' fields is unaffected by
// the bonding process. After bonding, it pings the target with a different from endpoint.
func BondThenPingWithWrongFrom(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2)
Expand Down Expand Up @@ -289,7 +289,7 @@ waitForPong:
}
}

// This test just sends FINDNODE. The remote node should not reply
// FindnodeWithoutEndpointProof sends FINDNODE. The remote node should not reply
// because the endpoint proof has not completed.
func FindnodeWithoutEndpointProof(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2)
Expand Down Expand Up @@ -332,7 +332,7 @@ func BasicFindnode(t *utesting.T) {
}
}

// This test sends an unsolicited NEIGHBORS packet after the endpoint proof, then sends
// UnsolicitedNeighbors sends an unsolicited NEIGHBORS packet after the endpoint proof, then sends
// FINDNODE to read the remote table. The remote node should not return the node contained
// in the unsolicited NEIGHBORS packet.
func UnsolicitedNeighbors(t *utesting.T) {
Expand Down Expand Up @@ -373,7 +373,7 @@ func UnsolicitedNeighbors(t *utesting.T) {
}
}

// This test sends FINDNODE with an expiration timestamp in the past.
// FindnodePastExpiration sends FINDNODE with an expiration timestamp in the past.
// The remote node should not respond.
func FindnodePastExpiration(t *utesting.T) {
te := newTestEnv(Remote, Listen1, Listen2)
Expand Down Expand Up @@ -426,7 +426,7 @@ func bond(t *utesting.T, te *testenv) {
}
}

// This test attempts to perform a traffic amplification attack against a
// FindnodeAmplificationInvalidPongHash attempts to perform a traffic amplification attack against a
// 'victim' endpoint using FINDNODE. In this attack scenario, the attacker
// attempts to complete the endpoint proof non-interactively by sending a PONG
// with mismatching reply token from the 'victim' endpoint. The attack works if
Expand Down Expand Up @@ -478,7 +478,7 @@ func FindnodeAmplificationInvalidPongHash(t *utesting.T) {
}
}

// This test attempts to perform a traffic amplification attack using FINDNODE.
// FindnodeAmplificationWrongIP attempts to perform a traffic amplification attack using FINDNODE.
// The attack works if the remote node does not verify the IP address of FINDNODE
// against the endpoint verification proof done by PING/PONG.
func FindnodeAmplificationWrongIP(t *utesting.T) {
Expand Down
1 change: 0 additions & 1 deletion consensus/clique/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ func (tt *cliqueTest) run(t *testing.T) {
for j := 0; j < len(batches)-1; j++ {
if k, err := chain.InsertChain(batches[j]); err != nil {
t.Fatalf("failed to import batch %d, block %d: %v", j, k, err)
break
}
}
if _, err = chain.InsertChain(batches[len(batches)-1]); err != tt.failure {
Expand Down
2 changes: 1 addition & 1 deletion core/tracing/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ const (
GasChangeCallLeftOverRefunded GasChangeReason = 7
// GasChangeCallContractCreation is the amount of gas that will be burned for a CREATE.
GasChangeCallContractCreation GasChangeReason = 8
// GasChangeContractCreation is the amount of gas that will be burned for a CREATE2.
// GasChangeCallContractCreation2 is the amount of gas that will be burned for a CREATE2.
GasChangeCallContractCreation2 GasChangeReason = 9
// GasChangeCallCodeStorage is the amount of gas that will be charged for code storage.
GasChangeCallCodeStorage GasChangeReason = 10
Expand Down
6 changes: 3 additions & 3 deletions core/txpool/legacypool/legacypool2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ func TestTransactionZAttack(t *testing.T) {
var ivpendingNum int
pendingtxs, _ := pool.Content()
for account, txs := range pendingtxs {
cur_balance := new(big.Int).Set(pool.currentState.GetBalance(account).ToBig())
curBalance := new(big.Int).Set(pool.currentState.GetBalance(account).ToBig())
for _, tx := range txs {
if cur_balance.Cmp(tx.Value()) <= 0 {
if curBalance.Cmp(tx.Value()) <= 0 {
ivpendingNum++
} else {
cur_balance.Sub(cur_balance, tx.Value())
curBalance.Sub(curBalance, tx.Value())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/types/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
depositRequestSize = 192
)

// UnpackIntoDeposit unpacks a serialized DepositEvent.
// DepositLogToRequest unpacks a serialized DepositEvent.
func DepositLogToRequest(data []byte) ([]byte, error) {
if len(data) != 576 {
return nil, fmt.Errorf("deposit wrong length: want 576, have %d", len(data))
Expand Down
6 changes: 3 additions & 3 deletions core/vm/eof_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func validateCode(code []byte, section int, container *Container, jt *JumpTable,
return nil, err
}
case RJUMPV:
max_size := int(code[i+1])
length := max_size + 1
maxSize := int(code[i+1])
length := maxSize + 1
if len(code) <= i+length {
return nil, fmt.Errorf("%w: jump table truncated, op %s, pos %d", errTruncatedImmediate, op, i)
}
Expand All @@ -120,7 +120,7 @@ func validateCode(code []byte, section int, container *Container, jt *JumpTable,
return nil, err
}
}
i += 2 * max_size
i += 2 * maxSize
case CALLF:
arg, _ := parseUint16(code[i+1:])
if arg >= len(container.types) {
Expand Down
5 changes: 3 additions & 2 deletions core/vm/program/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// - There are not package guarantees. We might iterate heavily on this package, and do backwards-incompatible changes without warning
// - There are no quality-guarantees. These utilities may produce evm-code that is non-functional. YMMV.
// - There are no stability-guarantees. The utility will `panic` if the inputs do not align / make sense.

package program

import (
Expand Down Expand Up @@ -204,7 +205,7 @@ func (p *Program) StaticCall(gas *uint256.Int, address, inOffset, inSize, outOff
return p.Op(vm.STATICCALL)
}

// StaticCall is a convenience function to make a callcode. If 'gas' is nil, the opcode GAS will
// CallCode is a convenience function to make a callcode. If 'gas' is nil, the opcode GAS will
// be used to provide all gas.
func (p *Program) CallCode(gas *uint256.Int, address, value, inOffset, inSize, outOffset, outSize any) *Program {
if outOffset == outSize && inSize == outSize && inOffset == outSize {
Expand Down Expand Up @@ -263,7 +264,7 @@ func (p *Program) InputAddressToStack(inputOffset uint32) *Program {
return p.Op(vm.AND)
}

// MStore stores the provided data (into the memory area starting at memStart).
// Mstore stores the provided data (into the memory area starting at memStart).
func (p *Program) Mstore(data []byte, memStart uint32) *Program {
var idx = 0
// We need to store it in chunks of 32 bytes
Expand Down
8 changes: 4 additions & 4 deletions crypto/blake2b/blake2b.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
)

const (
// The blocksize of BLAKE2b in bytes.
// BlockSize the blocksize of BLAKE2b in bytes.
BlockSize = 128
// The hash size of BLAKE2b-512 in bytes.
// Size the hash size of BLAKE2b-512 in bytes.
Size = 64
// The hash size of BLAKE2b-384 in bytes.
// Size384 the hash size of BLAKE2b-384 in bytes.
Size384 = 48
// The hash size of BLAKE2b-256 in bytes.
// Size256 the hash size of BLAKE2b-256 in bytes.
Size256 = 32
)

Expand Down
2 changes: 1 addition & 1 deletion crypto/bn256/gnark/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/consensys/gnark-crypto/ecc/bn254"
)

// Computes the following relation: ∏ᵢ e(Pᵢ, Qᵢ) =? 1
// PairingCheck computes the following relation: ∏ᵢ e(Pᵢ, Qᵢ) =? 1
//
// To explain why gnark returns a (bool, error):
//
Expand Down
12 changes: 6 additions & 6 deletions crypto/ecies/ecies.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ type PublicKey struct {
Params *ECIESParams
}

// Export an ECIES public key as an ECDSA public key.
// ExportECDSA exports an ECIES public key as an ECDSA public key.
func (pub *PublicKey) ExportECDSA() *ecdsa.PublicKey {
return &ecdsa.PublicKey{Curve: pub.Curve, X: pub.X, Y: pub.Y}
}

// Import an ECDSA public key as an ECIES public key.
// ImportECDSAPublic imports an ECDSA public key as an ECIES public key.
func ImportECDSAPublic(pub *ecdsa.PublicKey) *PublicKey {
return &PublicKey{
X: pub.X,
Expand All @@ -81,20 +81,20 @@ type PrivateKey struct {
D *big.Int
}

// Export an ECIES private key as an ECDSA private key.
// ExportECDSA exports an ECIES private key as an ECDSA private key.
func (prv *PrivateKey) ExportECDSA() *ecdsa.PrivateKey {
pub := &prv.PublicKey
pubECDSA := pub.ExportECDSA()
return &ecdsa.PrivateKey{PublicKey: *pubECDSA, D: prv.D}
}

// Import an ECDSA private key as an ECIES private key.
// ImportECDSA imports an ECDSA private key as an ECIES private key.
func ImportECDSA(prv *ecdsa.PrivateKey) *PrivateKey {
pub := ImportECDSAPublic(&prv.PublicKey)
return &PrivateKey{*pub, prv.D}
}

// Generate an elliptic curve public / private keypair. If params is nil,
// GenerateKey generates an elliptic curve public / private keypair. If params is nil,
// the recommended default parameters for the key will be chosen.
func GenerateKey(rand io.Reader, curve elliptic.Curve, params *ECIESParams) (prv *PrivateKey, err error) {
sk, err := ecdsa.GenerateKey(curve, rand)
Expand All @@ -119,7 +119,7 @@ func MaxSharedKeyLength(pub *PublicKey) int {
return (pub.Curve.Params().BitSize + 7) / 8
}

// ECDH key agreement method used to establish secret keys for encryption.
// GenerateShared ECDH key agreement method used to establish secret keys for encryption.
func (prv *PrivateKey) GenerateShared(pub *PublicKey, skLen, macLen int) (sk []byte, err error) {
if prv.PublicKey.Curve != pub.Curve {
return nil, ErrInvalidCurve
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Context struct {
TxHash common.Hash // Hash of the transaction being traced (zero if dangling call)
}

// The set of methods that must be exposed by a tracer
// Tracer represents the set of methods that must be exposed by a tracer
// for it to be available through the RPC interface.
// This involves a method to retrieve results and one to
// stop tracing.
Expand Down
1 change: 1 addition & 0 deletions eth/tracers/internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package internal

import (
Expand Down
3 changes: 2 additions & 1 deletion internal/era/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// along with go-ethereum. If not, see <http//www.gnu.org/licenses/>.

package era

import (
Expand Down
25 changes: 22 additions & 3 deletions internal/jsre/jsre.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,19 @@ type evalReq struct {
done chan bool
}

// runtime must be stopped with Stop() after use and cannot be used after stopping
// New creates and initializes a new JavaScript runtime environment (JSRE).
// The runtime is configured with the provided assetPath for loading scripts and
// an output writer for logging or printing results.
//
// The returned JSRE must be stopped by calling Stop() after use to release resources.
// Attempting to use the JSRE after stopping it will result in undefined behavior.
//
// Parameters:
// - assetPath: The path to the directory containing script assets.
// - output: The writer used for logging or printing runtime output.
//
// Returns:
// - A pointer to the newly created JSRE instance.
func New(assetPath string, output io.Writer) *JSRE {
re := &JSRE{
assetPath: assetPath,
Expand Down Expand Up @@ -251,8 +263,15 @@ func (re *JSRE) Stop(waitForCallbacks bool) {
}
}

// Exec(file) loads and runs the contents of a file
// if a relative path is given, the jsre's assetPath is used
// Exec loads and executes the contents of a JavaScript file.
// If a relative path is provided, the file is resolved relative to the JSRE's assetPath.
// The file is read, compiled, and executed in the JSRE's runtime environment.
//
// Parameters:
// - file: The path to the JavaScript file to execute. Can be an absolute path or relative to assetPath.
//
// Returns:
// - error: An error if the file cannot be read, compiled, or executed.
func (re *JSRE) Exec(file string) error {
code, err := os.ReadFile(common.AbsolutePath(re.assetPath, file))
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/reexec/reexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// we require because of the forking limitations of using Go. Handlers can be
// registered with a name and the argv 0 of the exec of the binary will be used
// to find and execute custom init paths.

package reexec

import (
Expand Down
1 change: 1 addition & 0 deletions metrics/exp/exp.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Hook go-metrics into expvar
// on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler

package exp

import (
Expand Down
2 changes: 1 addition & 1 deletion metrics/gauge_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewRegisteredGaugeInfo(name string, r Registry) *GaugeInfo {
return c
}

// gaugeInfoSnapshot is a read-only copy of another GaugeInfo.
// GaugeInfoSnapshot is a read-only copy of another GaugeInfo.
type GaugeInfoSnapshot GaugeInfoValue

// Value returns the value at the time the snapshot was taken.
Expand Down
2 changes: 1 addition & 1 deletion metrics/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func Log(r Registry, freq time.Duration, l Logger) {
LogScaled(r, freq, time.Nanosecond, l)
}

// Output each metric in the given registry periodically using the given
// LogScaled outputs each metric in the given registry periodically using the given
// logger. Print timings in `scale` units (eg time.Millisecond) rather than nanos.
func LogScaled(r Registry, freq time.Duration, scale time.Duration, l Logger) {
du := float64(scale)
Expand Down
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// <https://github.com/rcrowley/go-metrics>
//
// Coda Hale's original work: <https://github.com/codahale/metrics>

package metrics

import (
Expand Down
6 changes: 3 additions & 3 deletions metrics/resetting_timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ func (t *ResettingTimer) Snapshot() *ResettingTimerSnapshot {
return snapshot
}

// Record the duration of the execution of the given function.
// Time records the duration of the execution of the given function.
func (t *ResettingTimer) Time(f func()) {
ts := time.Now()
f()
t.Update(time.Since(ts))
}

// Record the duration of an event.
// Update records the duration of an event.
func (t *ResettingTimer) Update(d time.Duration) {
if !metricsEnabled {
return
Expand All @@ -71,7 +71,7 @@ func (t *ResettingTimer) Update(d time.Duration) {
t.sum += int64(d)
}

// Record the duration of an event that started at a time and ends now.
// UpdateSince records the duration of an event that started at a time and ends now.
func (t *ResettingTimer) UpdateSince(ts time.Time) {
t.Update(time.Since(ts))
}
Expand Down
Loading