Skip to content
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
2 changes: 1 addition & 1 deletion apps/eth/ethrpc/gasprice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions apps/eth/test/cmd/erc20/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions apps/eth/test/cmd/transfer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions apps/eth/test/cmd/uniswap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion apps/eth/test/uniswap/uniswapV2Accuracy_testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
22 changes: 11 additions & 11 deletions apps/quickstart/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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)
Expand All @@ -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)
Expand Down
24 changes: 12 additions & 12 deletions apps/vdf/vdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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")
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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)
Expand Down
Loading