diff --git a/apps/eth/ethrpc/gasprice.go b/apps/eth/ethrpc/gasprice.go index 86fca81f..53692f8e 100644 --- a/apps/eth/ethrpc/gasprice.go +++ b/apps/eth/ethrpc/gasprice.go @@ -263,7 +263,7 @@ func (e *EthAPIBackend) FeeHistory(ctx context.Context, blockCount uint64, lastB reward[rewardIndex], baseFee[rewardIndex], baseFee[rewardIndex+1], gasUsedRatio[rewardIndex] = fees.results.reward, fees.results.baseFee, fees.results.nextBaseFee, fees.results.gasUsedRatio blobGasUsedRatio[rewardIndex], blobBaseFee[rewardIndex], blobBaseFee[rewardIndex+1] = fees.results.blobGasUsedRatio, fees.results.blobBaseFee, fees.results.nextBlobBaseFee } else { - // 如果没有block和error,意味着我们请求到了未来的区块(可能因为重组) + // If there is no block and no error, it means we requested a future block (possibly due to a reorg) if uint64(i) < firstMissing { firstMissing = uint64(i) } diff --git a/apps/eth/test/cmd/erc20/main.go b/apps/eth/test/cmd/erc20/main.go index 917d4526..d39613ca 100644 --- a/apps/eth/test/cmd/erc20/main.go +++ b/apps/eth/test/cmd/erc20/main.go @@ -46,14 +46,14 @@ func main() { log.Println("finish start eth") if err := assertErc20Transfer(context.Background(), evmConfig); err != nil { log.Println(err) - // 停止链 + // Stop the chain if chain != nil { chain.Stop() } os.Exit(1) } log.Println("assert success") - // 停止链 + // Stop the chain if chain != nil { log.Println("stopping eth chain...") chain.Stop() diff --git a/apps/eth/test/cmd/transfer/main.go b/apps/eth/test/cmd/transfer/main.go index 949ac72e..9cb190d9 100644 --- a/apps/eth/test/cmd/transfer/main.go +++ b/apps/eth/test/cmd/transfer/main.go @@ -53,14 +53,14 @@ func main() { } if err := assertEthTransfer(context.Background(), chainID); err != nil { logrus.Info(err) - // 停止链 + // Stop the chain if chain != nil { chain.Stop() } os.Exit(1) } logrus.Info("assert success") - // 停止链 + // Stop the chain if chain != nil { logrus.Info("stopping eth chain...") chain.Stop() diff --git a/apps/eth/test/cmd/uniswap/main.go b/apps/eth/test/cmd/uniswap/main.go index 5f3acc6c..d0ad35a5 100644 --- a/apps/eth/test/cmd/uniswap/main.go +++ b/apps/eth/test/cmd/uniswap/main.go @@ -47,14 +47,14 @@ func main() { logrus.Info("finish start eth") if err := assertUniswapV2(context.Background(), evmConfig.ChainConfig.ChainID.Int64()); err != nil { logrus.Info(err) - // 停止链 + // Stop the chain if chain != nil { chain.Stop() } os.Exit(1) } logrus.Info("assert success") - // 停止链 + // Stop the chain if chain != nil { logrus.Info("stopping eth chain...") chain.Stop() diff --git a/apps/eth/test/uniswap/uniswapV2Accuracy_testcase.go b/apps/eth/test/uniswap/uniswapV2Accuracy_testcase.go index 65c4a18d..5b1a5530 100644 --- a/apps/eth/test/uniswap/uniswapV2Accuracy_testcase.go +++ b/apps/eth/test/uniswap/uniswapV2Accuracy_testcase.go @@ -126,7 +126,7 @@ func (ca *UniswapV2AccuracyTestCase) Run(ctx context.Context, m *pkg.WalletManag retryErrors = append(retryErrors, struct { Nonce int Err error - }{Nonce: int(nonce), Err: err}) // record和 nonce + }{Nonce: int(nonce), Err: err}) // record nonce time.Sleep(retryDelay) } diff --git a/apps/quickstart/chain.go b/apps/quickstart/chain.go index 60184126..171550ff 100644 --- a/apps/quickstart/chain.go +++ b/apps/quickstart/chain.go @@ -17,9 +17,9 @@ func NewQuickStart() *QuickStart { tri := &QuickStart{ tripod.NewTripod(), } - // 此处需要手动将自定义的 Writing 注册到 tripod 中, + // Register custom Writing to the tripod manually tri.SetWritings(tri.WriteA) - // 此处需要手动将自定义的 Reading 注册到 tripod 中 + // Register custom Reading to the tripod manually tri.SetReadings(tri.ReadA) return tri } @@ -29,20 +29,20 @@ type WriteRequest struct { Value string `json:"value"` } -// 此处定制开发一个 Writing -// Writing会被全网节点共识并执行 +// WriteA is a custom Writing handler. +// Writings are executed by consensus across all network nodes. func (q *QuickStart) WriteA(ctx *context.WriteContext) error { - // 设置该 writing 所需消耗的lei (lei和gas同义) + // Set the lei (equivalent to gas) cost for this writing ctx.SetLei(100) - // 解析请求体 + // Parse the request body req := new(WriteRequest) err := ctx.BindJson(req) if err != nil { return err } - // 将数据存入链上状态中。 + // Store data into on-chain state q.Set([]byte(req.Key), []byte(req.Value)) - // 向链外发射一个event + // Emit an event to off-chain listeners ctx.EmitStringEvent("execute success") return nil } @@ -55,7 +55,7 @@ type ReadResponse struct { Value string `json:"value"` } -// 此处定制开发一个 Reading +// ReadA is a custom Reading handler. func (q *QuickStart) ReadA(ctx *context.ReadContext) { req := new(ReadRequest) err := ctx.BindJson(req) @@ -72,9 +72,9 @@ func (q *QuickStart) ReadA(ctx *context.ReadContext) { } func main() { - // 启用poa tripod的默认配置 + // Use the default PoA tripod configuration poaCfg := poa.DefaultCfg(0) - // 启用yu的默认配置 + // Use the default yu kernel configuration yuCfg := startup.InitDefaultKernelConfig() poaTri := poa.NewPoa(poaCfg) diff --git a/apps/vdf/vdf.go b/apps/vdf/vdf.go index caad2019..60b6e837 100644 --- a/apps/vdf/vdf.go +++ b/apps/vdf/vdf.go @@ -8,10 +8,10 @@ import ( ) // ---------------------------- -// 基础工具函数 +// Basic utility functions // ---------------------------- -// hashToPrime 从 N, x, y, t 哈希生成一个确定性的素数 l +// hashToPrime generates a deterministic prime l by hashing N, x, y, t func hashToPrime(N, x, y *big.Int, t uint64, bits int) (*big.Int, error) { h := sha256.New() h.Write(N.Bytes()) @@ -42,13 +42,13 @@ func hashToPrime(N, x, y *big.Int, t uint64, bits int) (*big.Int, error) { } } -// gcd 计算 a,b 的最大公约数 +// gcd computes the greatest common divisor of a and b func gcd(a, b *big.Int) *big.Int { return new(big.Int).GCD(nil, nil, a, b) } -// GenerateRSAmodulus 生成一个 RSA 模数 N = p*q -// 注意:生产环境应使用多方安全生成,否则泄露因子会破坏安全性。 +// GenerateRSAmodulus generates an RSA modulus N = p*q +// Note: production environments should use multi-party secure generation, otherwise leaking factors breaks security. func GenerateRSAmodulus(totalBits int) (*big.Int, error) { if totalBits%2 != 0 { return nil, errors.New("bit length must be even") @@ -66,16 +66,16 @@ func GenerateRSAmodulus(totalBits int) (*big.Int, error) { } // ---------------------------- -// VDF Wesolowski 核心实现 +// VDF Wesolowski core implementation // ---------------------------- -// EvalResult 表示 VDF 的输出结果 +// EvalResult represents the output of a VDF evaluation type EvalResult struct { Y *big.Int // y = x^{2^t} mod N - Pi *big.Int // Wesolowski 证明 π + Pi *big.Int // Wesolowski proof π } -// Eval 计算 VDF 输出与证明 +// Eval computes the VDF output and proof func Eval(x *big.Int, t uint64, N *big.Int, securityBits int) (*EvalResult, error) { xMod := new(big.Int).Mod(x, N) if xMod.Sign() == 0 { @@ -85,14 +85,14 @@ func Eval(x *big.Int, t uint64, N *big.Int, securityBits int) (*EvalResult, erro return nil, errors.New("x not coprime with N") } - // Step 1: 计算 y = x^{2^t} mod N + // Step 1: compute y = x^{2^t} mod N y := new(big.Int).Set(xMod) for i := uint64(0); i < t; i++ { y.Mul(y, y) y.Mod(y, N) } - // Step 2: 生成素数挑战 l + // Step 2: generate prime challenge l l, err := hashToPrime(N, xMod, y, t, securityBits) if err != nil { return nil, err @@ -107,7 +107,7 @@ func Eval(x *big.Int, t uint64, N *big.Int, securityBits int) (*EvalResult, erro return &EvalResult{Y: y, Pi: pi}, nil } -// Verify 验证 Wesolowski 证明 +// Verify verifies the Wesolowski proof func Verify(x, y, pi *big.Int, t uint64, N *big.Int, securityBits int) (bool, error) { xMod := new(big.Int).Mod(x, N) yMod := new(big.Int).Mod(y, N)