diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 6d7639844e..4901e40398 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1153,7 +1153,6 @@ func setConsensusEngineConfig(cfg *quaiconfig.Config) { case params.OrchardName: cfg.Progpow.DurationLimit = params.OrchardDurationLimit cfg.Progpow.GasCeil = params.OrchardGasCeil - cfg.Progpow.GasCeil = params.ColosseumGasCeil cfg.Progpow.MinDifficulty = new(big.Int).Div(core.DefaultOrchardGenesisBlock(cfg.ConsensusEngine, cfg.GenesisNonce).Difficulty, common.Big2) case params.LighthouseName: cfg.Progpow.DurationLimit = params.LighthouseDurationLimit diff --git a/common/big.go b/common/big.go index 7485bea178..3626dd51a0 100644 --- a/common/big.go +++ b/common/big.go @@ -22,6 +22,10 @@ import ( "modernc.org/mathutil" ) +const ( + MantBits = 64 +) + // Common big integers often used var ( Big0 = big.NewInt(0) @@ -64,3 +68,12 @@ func EntropyBigBitsToDifficultyBits(bigBits *big.Int) *big.Int { twopowerBits := new(big.Int).Exp(big.NewInt(2), new(big.Int).Div(bigBits, Big2e64), nil) return new(big.Int).Div(Big2e256, twopowerBits) } + +// IntrinsicLogEntropy returns the logarithm of the intrinsic entropy reduction of a PoW hash +func LogBig(diff *big.Int) *big.Int { + diffCopy := new(big.Int).Set(diff) + c, m := mathutil.BinaryLog(diffCopy, MantBits) + bigBits := new(big.Int).Mul(big.NewInt(int64(c)), new(big.Int).Exp(big.NewInt(2), big.NewInt(MantBits), nil)) + bigBits = new(big.Int).Add(bigBits, m) + return bigBits +} diff --git a/common/logistic/logistic.go b/common/logistic/logistic.go new file mode 100644 index 0000000000..030ab3b494 --- /dev/null +++ b/common/logistic/logistic.go @@ -0,0 +1,184 @@ +package logistic + +import ( + "fmt" + "math/big" + + "github.com/dominant-strategies/go-quai/common" + "github.com/dominant-strategies/go-quai/common/math" + "gonum.org/v1/plot" + "gonum.org/v1/plot/plotter" + "gonum.org/v1/plot/vg" +) + +var ( + c_learningRate = big.NewFloat(0.001) + c_epochLength = 100 +) + +// LogisticRegression represents a logistic regression model. +type LogisticRegression struct { + beta0 *big.Float // Model bias (intercept) + beta1 *big.Float // Model weight (slope) +} + +// NewLogisticRegression initializes a new LogisticRegression model. +func NewLogisticRegression(beta0, beta1 *big.Float) *LogisticRegression { + return &LogisticRegression{ + beta0: beta0, + beta1: beta1, + } +} + +// sigmoid computes the sigmoid function. +func sigmoid(z *big.Float) *big.Float { + // Compute exp(-z) + negZ := new(big.Float).Neg(z) + expNegZ := math.EToTheX(negZ) + + // Compute 1 + exp(-z) + denom := new(big.Float).Add(new(big.Float).SetInt(common.Big1), expNegZ) + + // Compute 1 / (1 + exp(-z)) + result := new(big.Float).Quo(new(big.Float).SetInt(common.Big1), denom) + + return result +} + +// Predict computes the probability that the input belongs to class 1. +func (lr *LogisticRegression) Predict(x *big.Float) *big.Float { + // z = beta0 + beta1 * x + beta1x := new(big.Float).Mul(lr.beta1, x) + z := new(big.Float).Add(lr.beta0, beta1x) + + // Apply sigmoid function + return sigmoid(z) +} + +// Train trains the logistic regression model using gradient descent. +func (lr *LogisticRegression) Train(x []*big.Int, y []*big.Int) { + nSamples := len(y) + + var xfloat, yfloat []*big.Float + for i := 0; i < nSamples; i++ { + xfloat = append(xfloat, new(big.Float).SetInt(x[i])) + yfloat = append(yfloat, new(big.Float).SetInt(y[i])) + } + + for epoch := 0; epoch < c_epochLength; epoch++ { + // Initialize gradients + dw := new(big.Float).SetInt(common.Big0) + db := new(big.Float).SetInt(common.Big0) + + // Compute gradients + for i := 0; i < nSamples; i++ { + xi := xfloat[i] + yi := yfloat[i] + pred := lr.Predict(xi) + error := new(big.Float).Sub(pred, yi) + dwTerm := new(big.Float).Mul(error, xi) + dw.Add(dw, dwTerm) + db.Add(db, error) + } + + nSamplesFloat := new(big.Float).SetInt(big.NewInt(int64(nSamples))) //big.NewFloat(float64(nSamples)) + + // Compute gradient averages + dw.Quo(dw, nSamplesFloat) + db.Quo(db, nSamplesFloat) + + // Update weight: beta1 = beta1 - LearningRate * dw + lrUpdateW := new(big.Float).Mul(c_learningRate, dw) + lr.beta1.Sub(lr.beta1, lrUpdateW) + + // Update bias: beta0 = beta0 - LearningRate * db + lrUpdateB := new(big.Float).Mul(c_learningRate, db) + lr.beta0.Sub(lr.beta0, lrUpdateB) + } +} + +// Beta0 returns the model's bias (intercept) term. +func (lr *LogisticRegression) Beta0() *big.Float { + return new(big.Float).Set(lr.beta0) +} + +// Beta1 returns the model's weight (slope) term. +func (lr *LogisticRegression) Beta1() *big.Float { + return new(big.Float).Set(lr.beta1) +} + +// BigBeta0 returns the model's bias (intercept) term. +func (lr *LogisticRegression) BigBeta0() *big.Int { + bigBeta := new(big.Float).Mul(lr.beta0, new(big.Float).SetInt(common.Big2e64)) + bigBetaInt, _ := bigBeta.Int(nil) + return bigBetaInt +} + +// BigBeta1 returns the model's weight (slope) term. +func (lr *LogisticRegression) BigBeta1() *big.Int { + bigBeta := new(big.Float).Mul(lr.beta1, new(big.Float).SetInt(common.Big2e64)) + bigBetaInt, _ := bigBeta.Int(nil) + return bigBetaInt +} + +// Plot the given trained logistic regression values with Beta0 and Beta1 +func (lr *LogisticRegression) PlotSigmoid(xValues, yValues []float64, blockNumber uint64) error { + // Create a new plot + p := plot.New() + + beta0, _ := lr.beta0.Float64() + beta1, _ := lr.beta1.Float64() + + p.Title.Text = fmt.Sprintf("Sigmoid Function: Beta0=%.10f, Beta1=%.10f", beta0, beta1) + p.X.Label.Text = "x" + p.Y.Label.Text = "sigmoid(x)" + + plotValues := make(plotter.XYs, 0) + for i := range xValues { + value := plotter.XY{xValues[i], yValues[i]} + plotValues = append(plotValues, value) + } + + // Create a line plotter with x and y values + line, err := plotter.NewScatter(plotValues) + if err != nil { + return err + } + + // Add the line to the plot + p.Add(line) + + // Create the function to be plotted + sigmoidFunc := plotter.NewFunction(func(x float64) float64 { + result := lr.Predict(big.NewFloat(x)) + resultF, _ := result.Float64() + return resultF + }) + + // Set the style for the function line + sigmoidFunc.Color = plotter.DefaultLineStyle.Color + sigmoidFunc.Width = vg.Points(2) + + // Set the range for x-axis values + // Find the min and max in the xValues + xMin := float64(math.MaxInt64) + xMax := float64(0) + for _, x := range xValues { + if x < xMin { + xMin = x + } else if x > xMax { + xMax = x + } + } + sigmoidFunc.XMin = xMin + sigmoidFunc.XMax = xMax + + p.Add(sigmoidFunc) + + // Save the plot as a PNG image + if err := p.Save(6*vg.Inch, 4*vg.Inch, fmt.Sprintf("sigmoid-%d.png", blockNumber)); err != nil { + return err + } + + return nil +} diff --git a/common/math/big.go b/common/math/big.go index 3ae25337a0..2c2f06de6d 100644 --- a/common/math/big.go +++ b/common/math/big.go @@ -292,3 +292,73 @@ func TwoToTheX(x *big.Float) *big.Float { return result } + +// EToTheX computes the expression 1 + x + (1/2)*x^2 + (1/6)*x^3 + (1/24)*x^4 + (1/120)*x^5 + (1/720)*x^6 + (1/5040)*x^7 +func EToTheX(x *big.Float) *big.Float { + // Set the desired precision + prec := uint(16) // You can adjust the precision as needed + + // Initialize constants with the specified precision + one := new(big.Float).SetPrec(prec).SetInt64(1) + half := new(big.Float).SetPrec(prec).Quo( + new(big.Float).SetPrec(prec).SetInt64(1), + new(big.Float).SetPrec(prec).SetInt64(6), + ) + oneSixth := new(big.Float).SetPrec(prec).Quo( + new(big.Float).SetPrec(prec).SetInt64(1), + new(big.Float).SetPrec(prec).SetInt64(6), + ) + oneTwentyFourth := new(big.Float).SetPrec(prec).Quo( + new(big.Float).SetPrec(prec).SetInt64(1), + new(big.Float).SetPrec(prec).SetInt64(24), + ) + oneOneTwentieth := new(big.Float).SetPrec(prec).Quo( + new(big.Float).SetPrec(prec).SetInt64(1), + new(big.Float).SetPrec(prec).SetInt64(120), + ) + oneOneSevenTwentieth := new(big.Float).SetPrec(prec).Quo( + new(big.Float).SetPrec(prec).SetInt64(1), + new(big.Float).SetPrec(prec).SetInt64(720), + ) + oneFiveThousandFourtieth := new(big.Float).SetPrec(prec).Quo( + new(big.Float).SetPrec(prec).SetInt64(1), + new(big.Float).SetPrec(prec).SetInt64(5040), + ) + + // Compute x^2 + x2 := new(big.Float).SetPrec(prec).Mul(x, x) + + // Compute x^3 + x3 := new(big.Float).SetPrec(prec).Mul(x2, x) + + // Compute x^4 + x4 := new(big.Float).SetPrec(prec).Mul(x3, x) + + // Compute x^5 + x5 := new(big.Float).SetPrec(prec).Mul(x4, x) + + // Compute x^6 + x6 := new(big.Float).SetPrec(prec).Mul(x5, x) + + // Compute x^7 + x7 := new(big.Float).SetPrec(prec).Mul(x6, x) + + // Compute terms + term2 := new(big.Float).SetPrec(prec).Mul(half, x2) // 0.5 * x^2 + term3 := new(big.Float).SetPrec(prec).Mul(oneSixth, x3) // (1/6) * x^3 + term4 := new(big.Float).SetPrec(prec).Mul(oneTwentyFourth, x4) // (1/24) * x^4 + term5 := new(big.Float).SetPrec(prec).Mul(oneOneTwentieth, x5) // (1/120) * x^5 + term6 := new(big.Float).SetPrec(prec).Mul(oneOneSevenTwentieth, x6) // (1/720) * x^6 + term7 := new(big.Float).SetPrec(prec).Mul(oneFiveThousandFourtieth, x7) // (1/5040) * x^7 + + // Sum up the terms: result = 1 + x + term2 + term3 + term4 + result := new(big.Float).SetPrec(prec).Add(one, x) // result = 1 + x + result.Add(result, term2) // result += term2 + result.Add(result, term3) // result += term3 + result.Add(result, term4) // result += term4 + result.Add(result, term5) // result += term5 + result.Add(result, term6) // result += term6 + result.Add(result, term7) // result += term7 + + return result +} diff --git a/common/math/big_test.go b/common/math/big_test.go index 2dbb8ce257..4cef2a9dd6 100644 --- a/common/math/big_test.go +++ b/common/math/big_test.go @@ -384,3 +384,49 @@ func TestTwoToTheX(t *testing.T) { } } } + +func TestEtoTheX(t *testing.T) { + tests := []struct { + x *big.Float + actual *big.Float + }{ + { + x: big.NewFloat(1.625), + actual: big.NewFloat(5.0784190371800815), + }, + { + x: big.NewFloat(0.765), + actual: big.NewFloat(2.1489943746552203), + }, + { + x: big.NewFloat(1.685), + actual: big.NewFloat(5.392450932349507), + }, + { + x: big.NewFloat(2.0), + actual: big.NewFloat(7.38905609893065), + }, + { + x: big.NewFloat(5.5), + actual: big.NewFloat(244.69193226422038), + }, + { + x: big.NewFloat(-0.00000045456), + actual: big.NewFloat(0.9999999999), + }, + { + x: big.NewFloat(0.0), + actual: big.NewFloat(1.0), // e^0 = 1 + }, + } + + for _, test := range tests { + result := EToTheX(test.x) + lowerBound := new(big.Float).Mul(test.actual, big.NewFloat(0.60)) + upperBound := new(big.Float).Mul(test.actual, big.NewFloat(1.40)) + + if result.Cmp(lowerBound) < 0 || result.Cmp(upperBound) > 0 { + t.Errorf("TwoToTheX(%s) = %g, want %g within 40%%", test.x.Text('f', -1), result, test.actual) + } + } +} diff --git a/common/proto_common.pb.go b/common/proto_common.pb.go index 9ffbc5669f..cfb940a644 100644 --- a/common/proto_common.pb.go +++ b/common/proto_common.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 +// protoc-gen-go v1.35.1 // protoc v5.28.2 // source: common/proto_common.proto @@ -30,11 +30,9 @@ type ProtoLocation struct { func (x *ProtoLocation) Reset() { *x = ProtoLocation{} - if protoimpl.UnsafeEnabled { - mi := &file_common_proto_common_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_proto_common_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoLocation) String() string { @@ -45,7 +43,7 @@ func (*ProtoLocation) ProtoMessage() {} func (x *ProtoLocation) ProtoReflect() protoreflect.Message { mi := &file_common_proto_common_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -77,11 +75,9 @@ type ProtoHash struct { func (x *ProtoHash) Reset() { *x = ProtoHash{} - if protoimpl.UnsafeEnabled { - mi := &file_common_proto_common_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_proto_common_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoHash) String() string { @@ -92,7 +88,7 @@ func (*ProtoHash) ProtoMessage() {} func (x *ProtoHash) ProtoReflect() protoreflect.Message { mi := &file_common_proto_common_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -124,11 +120,9 @@ type ProtoHashes struct { func (x *ProtoHashes) Reset() { *x = ProtoHashes{} - if protoimpl.UnsafeEnabled { - mi := &file_common_proto_common_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_proto_common_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoHashes) String() string { @@ -139,7 +133,7 @@ func (*ProtoHashes) ProtoMessage() {} func (x *ProtoHashes) ProtoReflect() protoreflect.Message { mi := &file_common_proto_common_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -171,11 +165,9 @@ type ProtoAddress struct { func (x *ProtoAddress) Reset() { *x = ProtoAddress{} - if protoimpl.UnsafeEnabled { - mi := &file_common_proto_common_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_proto_common_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoAddress) String() string { @@ -186,7 +178,7 @@ func (*ProtoAddress) ProtoMessage() {} func (x *ProtoAddress) ProtoReflect() protoreflect.Message { mi := &file_common_proto_common_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -218,11 +210,9 @@ type ProtoNumber struct { func (x *ProtoNumber) Reset() { *x = ProtoNumber{} - if protoimpl.UnsafeEnabled { - mi := &file_common_proto_common_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_proto_common_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoNumber) String() string { @@ -233,7 +223,7 @@ func (*ProtoNumber) ProtoMessage() {} func (x *ProtoNumber) ProtoReflect() protoreflect.Message { mi := &file_common_proto_common_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -265,11 +255,9 @@ type ProtoLocations struct { func (x *ProtoLocations) Reset() { *x = ProtoLocations{} - if protoimpl.UnsafeEnabled { - mi := &file_common_proto_common_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_proto_common_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoLocations) String() string { @@ -280,7 +268,7 @@ func (*ProtoLocations) ProtoMessage() {} func (x *ProtoLocations) ProtoReflect() protoreflect.Message { mi := &file_common_proto_common_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -367,80 +355,6 @@ func file_common_proto_common_proto_init() { if File_common_proto_common_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_common_proto_common_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*ProtoLocation); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_common_proto_common_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ProtoHash); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_common_proto_common_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*ProtoHashes); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_common_proto_common_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*ProtoAddress); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_common_proto_common_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*ProtoNumber); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_common_proto_common_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*ProtoLocations); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/consensus/misc/rewards.go b/consensus/misc/rewards.go index 7bad9c4b66..04794573cd 100644 --- a/consensus/misc/rewards.go +++ b/consensus/misc/rewards.go @@ -3,42 +3,98 @@ package misc import ( "math/big" + "github.com/dominant-strategies/go-quai/common" + "github.com/dominant-strategies/go-quai/consensus" "github.com/dominant-strategies/go-quai/core/types" + "github.com/dominant-strategies/go-quai/params" + "modernc.org/mathutil" ) -func CalculateReward(header *types.WorkObjectHeader) *big.Int { +func CalculateReward(parent *types.WorkObject, header *types.WorkObjectHeader) *big.Int { if header.PrimaryCoinbase().IsInQiLedgerScope() { - return CalculateQiReward(header) + return CalculateQiReward(parent.WorkObjectHeader()) } else { - return CalculateQuaiReward(header) + return CalculateQuaiReward(parent) } } // Calculate the amount of Quai that Qi can be converted to. Expect the current Header and the Qi amount in "qits", returns the quai amount in "its" -func QiToQuai(currentHeader *types.WorkObjectHeader, qiAmt *big.Int) *big.Int { - quaiPerQi := new(big.Int).Div(CalculateQuaiReward(currentHeader), CalculateQiReward(currentHeader)) - return new(big.Int).Mul(qiAmt, quaiPerQi) +func QiToQuai(parent *types.WorkObject, qiAmt *big.Int) *big.Int { + quaiByQi := new(big.Int).Mul(CalculateQuaiReward(parent), qiAmt) + return new(big.Int).Quo(quaiByQi, CalculateQiReward(parent.WorkObjectHeader())) } // Calculate the amount of Qi that Quai can be converted to. Expect the current Header and the Quai amount in "its", returns the Qi amount in "qits" -func QuaiToQi(currentHeader *types.WorkObjectHeader, quaiAmt *big.Int) *big.Int { - qiPerQuai := new(big.Int).Div(CalculateQiReward(currentHeader), CalculateQuaiReward(currentHeader)) - return new(big.Int).Mul(quaiAmt, qiPerQuai) +func QuaiToQi(header *types.WorkObject, quaiAmt *big.Int) *big.Int { + qiByQuai := new(big.Int).Mul(CalculateQiReward(header.WorkObjectHeader()), quaiAmt) + return new(big.Int).Quo(qiByQuai, CalculateQuaiReward(header)) } // CalculateQuaiReward calculates the quai that can be recieved for mining a block and returns value in its -func CalculateQuaiReward(header *types.WorkObjectHeader) *big.Int { - return big.NewInt(1000000) +// k_quai = state["K Quai"] +// alpha = params["Controller Alpha Parameter"] +// D = spaces[0]["Block Difficulty"] +// D = sum(D) / len(D) +// d1 = D +// d2 = log(D, params["Quai Reward Base Parameter"]) +// x_d = d1 / d2 +// x_b_star = -spaces[1]["Beta"][0] / spaces[1]["Beta"][1] +// k_quai += alpha * (x_b_star / x_d - 1) * k_quai +// spaces = [{"K Qi": state["K Qi"], "K Quai": k_quai}, spaces[1]] +// return spaces +func CalculateKQuai(parent *types.WorkObject, beta0 *big.Int, beta1 *big.Int) *big.Int { + // Set kQuai to the exchange rate from the header + kQuai := new(big.Int).Set(parent.ExchangeRate()) // in Its + + // Calculate log of the difficulty + d2 := LogBig(parent.Difficulty()) + + // Multiply beta0 and d2 + num := new(big.Int).Mul(beta0, d2) + + // Negate num + negnum := new(big.Int).Neg(num) + + // Multiply beta1 and the difficulty + denom := new(big.Int).Mul(beta1, parent.Difficulty()) + + // Divide negnum by denom + frac := new(big.Int).Quo(negnum, denom) + + // Subtract 2^64 from frac + sub := new(big.Int).Sub(frac, common.Big2e64) + + // Multiply sub by kQuai + bykQuai := new(big.Int).Mul(sub, kQuai) + + // Multiply params.OneOverAlpha by 2^64 + divisor := new(big.Int).Mul(params.OneOverAlpha, common.Big2e64) + + // Divide bykQuai by divisor to get the final result + delta := new(big.Int).Quo(bykQuai, divisor) + + final := new(big.Int).Add(kQuai, delta) + + return final } -// CalculateQiReward caculates the qi that can be received for mining a block and returns value in qits -func CalculateQiReward(header *types.WorkObjectHeader) *big.Int { - return big.NewInt(1000) +func CalculateQuaiReward(header *types.WorkObject) *big.Int { + numerator := new(big.Int).Mul(header.ExchangeRate(), LogBig(header.Difficulty())) + reward := new(big.Int).Quo(numerator, common.Big2e64) + if reward.Cmp(common.Big0) == 0 { + reward = big.NewInt(1) + } + return reward } -// CalculateExchangeRate based on the quai to qi and qi to quai exchange rates -func CalculateExchangeRate(quaiToQi *big.Int, qiToQuai *big.Int) *big.Int { - return new(big.Int).Div(quaiToQi, qiToQuai) +// CalculateQiReward caculates the qi that can be received for mining a block and returns value in qits +func CalculateQiReward(header *types.WorkObjectHeader) *big.Int { + diff := header.Difficulty() + qiReward := new(big.Int).Quo(diff, params.OneOverKqi) + if qiReward.Cmp(common.Big0) == 0 { + qiReward = big.NewInt(1) + } + return qiReward } // FindMinDenominations finds the minimum number of denominations to make up the reward @@ -71,3 +127,12 @@ func FindMinDenominations(reward *big.Int) map[uint8]uint64 { } return denominationCount } + +// IntrinsicLogEntropy returns the logarithm of the intrinsic entropy reduction of a PoW hash +func LogBig(diff *big.Int) *big.Int { + diffCopy := new(big.Int).Set(diff) + c, m := mathutil.BinaryLog(diffCopy, consensus.MantBits) + bigBits := new(big.Int).Mul(big.NewInt(int64(c)), new(big.Int).Exp(big.NewInt(2), big.NewInt(consensus.MantBits), nil)) + bigBits = new(big.Int).Add(bigBits, m) + return bigBits +} diff --git a/core/block_validator.go b/core/block_validator.go index 969c868785..f7bd56c708 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -389,7 +389,6 @@ func (v *BlockValidator) ValidateState(block *types.WorkObject, statedb *state.S // to keep the baseline gas close to the provided target, and increase it towards // the target if the baseline gas is lower. func CalcGasLimit(parent *types.WorkObject, gasCeil uint64) uint64 { - return params.MinGasLimit // No Gas for TimeToStartTx days worth of zone blocks, this gives enough time to // onboard new miners into the slice if parent.NumberU64(common.ZONE_CTX) < params.TimeToStartTx { @@ -409,10 +408,7 @@ func CalcGasLimit(parent *types.WorkObject, gasCeil uint64) uint64 { var desiredLimit uint64 percentGasUsed := parent.GasUsed() * 100 / parent.GasLimit() if percentGasUsed > params.PercentGasUsedThreshold { - desiredLimit = CalcGasCeil(parent.NumberU64(common.ZONE_CTX), gasCeil) - if desiredLimit > gasCeil { - desiredLimit = gasCeil - } + desiredLimit = gasCeil if limit+delta > desiredLimit { return desiredLimit } else { @@ -427,14 +423,3 @@ func CalcGasLimit(parent *types.WorkObject, gasCeil uint64) uint64 { } } } - -func CalcGasCeil(blockNumber uint64, gasCeil uint64) uint64 { - if blockNumber < params.GasLimitStepOneBlockThreshold { - return gasCeil / 4 - } else if blockNumber < params.GasLimitStepTwoBlockThreshold { - return gasCeil / 2 - } else if blockNumber < params.GasLimitStepThreeBlockThreshold { - return gasCeil * 3 / 4 - } - return gasCeil -} diff --git a/core/exchange_controller.go b/core/exchange_controller.go new file mode 100644 index 0000000000..d707cea61e --- /dev/null +++ b/core/exchange_controller.go @@ -0,0 +1,140 @@ +package core + +import ( + "errors" + "math/big" + + "github.com/dominant-strategies/go-quai/common" + "github.com/dominant-strategies/go-quai/common/logistic" + "github.com/dominant-strategies/go-quai/consensus/misc" + "github.com/dominant-strategies/go-quai/core/rawdb" + "github.com/dominant-strategies/go-quai/core/types" + "github.com/dominant-strategies/go-quai/params" +) + +// CalculateExchangeRate takes in the parent block and the etxs generated in the +// current block and calculates the new exchange rate +func CalculateExchangeRate(hc *HeaderChain, block *types.WorkObject, newTokenChoiceSet types.TokenChoiceSet) (*big.Int, *big.Float, *big.Float, error) { + + // Read the parents beta values + betas := rawdb.ReadBetas(hc.headerDb, block.Hash()) + if betas == nil { + return nil, nil, nil, errors.New("could not find the betas stored for parent hash") + } + + if block.NumberU64(common.ZONE_CTX) < types.C_tokenChoiceSetSize { + return params.ExchangeRate, betas.Beta0(), betas.Beta1(), nil + } + + // Do the regression to calculate new betas + diff, tokenChoice := SerializeTokenChoiceSet(newTokenChoiceSet) + var exchangeRate *big.Int + + if len(tokenChoice) != 0 { + r := logistic.NewLogisticRegression(betas.Beta0(), betas.Beta1()) + // If parent is genesis, there is nothing to train + exchangeRate = misc.CalculateKQuai(block, r.BigBeta0(), r.BigBeta1()) + + r.Train(diff, tokenChoice) + + return exchangeRate, r.Beta0(), r.Beta1(), nil + } else { + return block.ExchangeRate(), betas.Beta0(), betas.Beta1(), nil + } +} + +// CalculateTokenChoicesSet reads the block token choices set and adds in the +// choices generated in the current block +func CalculateTokenChoicesSet(hc *HeaderChain, block *types.WorkObject, etxs types.Transactions) (types.TokenChoiceSet, error) { + // If the parent is genesis return an empty set + if block.Hash() == hc.config.DefaultGenesisHash { + return types.NewTokenChoiceSet(), nil + } + + // Look up prior tokenChoiceSet and update + parentTokenChoicesSet := rawdb.ReadTokenChoicesSet(hc.headerDb, block.ParentHash(common.ZONE_CTX)) + if parentTokenChoicesSet == nil { + return types.TokenChoiceSet{}, errors.New("cannot find the token choice set for the parent hash") + } + + tokenChoices := types.TokenChoices{Quai: 0, Qi: 0, Diff: block.Difficulty()} + + for _, tx := range etxs { + if types.IsCoinBaseTx(tx) { + if tx.To().IsInQiLedgerScope() { + tokenChoices.Qi++ + } else if tx.To().IsInQuaiLedgerScope() { + tokenChoices.Quai++ + } + } else if types.IsConversionTx(tx) { + if tx.To().IsInQiLedgerScope() { + tokenChoices.Qi += NormalizeConversionValueToBlock(block, tx.Value(), true) + } else if tx.To().IsInQuaiLedgerScope() { + tokenChoices.Quai += NormalizeConversionValueToBlock(block, tx.Value(), false) + } + } + } + + newTokenChoiceSet := types.NewTokenChoiceSet() + + // Until block number 100 is reached, we need to just accumulate to the + // set and then after block 100 we trim and add the new element + if block.NumberU64(common.ZONE_CTX) <= types.C_tokenChoiceSetSize { + if hc.IsGenesisHash(block.ParentHash(common.ZONE_CTX)) { // parent is genesis + newTokenChoiceSet[0] = tokenChoices + } else { + // go through the parent token choice set and copy it to the new + // token choice set + for i, prevTokenChoices := range *parentTokenChoicesSet { + // TODO: can cut this short using parent Number + newTokenChoiceSet[i] = prevTokenChoices + } + // add the elements from the current block at the end + newTokenChoiceSet[block.NumberU64(common.ZONE_CTX)-1] = tokenChoices + } + } else { + // Once block 100 is reached, the first element in the token set has + // to be discarded and the current block elements have to appended + // at the end + for i, prevTokenChoices := range *parentTokenChoicesSet { + if i > 0 { + newTokenChoiceSet[i-1] = prevTokenChoices + } + } + // Last element is set to the current block choices + newTokenChoiceSet[types.C_tokenChoiceSetSize-1] = tokenChoices + } + + return newTokenChoiceSet, nil +} + +func NormalizeConversionValueToBlock(block *types.WorkObject, value *big.Int, chooseQi bool) uint64 { + var reward *big.Int + if chooseQi { + reward = misc.CalculateQiReward(block.WorkObjectHeader()) + } else { + reward = misc.CalculateQuaiReward(block) + } + + numBlocks := int(new(big.Int).Quo(value, reward).Uint64()) + return uint64(numBlocks) +} + +// serialize tokenChoiceSet +func SerializeTokenChoiceSet(tokenChoiceSet types.TokenChoiceSet) ([]*big.Int, []*big.Int) { + var diff []*big.Int + var token []*big.Int + + for _, tokenChoices := range tokenChoiceSet { + for i := 0; i < int(tokenChoices.Quai); i++ { + diff = append(diff, tokenChoices.Diff) + token = append(token, big.NewInt(0)) + } + for i := 0; i < int(tokenChoices.Qi); i++ { + diff = append(diff, tokenChoices.Diff) + token = append(token, big.NewInt(1)) + } + } + + return diff, token +} diff --git a/core/genesis.go b/core/genesis.go index 3245caddb3..bdf4acea6b 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -370,7 +370,7 @@ func DefaultColosseumGenesisBlock(consensusEngine string, genesisNonce uint64) * Nonce: genesisNonce, ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fb"), GasLimit: 5000000, - Difficulty: big.NewInt(1000000000), + Difficulty: big.NewInt(30000000000), } } diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index f900a32695..d39102ba12 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -19,6 +19,7 @@ package rawdb import ( "encoding/binary" "fmt" + "math/big" "sort" "github.com/dominant-strategies/go-quai/common" @@ -1284,6 +1285,89 @@ func WriteMultiSet(db ethdb.KeyValueWriter, blockHash common.Hash, multiSet *mul } } +func ReadTokenChoicesSet(db ethdb.Reader, blockHash common.Hash) *types.TokenChoiceSet { + data, _ := db.Get(tokenChoiceSetKey(blockHash)) + if len(data) == 0 { + return nil + } + protoTokenChoiceSet := new(types.ProtoTokenChoiceSet) + if err := proto.Unmarshal(data, protoTokenChoiceSet); err != nil { + db.Logger().WithField("err", err).Fatal("Failed to unmarshal tokenChoicesSample") + return nil + } + + tokenChoiceSet := new(types.TokenChoiceSet) + if err := tokenChoiceSet.ProtoDecode(protoTokenChoiceSet); err != nil { + db.Logger().WithField("err", err).Fatal("Failed to decode tokenChoicesSample") + return nil + } + return tokenChoiceSet +} + +func WriteTokenChoicesSet(db ethdb.KeyValueWriter, blockHash common.Hash, tokenChoiceSet *types.TokenChoiceSet) error { + protoTokenChoiceSet, err := tokenChoiceSet.ProtoEncode() + if err != nil { + db.Logger().WithField("err", err).Fatal("Failed to encode tokenChoicesSample") + return err + } + data, err := proto.Marshal(protoTokenChoiceSet) + if err != nil { + db.Logger().WithField("err", err).Fatal("Failed to marshal tokenChoicesSample") + return err + } + if err := db.Put(tokenChoiceSetKey(blockHash), data); err != nil { + db.Logger().WithField("err", err).Fatal("Failed to store tokenChoicesSample") + return err + } + return nil +} + +func DeleteTokenChoicesSet(db ethdb.KeyValueWriter, blockHash common.Hash) { + if err := db.Delete(tokenChoiceSetKey(blockHash)); err != nil { + db.Logger().WithField("err", err).Fatal("Failed to delete token choices set key") + } +} + +func ReadBetas(db ethdb.KeyValueReader, blockHash common.Hash) *types.Betas { + data, _ := db.Get(betasKey(blockHash)) + if len(data) == 0 { + return nil + } + protoBetas := new(types.ProtoBetas) + if err := proto.Unmarshal(data, protoBetas); err != nil { + db.Logger().WithField("err", err).Fatal("Failed to unmarshal proto betas") + return nil + } + + betas := new(types.Betas) + if err := betas.ProtoDecode(protoBetas); err != nil { + db.Logger().WithField("err", err).Fatal("Failed to decode betas") + return nil + } + return betas +} + +func WriteBetas(db ethdb.KeyValueWriter, blockHash common.Hash, beta0, beta1 *big.Float) error { + protoBetas, err := types.NewBetas(beta0, beta1).ProtoEncode() + if err != nil { + return err + } + data, err := proto.Marshal(protoBetas) + if err != nil { + return err + } + if err := db.Put(betasKey(blockHash), data); err != nil { + return err + } + return nil +} + +func DeleteBetas(db ethdb.KeyValueWriter, blockHash common.Hash) { + if err := db.Delete(betasKey(blockHash)); err != nil { + db.Logger().WithField("err", err).Fatal("Failed to delete betas") + } +} + func WriteSpentUTXOs(db ethdb.KeyValueWriter, blockHash common.Hash, spentUTXOs []*types.SpentUtxoEntry) error { protoSpentUTXOs := &types.ProtoSpentUTXOs{} for _, utxo := range spentUTXOs { diff --git a/core/rawdb/db.pb.go b/core/rawdb/db.pb.go index 0c54a7f092..0ff70349e8 100644 --- a/core/rawdb/db.pb.go +++ b/core/rawdb/db.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 +// protoc-gen-go v1.35.1 // protoc v5.28.2 // source: core/rawdb/db.proto @@ -31,11 +31,9 @@ type ProtoNumber struct { func (x *ProtoNumber) Reset() { *x = ProtoNumber{} - if protoimpl.UnsafeEnabled { - mi := &file_core_rawdb_db_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_rawdb_db_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoNumber) String() string { @@ -46,7 +44,7 @@ func (*ProtoNumber) ProtoMessage() {} func (x *ProtoNumber) ProtoReflect() protoreflect.Message { mi := &file_core_rawdb_db_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -80,11 +78,9 @@ type ProtoLegacyTxLookupEntry struct { func (x *ProtoLegacyTxLookupEntry) Reset() { *x = ProtoLegacyTxLookupEntry{} - if protoimpl.UnsafeEnabled { - mi := &file_core_rawdb_db_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_rawdb_db_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoLegacyTxLookupEntry) String() string { @@ -95,7 +91,7 @@ func (*ProtoLegacyTxLookupEntry) ProtoMessage() {} func (x *ProtoLegacyTxLookupEntry) ProtoReflect() protoreflect.Message { mi := &file_core_rawdb_db_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -186,32 +182,6 @@ func file_core_rawdb_db_proto_init() { if File_core_rawdb_db_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_core_rawdb_db_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*ProtoNumber); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_rawdb_db_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ProtoLegacyTxLookupEntry); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index 723376d067..8848108f6a 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -85,6 +85,9 @@ var ( processedStatePrefix = []byte("ps") // processedStatePrefix + hash -> boolean multiSetPrefix = []byte("ms") // multiSetPrefix + hash -> multiset UtxoPrefix = []byte("ut") // outpointPrefix + hash -> types.Outpoint + tokenChoicePrefix = []byte("tc") // tokenChoicePrefix + hash -> tokenChoices + betasPrefix = []byte("betas") // tokenChoicePrefix + hash -> tokenChoices + utxoPrefix = []byte("ut") // outpointPrefix + hash -> types.Outpoint spentUTXOsPrefix = []byte("sutxo") // spentUTXOsPrefix + hash -> []types.SpentTxOut trimmedUTXOsPrefix = []byte("tutxo") // trimmedUTXOsPrefix + hash -> []types.SpentTxOut trimDepthsPrefix = []byte("td") // trimDepthsPrefix + hash -> uint64 @@ -370,3 +373,11 @@ func collidingKeysKey(hash common.Hash) []byte { func alreadyPrunedKey(hash common.Hash) []byte { return append(prunedPrefix, hash.Bytes()...) } + +func tokenChoiceSetKey(hash common.Hash) []byte { + return append(tokenChoicePrefix, hash.Bytes()...) +} + +func betasKey(hash common.Hash) []byte { + return append(betasPrefix, hash.Bytes()...) +} diff --git a/core/slice.go b/core/slice.go index 89f1d0bcc0..7f998e667c 100644 --- a/core/slice.go +++ b/core/slice.go @@ -767,6 +767,10 @@ func (sl *Slice) init() error { genesisTermini.SetDomTerminiAtIndex(genesisHash, i) } + rawdb.WriteBetas(sl.sliceDb, genesisHash, big.NewFloat(0.5), big.NewFloat(0.00083222)) + newTokenChoiceSet := types.NewTokenChoiceSet() + rawdb.WriteTokenChoicesSet(sl.sliceDb, genesisHash, &newTokenChoiceSet) + rawdb.WriteTermini(sl.sliceDb, genesisHash, genesisTermini) rawdb.WriteManifest(sl.sliceDb, genesisHash, types.BlockManifest{genesisHash}) @@ -778,6 +782,7 @@ func (sl *Slice) init() error { if err != nil { return err } + // This is just done for the startup process sl.hc.SetCurrentHeader(genesisHeader) @@ -902,9 +907,6 @@ func (sl *Slice) combinePendingHeader(header *types.WorkObject, slPendingHeader combinedPendingHeader.Header().SetThresholdCount(header.ThresholdCount()) combinedPendingHeader.Header().SetEtxEligibleSlices(header.EtxEligibleSlices()) combinedPendingHeader.Header().SetInterlinkRootHash(header.InterlinkRootHash()) - combinedPendingHeader.Header().SetExchangeRate(header.ExchangeRate()) - combinedPendingHeader.Header().SetQiToQuai(header.QiToQuai()) - combinedPendingHeader.Header().SetQuaiToQi(header.QuaiToQi()) } if inSlice { @@ -934,6 +936,9 @@ func (sl *Slice) combinePendingHeader(header *types.WorkObject, slPendingHeader combinedPendingHeader.Header().SetPrimeTerminusHash(header.PrimeTerminusHash()) combinedPendingHeader.Header().SetSecondaryCoinbase(header.SecondaryCoinbase()) combinedPendingHeader.Header().SetExpansionNumber(header.ExpansionNumber()) + combinedPendingHeader.Header().SetExchangeRate(header.ExchangeRate()) + combinedPendingHeader.Header().SetQiToQuai(header.QiToQuai()) + combinedPendingHeader.Header().SetQuaiToQi(header.QuaiToQi()) combinedPendingHeader.Body().SetTransactions(header.Transactions()) combinedPendingHeader.Body().SetOutboundEtxs(header.OutboundEtxs()) diff --git a/core/state_processor.go b/core/state_processor.go index 13d7b1f822..74bcaaa187 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -304,6 +304,9 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty if etxPLimit < params.ETXPLimitMin { etxPLimit = params.ETXPLimitMin } + minimumEtxCount := params.MinEtxCount + maximumEtxCount := params.MaxEtxCount + etxCount := 0 minimumEtxGas := header.GasLimit() / params.MinimumEtxGasDivisor // 20% of the block gas limit maximumEtxGas := minimumEtxGas * params.MaximumEtxGasMultiplier // 40% of the block gas limit totalEtxGas := uint64(0) @@ -352,7 +355,7 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty qiFees.Add(qiFees, fees) // convert the fee to quai - qiTxFeeInQuai := misc.QiToQuai(primeTerminus.WorkObjectHeader(), qiTxFee) + qiTxFeeInQuai := misc.QiToQuai(parent, qiTxFee) // get the gas price by dividing the fee by qiTxGas qiGasPrice := new(big.Int).Div(qiTxFeeInQuai, big.NewInt(int64(types.CalculateBlockQiTxGas(tx, qiScalingFactor, p.hc.NodeLocation())))) if minGasPrice == nil { @@ -391,6 +394,7 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty var receipt *types.Receipt var addReceipt bool if tx.Type() == types.ExternalTxType { + etxCount++ startTimeEtx := time.Now() // ETXs MUST be included in order, so popping the first from the queue must equal the first in the block etx, err := statedb.PopETX() @@ -466,12 +470,14 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty quaiCoinbaseEtxs[coinbaseAddrWithLockup] = tx.Value() // this creates a new *big.Int } } - // subtract the minimum tx gas from the gas pool - if err := gp.SubGas(params.TxGas); err != nil { - return nil, nil, nil, nil, 0, 0, 0, nil, err + if block.NumberU64(common.ZONE_CTX) > params.TimeToStartTx { + // subtract the minimum tx gas from the gas pool + if err := gp.SubGas(params.TxGas); err != nil { + return nil, nil, nil, nil, 0, 0, 0, nil, err + } + *usedGas += params.TxGas + totalEtxGas += params.TxGas } - *usedGas += params.TxGas - totalEtxGas += params.TxGas timeDelta := time.Since(startTimeEtx) timeCoinbase += timeDelta continue @@ -479,11 +485,7 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty if etx.To().IsInQiLedgerScope() { if etx.ETXSender().Location().Equal(*etx.To().Location()) { // Quai->Qi Conversion lock := new(big.Int).Add(header.Number(nodeCtx), new(big.Int).SetUint64(params.ConversionLockPeriod)) - primeTerminus := p.hc.GetHeaderByHash(header.PrimeTerminusHash()) - if primeTerminus == nil { - return nil, nil, nil, nil, 0, 0, 0, nil, fmt.Errorf("could not find prime terminus header %032x", header.PrimeTerminusHash()) - } - value := misc.QuaiToQi(primeTerminus.WorkObjectHeader(), etx.Value()) // convert Quai to Qi + value := etx.Value() txGas := etx.Gas() if txGas < params.TxGas { continue @@ -545,7 +547,7 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty } else { if etx.ETXSender().Location().Equal(*etx.To().Location()) { // Qi->Quai Conversion msg.SetLock(new(big.Int).Add(header.Number(nodeCtx), new(big.Int).SetUint64(params.ConversionLockPeriod))) - msg.SetValue(misc.QiToQuai(primeTerminus.WorkObjectHeader(), etx.Value())) + msg.SetValue(etx.Value()) msg.SetData([]byte{}) // data is not used in conversion p.logger.Infof("Converting Qi to Quai for ETX %032x with value %d lock %d\n", tx.Hash(), msg.Value().Uint64(), msg.Lock().Uint64()) } @@ -624,7 +626,11 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty if etx != nil { etxAvailable = true } - if (etxAvailable && totalEtxGas < minimumEtxGas) || totalEtxGas > maximumEtxGas { + + if block.NumberU64(common.ZONE_CTX) <= params.TimeToStartTx && (etxAvailable && etxCount < minimumEtxCount || etxCount > maximumEtxCount) { + return nil, nil, nil, nil, 0, 0, 0, nil, fmt.Errorf("total number of ETXs %d is not within the range %d to %d", etxCount, minimumEtxCount, maximumEtxCount) + } + if block.NumberU64(common.ZONE_CTX) > params.TimeToStartTx && (etxAvailable && totalEtxGas < minimumEtxGas) || totalEtxGas > maximumEtxGas { p.logger.Errorf("prevInboundEtxs: %d, oldestIndex: %d, etxHash: %s", len(prevInboundEtxs), oldestIndex.Int64(), etx.Hash().Hex()) return nil, nil, nil, nil, 0, 0, 0, nil, fmt.Errorf("total gas used by ETXs %d is not within the range %d to %d", totalEtxGas, minimumEtxGas, maximumEtxGas) } @@ -663,7 +669,7 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty // If the primary coinbase belongs to a ledger and there is no fees // for other ledger, there is no etxs emitted for the other ledger if bytes.Equal(block.PrimaryCoinbase().Bytes(), quaiCoinbase.Bytes()) { - coinbaseReward := misc.CalculateReward(block.WorkObjectHeader()) + coinbaseReward := misc.CalculateReward(parent, block.WorkObjectHeader()) blockReward := new(big.Int).Add(coinbaseReward, quaiFees) coinbaseEtx := types.NewTx(&types.ExternalTx{To: &primaryCoinbase, Gas: params.TxGas, Value: blockReward, EtxType: types.CoinbaseType, OriginatingTxHash: origin, ETXIndex: uint16(len(emittedEtxs)), Sender: primaryCoinbase, Data: []byte{block.Lock()}}) emittedEtxs = append(emittedEtxs, coinbaseEtx) @@ -672,7 +678,7 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty emittedEtxs = append(emittedEtxs, coinbaseEtx) } } else if bytes.Equal(block.PrimaryCoinbase().Bytes(), qiCoinbase.Bytes()) { - coinbaseReward := misc.CalculateReward(block.WorkObjectHeader()) + coinbaseReward := misc.CalculateReward(parent, block.WorkObjectHeader()) blockReward := new(big.Int).Add(coinbaseReward, qiFees) coinbaseEtx := types.NewTx(&types.ExternalTx{To: &primaryCoinbase, Gas: params.TxGas, Value: blockReward, EtxType: types.CoinbaseType, OriginatingTxHash: origin, ETXIndex: uint16(len(emittedEtxs)), Sender: primaryCoinbase, Data: []byte{block.Lock()}}) emittedEtxs = append(emittedEtxs, coinbaseEtx) @@ -683,12 +689,55 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty } // Add an etx for each workshare for it to be rewarded for _, uncle := range block.Uncles() { - reward := misc.CalculateReward(uncle) + reward := misc.CalculateReward(parent, uncle) uncleCoinbase := uncle.PrimaryCoinbase() - emittedEtxs = append(emittedEtxs, types.NewTx(&types.ExternalTx{To: &uncleCoinbase, Gas: params.TxGas, Value: reward, EtxType: types.CoinbaseType, OriginatingTxHash: origin, ETXIndex: uint16(len(emittedEtxs)), Sender: uncleCoinbase, Data: []byte{uncle.Lock()}})) } + updatedTokenChoiceSet, err := CalculateTokenChoicesSet(p.hc, parent, emittedEtxs) + if err != nil { + return nil, nil, nil, nil, 0, 0, 0, nil, err + } + var exchangeRate *big.Int + var beta0, beta1 *big.Float + if parent.NumberU64(common.ZONE_CTX) > params.ControllerKickInBlock { + exchangeRate, beta0, beta1, err = CalculateExchangeRate(p.hc, parent, updatedTokenChoiceSet) + if err != nil { + return nil, nil, nil, nil, 0, 0, 0, nil, err + } + } else { + exchangeRate = parent.ExchangeRate() + betas := rawdb.ReadBetas(p.hc.headerDb, parent.Hash()) + beta0 = betas.Beta0() + beta1 = betas.Beta1() + } + err = rawdb.WriteTokenChoicesSet(batch, block.Hash(), &updatedTokenChoiceSet) + if err != nil { + return nil, nil, nil, nil, 0, 0, 0, nil, err + } + err = rawdb.WriteBetas(batch, block.Hash(), beta0, beta1) + if err != nil { + return nil, nil, nil, nil, 0, 0, 0, nil, err + } + if block.ExchangeRate().Cmp(exchangeRate) != 0 { + return nil, nil, nil, nil, 0, 0, 0, nil, fmt.Errorf("invalid exchange rate used (remote: %d local: %d)", block.ExchangeRate(), exchangeRate) + } + for _, etx := range emittedEtxs { + // If the etx is conversion + if types.IsConversionTx(etx) { + value := etx.Value() + // If to is in Qi, convert the value into Qi + if etx.To().IsInQiLedgerScope() { + value = misc.QuaiToQi(block, value) + } + // If to is in Quai, convert the value into Quai + if etx.To().IsInQuaiLedgerScope() { + value = misc.QiToQuai(block, value) + } + etx.SetValue(value) + } + } + time4 := common.PrettyDuration(time.Since(start)) // Finalize the block, applying any consensus engine specific extras (e.g. block rewards) multiSet, utxoSetSize, err := p.engine.Finalize(p.hc, batch, block, statedb, false, parentUtxoSetSize, utxosCreatedDeleted.UtxosCreatedHashes, utxosCreatedDeleted.UtxosDeletedHashes) @@ -975,7 +1024,7 @@ func ValidateQiTxOutputsAndSignature(tx *types.Transaction, chain ChainContext, return nil, fmt.Errorf("tx %032x has too many ETXs to calculate required gas", tx.Hash()) } minimumFeeInQuai := new(big.Int).Mul(big.NewInt(int64(requiredGas)), currentHeader.BaseFee()) - txFeeInQuai := misc.QiToQuai(primeTerminusHeader.WorkObjectHeader(), txFeeInQit) + txFeeInQuai := misc.QiToQuai(currentHeader, txFeeInQit) if txFeeInQuai.Cmp(minimumFeeInQuai) < 0 { return nil, fmt.Errorf("tx %032x has insufficient fee for base fee, have %d want %d", tx.Hash(), txFeeInQuai.Uint64(), minimumFeeInQuai.Uint64()) } @@ -1210,13 +1259,17 @@ func ProcessQiTx(tx *types.Transaction, chain ChainContext, checkSig bool, isFir return nil, nil, nil, fmt.Errorf("tx %032x has too many ETXs to calculate required gas", tx.Hash()), nil } minimumFeeInQuai := new(big.Int).Mul(big.NewInt(int64(requiredGas)), currentHeader.BaseFee()) - txFeeInQuai := misc.QiToQuai(primeTerminusHeader.WorkObjectHeader(), txFeeInQit) + parent := chain.GetBlockByHash(currentHeader.ParentHash(common.ZONE_CTX)) + if parent == nil { + return nil, nil, nil, fmt.Errorf("parent cannot be found for the block"), nil + } + txFeeInQuai := misc.QiToQuai(parent, txFeeInQit) if txFeeInQuai.Cmp(minimumFeeInQuai) < 0 { return nil, nil, nil, fmt.Errorf("tx %032x has insufficient fee for base fee, have %d want %d", tx.Hash(), txFeeInQuai.Uint64(), minimumFeeInQuai.Uint64()), nil } if conversion { // Since this transaction contains a conversion, the rest of the tx gas is given to conversion - remainingTxFeeInQuai := misc.QiToQuai(primeTerminusHeader.WorkObjectHeader(), txFeeInQit) + remainingTxFeeInQuai := misc.QiToQuai(parent, txFeeInQit) // Fee is basefee * gas, so gas remaining is fee remaining / basefee remainingGas := new(big.Int).Div(remainingTxFeeInQuai, currentHeader.BaseFee()) if remainingGas.Uint64() > (currentHeader.GasLimit() / params.MinimumEtxGasDivisor) { @@ -1394,7 +1447,7 @@ func ApplyTransaction(config *params.ChainConfig, parent *types.WorkObject, pare } } // Convert Qi to Quai - msg.SetValue(misc.QiToQuai(primeTerminus.WorkObjectHeader(), tx.Value())) + msg.SetValue(misc.QiToQuai(parent, tx.Value())) msg.SetData([]byte{}) // data is not used in conversion } // Create a new context to be used in the EVM environment diff --git a/core/types/external_tx.go b/core/types/external_tx.go index 25d0aa43df..1f0917c11f 100644 --- a/core/types/external_tx.go +++ b/core/types/external_tx.go @@ -184,3 +184,7 @@ func (tx *ExternalTx) setEcdsaSignatureValues(chainID, v, r, s *big.Int) { func (tx *ExternalTx) setTo(to common.Address) { tx.To = &to } + +func (tx *ExternalTx) setValue(value *big.Int) { + tx.Value.Set(value) +} diff --git a/core/types/proto_block.pb.go b/core/types/proto_block.pb.go index bd6fd75683..597e0d26a8 100644 --- a/core/types/proto_block.pb.go +++ b/core/types/proto_block.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 +// protoc-gen-go v1.35.1 // protoc v5.28.2 // source: core/types/proto_block.proto @@ -66,11 +66,9 @@ type ProtoHeader struct { func (x *ProtoHeader) Reset() { *x = ProtoHeader{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoHeader) String() string { @@ -81,7 +79,7 @@ func (*ProtoHeader) ProtoMessage() {} func (x *ProtoHeader) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -380,11 +378,9 @@ type ProtoTransaction struct { func (x *ProtoTransaction) Reset() { *x = ProtoTransaction{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoTransaction) String() string { @@ -395,7 +391,7 @@ func (*ProtoTransaction) ProtoMessage() {} func (x *ProtoTransaction) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -581,11 +577,9 @@ type ProtoTransactions struct { func (x *ProtoTransactions) Reset() { *x = ProtoTransactions{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoTransactions) String() string { @@ -596,7 +590,7 @@ func (*ProtoTransactions) ProtoMessage() {} func (x *ProtoTransactions) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -628,11 +622,9 @@ type ProtoHeaders struct { func (x *ProtoHeaders) Reset() { *x = ProtoHeaders{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoHeaders) String() string { @@ -643,7 +635,7 @@ func (*ProtoHeaders) ProtoMessage() {} func (x *ProtoHeaders) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -675,11 +667,9 @@ type ProtoManifest struct { func (x *ProtoManifest) Reset() { *x = ProtoManifest{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoManifest) String() string { @@ -690,7 +680,7 @@ func (*ProtoManifest) ProtoMessage() {} func (x *ProtoManifest) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -722,11 +712,9 @@ type ProtoAccessList struct { func (x *ProtoAccessList) Reset() { *x = ProtoAccessList{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoAccessList) String() string { @@ -737,7 +725,7 @@ func (*ProtoAccessList) ProtoMessage() {} func (x *ProtoAccessList) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -780,11 +768,9 @@ type ProtoWorkObjectHeader struct { func (x *ProtoWorkObjectHeader) Reset() { *x = ProtoWorkObjectHeader{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoWorkObjectHeader) String() string { @@ -795,7 +781,7 @@ func (*ProtoWorkObjectHeader) ProtoMessage() {} func (x *ProtoWorkObjectHeader) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -904,11 +890,9 @@ type ProtoWorkObjectHeaders struct { func (x *ProtoWorkObjectHeaders) Reset() { *x = ProtoWorkObjectHeaders{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoWorkObjectHeaders) String() string { @@ -919,7 +903,7 @@ func (*ProtoWorkObjectHeaders) ProtoMessage() {} func (x *ProtoWorkObjectHeaders) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -956,11 +940,9 @@ type ProtoWorkObjectBody struct { func (x *ProtoWorkObjectBody) Reset() { *x = ProtoWorkObjectBody{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoWorkObjectBody) String() string { @@ -971,7 +953,7 @@ func (*ProtoWorkObjectBody) ProtoMessage() {} func (x *ProtoWorkObjectBody) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1040,11 +1022,9 @@ type ProtoWorkObject struct { func (x *ProtoWorkObject) Reset() { *x = ProtoWorkObject{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoWorkObject) String() string { @@ -1055,7 +1035,7 @@ func (*ProtoWorkObject) ProtoMessage() {} func (x *ProtoWorkObject) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1101,11 +1081,9 @@ type ProtoWorkObjects struct { func (x *ProtoWorkObjects) Reset() { *x = ProtoWorkObjects{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoWorkObjects) String() string { @@ -1116,7 +1094,7 @@ func (*ProtoWorkObjects) ProtoMessage() {} func (x *ProtoWorkObjects) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1148,11 +1126,9 @@ type ProtoWorkObjectBlockView struct { func (x *ProtoWorkObjectBlockView) Reset() { *x = ProtoWorkObjectBlockView{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoWorkObjectBlockView) String() string { @@ -1163,7 +1139,7 @@ func (*ProtoWorkObjectBlockView) ProtoMessage() {} func (x *ProtoWorkObjectBlockView) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1195,11 +1171,9 @@ type ProtoWorkObjectBlocksView struct { func (x *ProtoWorkObjectBlocksView) Reset() { *x = ProtoWorkObjectBlocksView{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoWorkObjectBlocksView) String() string { @@ -1210,7 +1184,7 @@ func (*ProtoWorkObjectBlocksView) ProtoMessage() {} func (x *ProtoWorkObjectBlocksView) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1242,11 +1216,9 @@ type ProtoWorkObjectHeaderView struct { func (x *ProtoWorkObjectHeaderView) Reset() { *x = ProtoWorkObjectHeaderView{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoWorkObjectHeaderView) String() string { @@ -1257,7 +1229,7 @@ func (*ProtoWorkObjectHeaderView) ProtoMessage() {} func (x *ProtoWorkObjectHeaderView) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1289,11 +1261,9 @@ type ProtoWorkObjectShareView struct { func (x *ProtoWorkObjectShareView) Reset() { *x = ProtoWorkObjectShareView{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoWorkObjectShareView) String() string { @@ -1304,7 +1274,7 @@ func (*ProtoWorkObjectShareView) ProtoMessage() {} func (x *ProtoWorkObjectShareView) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1337,11 +1307,9 @@ type ProtoAccessTuple struct { func (x *ProtoAccessTuple) Reset() { *x = ProtoAccessTuple{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoAccessTuple) String() string { @@ -1352,7 +1320,7 @@ func (*ProtoAccessTuple) ProtoMessage() {} func (x *ProtoAccessTuple) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[15] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1397,11 +1365,9 @@ type ProtoReceiptForStorage struct { func (x *ProtoReceiptForStorage) Reset() { *x = ProtoReceiptForStorage{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoReceiptForStorage) String() string { @@ -1412,7 +1378,7 @@ func (*ProtoReceiptForStorage) ProtoMessage() {} func (x *ProtoReceiptForStorage) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[16] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1486,11 +1452,9 @@ type ProtoReceiptsForStorage struct { func (x *ProtoReceiptsForStorage) Reset() { *x = ProtoReceiptsForStorage{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoReceiptsForStorage) String() string { @@ -1501,7 +1465,7 @@ func (*ProtoReceiptsForStorage) ProtoMessage() {} func (x *ProtoReceiptsForStorage) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[17] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1535,11 +1499,9 @@ type ProtoLogForStorage struct { func (x *ProtoLogForStorage) Reset() { *x = ProtoLogForStorage{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoLogForStorage) String() string { @@ -1550,7 +1512,7 @@ func (*ProtoLogForStorage) ProtoMessage() {} func (x *ProtoLogForStorage) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[18] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1596,11 +1558,9 @@ type ProtoLogsForStorage struct { func (x *ProtoLogsForStorage) Reset() { *x = ProtoLogsForStorage{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoLogsForStorage) String() string { @@ -1611,7 +1571,7 @@ func (*ProtoLogsForStorage) ProtoMessage() {} func (x *ProtoLogsForStorage) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[19] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1644,11 +1604,9 @@ type ProtoPendingHeader struct { func (x *ProtoPendingHeader) Reset() { *x = ProtoPendingHeader{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoPendingHeader) String() string { @@ -1659,7 +1617,7 @@ func (*ProtoPendingHeader) ProtoMessage() {} func (x *ProtoPendingHeader) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[20] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1699,11 +1657,9 @@ type ProtoTermini struct { func (x *ProtoTermini) Reset() { *x = ProtoTermini{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoTermini) String() string { @@ -1714,7 +1670,7 @@ func (*ProtoTermini) ProtoMessage() {} func (x *ProtoTermini) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[21] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1753,11 +1709,9 @@ type ProtoEtxSet struct { func (x *ProtoEtxSet) Reset() { *x = ProtoEtxSet{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoEtxSet) String() string { @@ -1768,7 +1722,7 @@ func (*ProtoEtxSet) ProtoMessage() {} func (x *ProtoEtxSet) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[22] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1801,11 +1755,9 @@ type ProtoPendingEtxs struct { func (x *ProtoPendingEtxs) Reset() { *x = ProtoPendingEtxs{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoPendingEtxs) String() string { @@ -1816,7 +1768,7 @@ func (*ProtoPendingEtxs) ProtoMessage() {} func (x *ProtoPendingEtxs) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[23] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1856,11 +1808,9 @@ type ProtoPendingEtxsRollup struct { func (x *ProtoPendingEtxsRollup) Reset() { *x = ProtoPendingEtxsRollup{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoPendingEtxsRollup) String() string { @@ -1871,7 +1821,7 @@ func (*ProtoPendingEtxsRollup) ProtoMessage() {} func (x *ProtoPendingEtxsRollup) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[24] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1910,11 +1860,9 @@ type ProtoTxIns struct { func (x *ProtoTxIns) Reset() { *x = ProtoTxIns{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoTxIns) String() string { @@ -1925,7 +1873,7 @@ func (*ProtoTxIns) ProtoMessage() {} func (x *ProtoTxIns) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[25] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1957,11 +1905,9 @@ type ProtoTxOuts struct { func (x *ProtoTxOuts) Reset() { *x = ProtoTxOuts{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[26] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoTxOuts) String() string { @@ -1972,7 +1918,7 @@ func (*ProtoTxOuts) ProtoMessage() {} func (x *ProtoTxOuts) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[26] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2005,11 +1951,9 @@ type ProtoTxIn struct { func (x *ProtoTxIn) Reset() { *x = ProtoTxIn{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[27] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoTxIn) String() string { @@ -2020,7 +1964,7 @@ func (*ProtoTxIn) ProtoMessage() {} func (x *ProtoTxIn) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[27] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2060,11 +2004,9 @@ type ProtoOutPoint struct { func (x *ProtoOutPoint) Reset() { *x = ProtoOutPoint{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[28] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoOutPoint) String() string { @@ -2075,7 +2017,7 @@ func (*ProtoOutPoint) ProtoMessage() {} func (x *ProtoOutPoint) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[28] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2116,11 +2058,9 @@ type ProtoTxOut struct { func (x *ProtoTxOut) Reset() { *x = ProtoTxOut{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[29] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoTxOut) String() string { @@ -2131,7 +2071,7 @@ func (*ProtoTxOut) ProtoMessage() {} func (x *ProtoTxOut) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[29] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2179,11 +2119,9 @@ type ProtoOutPointAndDenomination struct { func (x *ProtoOutPointAndDenomination) Reset() { *x = ProtoOutPointAndDenomination{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[30] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoOutPointAndDenomination) String() string { @@ -2194,7 +2132,7 @@ func (*ProtoOutPointAndDenomination) ProtoMessage() {} func (x *ProtoOutPointAndDenomination) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[30] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2240,11 +2178,9 @@ type ProtoAddressOutPoints struct { func (x *ProtoAddressOutPoints) Reset() { *x = ProtoAddressOutPoints{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[31] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoAddressOutPoints) String() string { @@ -2255,7 +2191,7 @@ func (*ProtoAddressOutPoints) ProtoMessage() {} func (x *ProtoAddressOutPoints) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[31] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2287,11 +2223,9 @@ type ProtoOutPointsMap struct { func (x *ProtoOutPointsMap) Reset() { *x = ProtoOutPointsMap{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[32] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoOutPointsMap) String() string { @@ -2302,7 +2236,7 @@ func (*ProtoOutPointsMap) ProtoMessage() {} func (x *ProtoOutPointsMap) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[32] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2335,11 +2269,9 @@ type ProtoSpentUTXO struct { func (x *ProtoSpentUTXO) Reset() { *x = ProtoSpentUTXO{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[33] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoSpentUTXO) String() string { @@ -2350,7 +2282,7 @@ func (*ProtoSpentUTXO) ProtoMessage() {} func (x *ProtoSpentUTXO) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[33] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2389,11 +2321,9 @@ type ProtoSpentUTXOs struct { func (x *ProtoSpentUTXOs) Reset() { *x = ProtoSpentUTXOs{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[34] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[34] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoSpentUTXOs) String() string { @@ -2404,7 +2334,7 @@ func (*ProtoSpentUTXOs) ProtoMessage() {} func (x *ProtoSpentUTXOs) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[34] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2436,11 +2366,9 @@ type ProtoKeys struct { func (x *ProtoKeys) Reset() { *x = ProtoKeys{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[35] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[35] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoKeys) String() string { @@ -2451,7 +2379,7 @@ func (*ProtoKeys) ProtoMessage() {} func (x *ProtoKeys) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[35] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2483,11 +2411,9 @@ type ProtoTrimDepths struct { func (x *ProtoTrimDepths) Reset() { *x = ProtoTrimDepths{} - if protoimpl.UnsafeEnabled { - mi := &file_core_types_proto_block_proto_msgTypes[36] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_types_proto_block_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoTrimDepths) String() string { @@ -2498,7 +2424,7 @@ func (*ProtoTrimDepths) ProtoMessage() {} func (x *ProtoTrimDepths) ProtoReflect() protoreflect.Message { mi := &file_core_types_proto_block_proto_msgTypes[36] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2520,6 +2446,210 @@ func (x *ProtoTrimDepths) GetTrimDepths() map[uint32]uint64 { return nil } +type ProtoTokenChoiceSet struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TokenChoiceArray []*ProtoTokenChoiceArray `protobuf:"bytes,1,rep,name=token_choice_array,json=tokenChoiceArray,proto3" json:"token_choice_array,omitempty"` +} + +func (x *ProtoTokenChoiceSet) Reset() { + *x = ProtoTokenChoiceSet{} + mi := &file_core_types_proto_block_proto_msgTypes[37] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ProtoTokenChoiceSet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProtoTokenChoiceSet) ProtoMessage() {} + +func (x *ProtoTokenChoiceSet) ProtoReflect() protoreflect.Message { + mi := &file_core_types_proto_block_proto_msgTypes[37] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProtoTokenChoiceSet.ProtoReflect.Descriptor instead. +func (*ProtoTokenChoiceSet) Descriptor() ([]byte, []int) { + return file_core_types_proto_block_proto_rawDescGZIP(), []int{37} +} + +func (x *ProtoTokenChoiceSet) GetTokenChoiceArray() []*ProtoTokenChoiceArray { + if x != nil { + return x.TokenChoiceArray + } + return nil +} + +type ProtoTokenChoiceArray struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TokenChoices *ProtoTokenChoice `protobuf:"bytes,1,opt,name=token_choices,json=tokenChoices,proto3,oneof" json:"token_choices,omitempty"` +} + +func (x *ProtoTokenChoiceArray) Reset() { + *x = ProtoTokenChoiceArray{} + mi := &file_core_types_proto_block_proto_msgTypes[38] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ProtoTokenChoiceArray) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProtoTokenChoiceArray) ProtoMessage() {} + +func (x *ProtoTokenChoiceArray) ProtoReflect() protoreflect.Message { + mi := &file_core_types_proto_block_proto_msgTypes[38] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProtoTokenChoiceArray.ProtoReflect.Descriptor instead. +func (*ProtoTokenChoiceArray) Descriptor() ([]byte, []int) { + return file_core_types_proto_block_proto_rawDescGZIP(), []int{38} +} + +func (x *ProtoTokenChoiceArray) GetTokenChoices() *ProtoTokenChoice { + if x != nil { + return x.TokenChoices + } + return nil +} + +type ProtoTokenChoice struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Quai uint64 `protobuf:"varint,1,opt,name=quai,proto3" json:"quai,omitempty"` + Qi uint64 `protobuf:"varint,2,opt,name=qi,proto3" json:"qi,omitempty"` + Diff []byte `protobuf:"bytes,3,opt,name=diff,proto3" json:"diff,omitempty"` // big.Int as bytes +} + +func (x *ProtoTokenChoice) Reset() { + *x = ProtoTokenChoice{} + mi := &file_core_types_proto_block_proto_msgTypes[39] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ProtoTokenChoice) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProtoTokenChoice) ProtoMessage() {} + +func (x *ProtoTokenChoice) ProtoReflect() protoreflect.Message { + mi := &file_core_types_proto_block_proto_msgTypes[39] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProtoTokenChoice.ProtoReflect.Descriptor instead. +func (*ProtoTokenChoice) Descriptor() ([]byte, []int) { + return file_core_types_proto_block_proto_rawDescGZIP(), []int{39} +} + +func (x *ProtoTokenChoice) GetQuai() uint64 { + if x != nil { + return x.Quai + } + return 0 +} + +func (x *ProtoTokenChoice) GetQi() uint64 { + if x != nil { + return x.Qi + } + return 0 +} + +func (x *ProtoTokenChoice) GetDiff() []byte { + if x != nil { + return x.Diff + } + return nil +} + +type ProtoBetas struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Beta0 []byte `protobuf:"bytes,1,opt,name=beta0,proto3" json:"beta0,omitempty"` + Beta1 []byte `protobuf:"bytes,2,opt,name=beta1,proto3" json:"beta1,omitempty"` +} + +func (x *ProtoBetas) Reset() { + *x = ProtoBetas{} + mi := &file_core_types_proto_block_proto_msgTypes[40] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ProtoBetas) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProtoBetas) ProtoMessage() {} + +func (x *ProtoBetas) ProtoReflect() protoreflect.Message { + mi := &file_core_types_proto_block_proto_msgTypes[40] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProtoBetas.ProtoReflect.Descriptor instead. +func (*ProtoBetas) Descriptor() ([]byte, []int) { + return file_core_types_proto_block_proto_rawDescGZIP(), []int{40} +} + +func (x *ProtoBetas) GetBeta0() []byte { + if x != nil { + return x.Beta0 + } + return nil +} + +func (x *ProtoBetas) GetBeta1() []byte { + if x != nil { + return x.Beta1 + } + return nil +} + var File_core_types_proto_block_proto protoreflect.FileDescriptor var file_core_types_proto_block_proto_rawDesc = []byte{ @@ -3062,11 +3192,33 @@ var file_core_types_proto_block_proto_rawDesc = []byte{ 0x1a, 0x3d, 0x0a, 0x0f, 0x54, 0x72, 0x69, 0x6d, 0x44, 0x65, 0x70, 0x74, 0x68, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, - 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, - 0x6d, 0x69, 0x6e, 0x61, 0x6e, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x69, 0x65, - 0x73, 0x2f, 0x67, 0x6f, 0x2d, 0x71, 0x75, 0x61, 0x69, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, - 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, + 0x61, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x43, 0x68, 0x6f, + 0x69, 0x63, 0x65, 0x53, 0x65, 0x74, 0x12, 0x4a, 0x0a, 0x12, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, + 0x63, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x5f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x43, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x41, 0x72, 0x72, 0x61, 0x79, + 0x52, 0x10, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x43, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x41, 0x72, 0x72, + 0x61, 0x79, 0x22, 0x6c, 0x0a, 0x15, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x43, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x41, 0x0a, 0x0d, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x63, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x43, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x48, 0x00, 0x52, 0x0c, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x43, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x88, 0x01, 0x01, 0x42, 0x10, + 0x0a, 0x0e, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x63, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x73, + 0x22, 0x4a, 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x43, 0x68, + 0x6f, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x71, 0x75, 0x61, 0x69, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x04, 0x71, 0x75, 0x61, 0x69, 0x12, 0x0e, 0x0a, 0x02, 0x71, 0x69, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x71, 0x69, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x69, 0x66, 0x66, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x69, 0x66, 0x66, 0x22, 0x38, 0x0a, 0x0a, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x65, 0x74, 0x61, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x65, + 0x74, 0x61, 0x30, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x65, 0x74, 0x61, 0x30, + 0x12, 0x14, 0x0a, 0x05, 0x62, 0x65, 0x74, 0x61, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x05, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x6d, 0x69, 0x6e, 0x61, 0x6e, 0x74, 0x2d, 0x73, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x69, 0x65, 0x73, 0x2f, 0x67, 0x6f, 0x2d, 0x71, 0x75, 0x61, 0x69, + 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -3081,7 +3233,7 @@ func file_core_types_proto_block_proto_rawDescGZIP() []byte { return file_core_types_proto_block_proto_rawDescData } -var file_core_types_proto_block_proto_msgTypes = make([]protoimpl.MessageInfo, 40) +var file_core_types_proto_block_proto_msgTypes = make([]protoimpl.MessageInfo, 44) var file_core_types_proto_block_proto_goTypes = []any{ (*ProtoHeader)(nil), // 0: block.ProtoHeader (*ProtoTransaction)(nil), // 1: block.ProtoTransaction @@ -3120,53 +3272,57 @@ var file_core_types_proto_block_proto_goTypes = []any{ (*ProtoSpentUTXOs)(nil), // 34: block.ProtoSpentUTXOs (*ProtoKeys)(nil), // 35: block.ProtoKeys (*ProtoTrimDepths)(nil), // 36: block.ProtoTrimDepths - nil, // 37: block.ProtoAddressOutPoints.OutPointsEntry - nil, // 38: block.ProtoOutPointsMap.EntriesEntry - nil, // 39: block.ProtoTrimDepths.TrimDepthsEntry - (*common.ProtoHash)(nil), // 40: common.ProtoHash - (*common.ProtoLocation)(nil), // 41: common.ProtoLocation - (*common.ProtoAddress)(nil), // 42: common.ProtoAddress - (*common.ProtoHashes)(nil), // 43: common.ProtoHashes + (*ProtoTokenChoiceSet)(nil), // 37: block.ProtoTokenChoiceSet + (*ProtoTokenChoiceArray)(nil), // 38: block.ProtoTokenChoiceArray + (*ProtoTokenChoice)(nil), // 39: block.ProtoTokenChoice + (*ProtoBetas)(nil), // 40: block.ProtoBetas + nil, // 41: block.ProtoAddressOutPoints.OutPointsEntry + nil, // 42: block.ProtoOutPointsMap.EntriesEntry + nil, // 43: block.ProtoTrimDepths.TrimDepthsEntry + (*common.ProtoHash)(nil), // 44: common.ProtoHash + (*common.ProtoLocation)(nil), // 45: common.ProtoLocation + (*common.ProtoAddress)(nil), // 46: common.ProtoAddress + (*common.ProtoHashes)(nil), // 47: common.ProtoHashes } var file_core_types_proto_block_proto_depIdxs = []int32{ - 40, // 0: block.ProtoHeader.parent_hash:type_name -> common.ProtoHash - 40, // 1: block.ProtoHeader.uncle_hash:type_name -> common.ProtoHash - 40, // 2: block.ProtoHeader.evm_root:type_name -> common.ProtoHash - 40, // 3: block.ProtoHeader.tx_hash:type_name -> common.ProtoHash - 40, // 4: block.ProtoHeader.outbound_etx_hash:type_name -> common.ProtoHash - 40, // 5: block.ProtoHeader.etx_rollup_hash:type_name -> common.ProtoHash - 40, // 6: block.ProtoHeader.manifest_hash:type_name -> common.ProtoHash - 40, // 7: block.ProtoHeader.receipt_hash:type_name -> common.ProtoHash - 41, // 8: block.ProtoHeader.location:type_name -> common.ProtoLocation - 40, // 9: block.ProtoHeader.mix_hash:type_name -> common.ProtoHash - 40, // 10: block.ProtoHeader.utxo_root:type_name -> common.ProtoHash - 40, // 11: block.ProtoHeader.etx_set_root:type_name -> common.ProtoHash - 40, // 12: block.ProtoHeader.etx_eligible_slices:type_name -> common.ProtoHash - 40, // 13: block.ProtoHeader.prime_terminus_hash:type_name -> common.ProtoHash - 40, // 14: block.ProtoHeader.interlink_root_hash:type_name -> common.ProtoHash + 44, // 0: block.ProtoHeader.parent_hash:type_name -> common.ProtoHash + 44, // 1: block.ProtoHeader.uncle_hash:type_name -> common.ProtoHash + 44, // 2: block.ProtoHeader.evm_root:type_name -> common.ProtoHash + 44, // 3: block.ProtoHeader.tx_hash:type_name -> common.ProtoHash + 44, // 4: block.ProtoHeader.outbound_etx_hash:type_name -> common.ProtoHash + 44, // 5: block.ProtoHeader.etx_rollup_hash:type_name -> common.ProtoHash + 44, // 6: block.ProtoHeader.manifest_hash:type_name -> common.ProtoHash + 44, // 7: block.ProtoHeader.receipt_hash:type_name -> common.ProtoHash + 45, // 8: block.ProtoHeader.location:type_name -> common.ProtoLocation + 44, // 9: block.ProtoHeader.mix_hash:type_name -> common.ProtoHash + 44, // 10: block.ProtoHeader.utxo_root:type_name -> common.ProtoHash + 44, // 11: block.ProtoHeader.etx_set_root:type_name -> common.ProtoHash + 44, // 12: block.ProtoHeader.etx_eligible_slices:type_name -> common.ProtoHash + 44, // 13: block.ProtoHeader.prime_terminus_hash:type_name -> common.ProtoHash + 44, // 14: block.ProtoHeader.interlink_root_hash:type_name -> common.ProtoHash 5, // 15: block.ProtoTransaction.access_list:type_name -> block.ProtoAccessList - 40, // 16: block.ProtoTransaction.originating_tx_hash:type_name -> common.ProtoHash + 44, // 16: block.ProtoTransaction.originating_tx_hash:type_name -> common.ProtoHash 25, // 17: block.ProtoTransaction.tx_ins:type_name -> block.ProtoTxIns 26, // 18: block.ProtoTransaction.tx_outs:type_name -> block.ProtoTxOuts - 40, // 19: block.ProtoTransaction.parent_hash:type_name -> common.ProtoHash - 40, // 20: block.ProtoTransaction.mix_hash:type_name -> common.ProtoHash + 44, // 19: block.ProtoTransaction.parent_hash:type_name -> common.ProtoHash + 44, // 20: block.ProtoTransaction.mix_hash:type_name -> common.ProtoHash 1, // 21: block.ProtoTransactions.transactions:type_name -> block.ProtoTransaction 0, // 22: block.ProtoHeaders.headers:type_name -> block.ProtoHeader - 40, // 23: block.ProtoManifest.manifest:type_name -> common.ProtoHash + 44, // 23: block.ProtoManifest.manifest:type_name -> common.ProtoHash 15, // 24: block.ProtoAccessList.access_tuples:type_name -> block.ProtoAccessTuple - 40, // 25: block.ProtoWorkObjectHeader.header_hash:type_name -> common.ProtoHash - 40, // 26: block.ProtoWorkObjectHeader.parent_hash:type_name -> common.ProtoHash - 40, // 27: block.ProtoWorkObjectHeader.tx_hash:type_name -> common.ProtoHash - 41, // 28: block.ProtoWorkObjectHeader.location:type_name -> common.ProtoLocation - 40, // 29: block.ProtoWorkObjectHeader.mix_hash:type_name -> common.ProtoHash - 42, // 30: block.ProtoWorkObjectHeader.primary_coinbase:type_name -> common.ProtoAddress + 44, // 25: block.ProtoWorkObjectHeader.header_hash:type_name -> common.ProtoHash + 44, // 26: block.ProtoWorkObjectHeader.parent_hash:type_name -> common.ProtoHash + 44, // 27: block.ProtoWorkObjectHeader.tx_hash:type_name -> common.ProtoHash + 45, // 28: block.ProtoWorkObjectHeader.location:type_name -> common.ProtoLocation + 44, // 29: block.ProtoWorkObjectHeader.mix_hash:type_name -> common.ProtoHash + 46, // 30: block.ProtoWorkObjectHeader.primary_coinbase:type_name -> common.ProtoAddress 6, // 31: block.ProtoWorkObjectHeaders.wo_headers:type_name -> block.ProtoWorkObjectHeader 0, // 32: block.ProtoWorkObjectBody.header:type_name -> block.ProtoHeader 2, // 33: block.ProtoWorkObjectBody.transactions:type_name -> block.ProtoTransactions 7, // 34: block.ProtoWorkObjectBody.uncles:type_name -> block.ProtoWorkObjectHeaders 2, // 35: block.ProtoWorkObjectBody.outbound_etxs:type_name -> block.ProtoTransactions 4, // 36: block.ProtoWorkObjectBody.manifest:type_name -> block.ProtoManifest - 43, // 37: block.ProtoWorkObjectBody.interlink_hashes:type_name -> common.ProtoHashes + 47, // 37: block.ProtoWorkObjectBody.interlink_hashes:type_name -> common.ProtoHashes 6, // 38: block.ProtoWorkObject.wo_header:type_name -> block.ProtoWorkObjectHeader 8, // 39: block.ProtoWorkObject.wo_body:type_name -> block.ProtoWorkObjectBody 1, // 40: block.ProtoWorkObject.tx:type_name -> block.ProtoTransaction @@ -3175,19 +3331,19 @@ var file_core_types_proto_block_proto_depIdxs = []int32{ 11, // 43: block.ProtoWorkObjectBlocksView.work_objects:type_name -> block.ProtoWorkObjectBlockView 9, // 44: block.ProtoWorkObjectHeaderView.work_object:type_name -> block.ProtoWorkObject 9, // 45: block.ProtoWorkObjectShareView.work_object:type_name -> block.ProtoWorkObject - 40, // 46: block.ProtoAccessTuple.storage_key:type_name -> common.ProtoHash + 44, // 46: block.ProtoAccessTuple.storage_key:type_name -> common.ProtoHash 19, // 47: block.ProtoReceiptForStorage.logs:type_name -> block.ProtoLogsForStorage - 40, // 48: block.ProtoReceiptForStorage.tx_hash:type_name -> common.ProtoHash - 42, // 49: block.ProtoReceiptForStorage.contract_address:type_name -> common.ProtoAddress + 44, // 48: block.ProtoReceiptForStorage.tx_hash:type_name -> common.ProtoHash + 46, // 49: block.ProtoReceiptForStorage.contract_address:type_name -> common.ProtoAddress 2, // 50: block.ProtoReceiptForStorage.outbound_etxs:type_name -> block.ProtoTransactions 16, // 51: block.ProtoReceiptsForStorage.receipts:type_name -> block.ProtoReceiptForStorage - 42, // 52: block.ProtoLogForStorage.address:type_name -> common.ProtoAddress - 40, // 53: block.ProtoLogForStorage.topics:type_name -> common.ProtoHash + 46, // 52: block.ProtoLogForStorage.address:type_name -> common.ProtoAddress + 44, // 53: block.ProtoLogForStorage.topics:type_name -> common.ProtoHash 18, // 54: block.ProtoLogsForStorage.logs:type_name -> block.ProtoLogForStorage 9, // 55: block.ProtoPendingHeader.wo:type_name -> block.ProtoWorkObject 21, // 56: block.ProtoPendingHeader.termini:type_name -> block.ProtoTermini - 40, // 57: block.ProtoTermini.dom_termini:type_name -> common.ProtoHash - 40, // 58: block.ProtoTermini.sub_termini:type_name -> common.ProtoHash + 44, // 57: block.ProtoTermini.dom_termini:type_name -> common.ProtoHash + 44, // 58: block.ProtoTermini.sub_termini:type_name -> common.ProtoHash 9, // 59: block.ProtoPendingEtxs.header:type_name -> block.ProtoWorkObject 2, // 60: block.ProtoPendingEtxs.outbound_etxs:type_name -> block.ProtoTransactions 9, // 61: block.ProtoPendingEtxsRollup.header:type_name -> block.ProtoWorkObject @@ -3195,21 +3351,23 @@ var file_core_types_proto_block_proto_depIdxs = []int32{ 27, // 63: block.ProtoTxIns.tx_ins:type_name -> block.ProtoTxIn 29, // 64: block.ProtoTxOuts.tx_outs:type_name -> block.ProtoTxOut 28, // 65: block.ProtoTxIn.previous_out_point:type_name -> block.ProtoOutPoint - 40, // 66: block.ProtoOutPoint.hash:type_name -> common.ProtoHash - 40, // 67: block.ProtoOutPointAndDenomination.hash:type_name -> common.ProtoHash - 37, // 68: block.ProtoAddressOutPoints.out_points:type_name -> block.ProtoAddressOutPoints.OutPointsEntry - 38, // 69: block.ProtoOutPointsMap.entries:type_name -> block.ProtoOutPointsMap.EntriesEntry + 44, // 66: block.ProtoOutPoint.hash:type_name -> common.ProtoHash + 44, // 67: block.ProtoOutPointAndDenomination.hash:type_name -> common.ProtoHash + 41, // 68: block.ProtoAddressOutPoints.out_points:type_name -> block.ProtoAddressOutPoints.OutPointsEntry + 42, // 69: block.ProtoOutPointsMap.entries:type_name -> block.ProtoOutPointsMap.EntriesEntry 28, // 70: block.ProtoSpentUTXO.outpoint:type_name -> block.ProtoOutPoint 29, // 71: block.ProtoSpentUTXO.sutxo:type_name -> block.ProtoTxOut 33, // 72: block.ProtoSpentUTXOs.sutxos:type_name -> block.ProtoSpentUTXO - 39, // 73: block.ProtoTrimDepths.trim_depths:type_name -> block.ProtoTrimDepths.TrimDepthsEntry - 30, // 74: block.ProtoAddressOutPoints.OutPointsEntry.value:type_name -> block.ProtoOutPointAndDenomination - 31, // 75: block.ProtoOutPointsMap.EntriesEntry.value:type_name -> block.ProtoAddressOutPoints - 76, // [76:76] is the sub-list for method output_type - 76, // [76:76] is the sub-list for method input_type - 76, // [76:76] is the sub-list for extension type_name - 76, // [76:76] is the sub-list for extension extendee - 0, // [0:76] is the sub-list for field type_name + 43, // 73: block.ProtoTrimDepths.trim_depths:type_name -> block.ProtoTrimDepths.TrimDepthsEntry + 38, // 74: block.ProtoTokenChoiceSet.token_choice_array:type_name -> block.ProtoTokenChoiceArray + 39, // 75: block.ProtoTokenChoiceArray.token_choices:type_name -> block.ProtoTokenChoice + 30, // 76: block.ProtoAddressOutPoints.OutPointsEntry.value:type_name -> block.ProtoOutPointAndDenomination + 31, // 77: block.ProtoOutPointsMap.EntriesEntry.value:type_name -> block.ProtoAddressOutPoints + 78, // [78:78] is the sub-list for method output_type + 78, // [78:78] is the sub-list for method input_type + 78, // [78:78] is the sub-list for extension type_name + 78, // [78:78] is the sub-list for extension extendee + 0, // [0:78] is the sub-list for field type_name } func init() { file_core_types_proto_block_proto_init() } @@ -3217,452 +3375,6 @@ func file_core_types_proto_block_proto_init() { if File_core_types_proto_block_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_core_types_proto_block_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*ProtoHeader); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ProtoTransaction); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*ProtoTransactions); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*ProtoHeaders); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*ProtoManifest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*ProtoAccessList); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*ProtoWorkObjectHeader); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*ProtoWorkObjectHeaders); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*ProtoWorkObjectBody); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*ProtoWorkObject); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[10].Exporter = func(v any, i int) any { - switch v := v.(*ProtoWorkObjects); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[11].Exporter = func(v any, i int) any { - switch v := v.(*ProtoWorkObjectBlockView); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[12].Exporter = func(v any, i int) any { - switch v := v.(*ProtoWorkObjectBlocksView); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[13].Exporter = func(v any, i int) any { - switch v := v.(*ProtoWorkObjectHeaderView); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[14].Exporter = func(v any, i int) any { - switch v := v.(*ProtoWorkObjectShareView); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[15].Exporter = func(v any, i int) any { - switch v := v.(*ProtoAccessTuple); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[16].Exporter = func(v any, i int) any { - switch v := v.(*ProtoReceiptForStorage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[17].Exporter = func(v any, i int) any { - switch v := v.(*ProtoReceiptsForStorage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[18].Exporter = func(v any, i int) any { - switch v := v.(*ProtoLogForStorage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[19].Exporter = func(v any, i int) any { - switch v := v.(*ProtoLogsForStorage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[20].Exporter = func(v any, i int) any { - switch v := v.(*ProtoPendingHeader); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[21].Exporter = func(v any, i int) any { - switch v := v.(*ProtoTermini); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[22].Exporter = func(v any, i int) any { - switch v := v.(*ProtoEtxSet); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[23].Exporter = func(v any, i int) any { - switch v := v.(*ProtoPendingEtxs); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[24].Exporter = func(v any, i int) any { - switch v := v.(*ProtoPendingEtxsRollup); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[25].Exporter = func(v any, i int) any { - switch v := v.(*ProtoTxIns); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[26].Exporter = func(v any, i int) any { - switch v := v.(*ProtoTxOuts); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[27].Exporter = func(v any, i int) any { - switch v := v.(*ProtoTxIn); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[28].Exporter = func(v any, i int) any { - switch v := v.(*ProtoOutPoint); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[29].Exporter = func(v any, i int) any { - switch v := v.(*ProtoTxOut); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[30].Exporter = func(v any, i int) any { - switch v := v.(*ProtoOutPointAndDenomination); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[31].Exporter = func(v any, i int) any { - switch v := v.(*ProtoAddressOutPoints); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[32].Exporter = func(v any, i int) any { - switch v := v.(*ProtoOutPointsMap); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[33].Exporter = func(v any, i int) any { - switch v := v.(*ProtoSpentUTXO); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[34].Exporter = func(v any, i int) any { - switch v := v.(*ProtoSpentUTXOs); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[35].Exporter = func(v any, i int) any { - switch v := v.(*ProtoKeys); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_types_proto_block_proto_msgTypes[36].Exporter = func(v any, i int) any { - switch v := v.(*ProtoTrimDepths); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } file_core_types_proto_block_proto_msgTypes[0].OneofWrappers = []any{} file_core_types_proto_block_proto_msgTypes[1].OneofWrappers = []any{} file_core_types_proto_block_proto_msgTypes[6].OneofWrappers = []any{} @@ -3680,13 +3392,14 @@ func file_core_types_proto_block_proto_init() { file_core_types_proto_block_proto_msgTypes[29].OneofWrappers = []any{} file_core_types_proto_block_proto_msgTypes[30].OneofWrappers = []any{} file_core_types_proto_block_proto_msgTypes[33].OneofWrappers = []any{} + file_core_types_proto_block_proto_msgTypes[38].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_core_types_proto_block_proto_rawDesc, NumEnums: 0, - NumMessages: 40, + NumMessages: 44, NumExtensions: 0, NumServices: 0, }, diff --git a/core/types/proto_block.proto b/core/types/proto_block.proto index 3f913dd10e..4cfc50db06 100644 --- a/core/types/proto_block.proto +++ b/core/types/proto_block.proto @@ -227,4 +227,23 @@ message ProtoKeys { message ProtoTrimDepths { map trim_depths = 1; +} + +message ProtoTokenChoiceSet { + repeated ProtoTokenChoiceArray token_choice_array = 1; +} + +message ProtoTokenChoiceArray { + optional ProtoTokenChoice token_choices = 1; +} + +message ProtoTokenChoice { + uint64 quai = 1; + uint64 qi = 2; + bytes diff = 3; // big.Int as bytes +} + +message ProtoBetas { + bytes beta0 = 1; + bytes beta1 = 2; } \ No newline at end of file diff --git a/core/types/qi_tx.go b/core/types/qi_tx.go index 6fa89852c7..7129502983 100644 --- a/core/types/qi_tx.go +++ b/core/types/qi_tx.go @@ -181,3 +181,7 @@ func CalculateIntrinsicQiTxGas(transaction *Transaction, scalingFactor float64) func (tx *QiTx) setTo(to common.Address) { panic("Cannot set To on a Qi transaction") } + +func (tx *QiTx) setValue(value *big.Int) { + panic("quai TX does not have set value method") +} diff --git a/core/types/quai_tx.go b/core/types/quai_tx.go index 785e0c5a60..20f911c955 100644 --- a/core/types/quai_tx.go +++ b/core/types/quai_tx.go @@ -131,3 +131,7 @@ func (tx *QuaiTx) isCoinbase() bool { func (tx *QuaiTx) setTo(to common.Address) { tx.To = &to } + +func (tx *QuaiTx) setValue(value *big.Int) { + panic("quai TX does not have set value method") +} diff --git a/core/types/token_choice.go b/core/types/token_choice.go new file mode 100644 index 0000000000..c60efed2b8 --- /dev/null +++ b/core/types/token_choice.go @@ -0,0 +1,119 @@ +package types + +import ( + "errors" + "math/big" +) + +type TokenChoices struct { + Quai uint64 + Qi uint64 + Diff *big.Int +} + +const ( + C_tokenChoiceSetSize = 100 +) + +type TokenChoiceSet [C_tokenChoiceSetSize]TokenChoices + +func NewTokenChoiceSet() TokenChoiceSet { + newTokenChoiceSet := [C_tokenChoiceSetSize]TokenChoices{} + for i := 0; i < C_tokenChoiceSetSize; i++ { + newTokenChoiceSet[i] = TokenChoices{Quai: 0, Qi: 0, Diff: big.NewInt(0)} + } + return newTokenChoiceSet +} + +func (tcs *TokenChoiceSet) ProtoEncode() (*ProtoTokenChoiceSet, error) { + if tcs == nil { + return nil, errors.New("TokenChoiceSet is nil") + } + + protoSet := &ProtoTokenChoiceSet{} + + for _, choices := range tcs { + protoArray := &ProtoTokenChoiceArray{} + protoChoice := &ProtoTokenChoice{ + Quai: uint64(choices.Quai), + Qi: uint64(choices.Qi), + Diff: choices.Diff.Bytes(), + } + protoArray.TokenChoices = protoChoice + + protoSet.TokenChoiceArray = append(protoSet.TokenChoiceArray, protoArray) + } + + return protoSet, nil +} + +func (tcs *TokenChoiceSet) ProtoDecode(protoSet *ProtoTokenChoiceSet) error { + if protoSet == nil { + return errors.New("ProtoTokenChoiceSet is nil") + } + + for i, protoArray := range protoSet.TokenChoiceArray { + choice := TokenChoices{ + Quai: protoArray.TokenChoices.GetQuai(), + Qi: protoArray.TokenChoices.GetQi(), + Diff: new(big.Int).SetBytes(protoArray.TokenChoices.Diff), // Convert bytes back to *big.Int + } + tcs[i] = choice + } + + return nil +} + +// Betas struct holds the beta0 and beta1 of the logistic regression for each +// prime block +type Betas struct { + beta0 *big.Float + beta1 *big.Float +} + +func NewBetas(beta0, beta1 *big.Float) *Betas { + return &Betas{ + beta0: beta0, + beta1: beta1, + } +} + +func (b *Betas) Beta0() *big.Float { + return b.beta0 +} + +func (b *Betas) Beta1() *big.Float { + return b.beta1 +} + +func (b *Betas) ProtoEncode() (*ProtoBetas, error) { + beta0Bytes, err := b.beta0.GobEncode() + if err != nil { + return nil, err + } + beta1Bytes, err := b.beta1.GobEncode() + if err != nil { + return nil, err + } + return &ProtoBetas{ + Beta0: beta0Bytes, + Beta1: beta1Bytes, + }, nil +} + +func (b *Betas) ProtoDecode(betas *ProtoBetas) error { + beta0 := new(big.Float).SetInt64(0) + beta1 := new(big.Float).SetInt64(0) + err := beta0.GobDecode(betas.GetBeta0()) + if err != nil { + return err + } + err = beta1.GobDecode(betas.GetBeta1()) + if err != nil { + return err + } + // update the beta0 and beta1 + b.beta0 = beta0 + b.beta1 = beta1 + return nil +} diff --git a/core/types/transaction.go b/core/types/transaction.go index 9480e232ea..476b960ed5 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -130,6 +130,7 @@ type TxData interface { getEcdsaSignatureValues() (v, r, s *big.Int) setEcdsaSignatureValues(chainID, v, r, s *big.Int) setTo(to common.Address) + setValue(value *big.Int) parentHash() *common.Hash mixHash() *common.Hash workNonce() *BlockNonce @@ -635,6 +636,10 @@ func (tx *Transaction) SetTo(addr common.Address) { tx.inner.setTo(addr) } +func (tx *Transaction) SetValue(value *big.Int) { + tx.inner.setValue(value) +} + // Cost returns gas * gasPrice + value. func (tx *Transaction) Cost() *big.Int { total := new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas())) diff --git a/core/types/wo.go b/core/types/wo.go index 8a3a23164e..c32908623b 100644 --- a/core/types/wo.go +++ b/core/types/wo.go @@ -492,6 +492,7 @@ func (wo *WorkObject) TransactionsInfo() map[string]interface{} { txInfo["coinbaseEtxInbound"] = coinbaseInboundEtx txInfo["conversionEtxOutbound"] = conversionOutboundEtx txInfo["conversionEtxInbound"] = conversionInboundEtx + txInfo["baseFee"] = wo.BaseFee() return txInfo } diff --git a/core/worker.go b/core/worker.go index b012c7bdc0..17e51f0f2e 100644 --- a/core/worker.go +++ b/core/worker.go @@ -536,7 +536,7 @@ func (w *worker) GeneratePendingHeader(block *types.WorkObject, fill bool, txs t work.utxoFees = big.NewInt(0) work.quaiFees = big.NewInt(0) start := time.Now() - if err := w.fillTransactions(work, primeTerminus.WorkObjectHeader(), block, fill, txs); err != nil { + if err := w.fillTransactions(work, primeTerminus, block, fill, txs); err != nil { return nil, fmt.Errorf("error generating pending header: %v", err) } if fill { @@ -577,7 +577,7 @@ func (w *worker) GeneratePendingHeader(block *types.WorkObject, fill bool, txs t // If the primary coinbase belongs to a ledger and there is no fees // for other ledger, there is no etxs emitted for the other ledger if bytes.Equal(work.wo.PrimaryCoinbase().Bytes(), quaiCoinbase.Bytes()) { - coinbaseReward := misc.CalculateReward(work.wo.WorkObjectHeader()) + coinbaseReward := misc.CalculateReward(block, work.wo.WorkObjectHeader()) blockReward := new(big.Int).Add(coinbaseReward, work.quaiFees) coinbaseEtx := types.NewTx(&types.ExternalTx{To: &primaryCoinbase, Gas: params.TxGas, Value: blockReward, EtxType: types.CoinbaseType, OriginatingTxHash: origin, ETXIndex: uint16(len(work.etxs)), Sender: primaryCoinbase, Data: []byte{defaultCoinbaseLockup}}) work.etxs = append(work.etxs, coinbaseEtx) @@ -586,7 +586,7 @@ func (w *worker) GeneratePendingHeader(block *types.WorkObject, fill bool, txs t work.etxs = append(work.etxs, coinbaseEtx) } } else if bytes.Equal(work.wo.PrimaryCoinbase().Bytes(), qiCoinbase.Bytes()) { - coinbaseReward := misc.CalculateReward(work.wo.WorkObjectHeader()) + coinbaseReward := misc.CalculateReward(block, work.wo.WorkObjectHeader()) blockReward := new(big.Int).Add(coinbaseReward, work.utxoFees) coinbaseEtx := types.NewTx(&types.ExternalTx{To: &primaryCoinbase, Gas: params.TxGas, Value: blockReward, EtxType: types.CoinbaseType, OriginatingTxHash: origin, ETXIndex: uint16(len(work.etxs)), Sender: primaryCoinbase, Data: []byte{defaultCoinbaseLockup}}) work.etxs = append(work.etxs, coinbaseEtx) @@ -598,18 +598,60 @@ func (w *worker) GeneratePendingHeader(block *types.WorkObject, fill bool, txs t // Add an etx for each workshare for it to be rewarded for _, uncle := range uncles { - reward := misc.CalculateReward(uncle) + reward := misc.CalculateReward(block, uncle) uncleCoinbase := uncle.PrimaryCoinbase() work.etxs = append(work.etxs, types.NewTx(&types.ExternalTx{To: &uncleCoinbase, Gas: params.TxGas, Value: reward, EtxType: types.CoinbaseType, OriginatingTxHash: origin, ETXIndex: uint16(len(work.etxs)), Sender: uncleCoinbase, Data: []byte{uncle.Lock()}})) } } + if nodeCtx == common.ZONE_CTX { + var exchangeRate *big.Int + if w.hc.IsGenesisHash(block.Hash()) { + exchangeRate = params.ExchangeRate + } else { + if block.NumberU64(common.ZONE_CTX) > params.ControllerKickInBlock { + // convert map to a slice + updatedTokenChoiceSet, err := CalculateTokenChoicesSet(w.hc, block, work.etxs) + if err != nil { + return nil, err + } + exchangeRate, _, _, err = CalculateExchangeRate(w.hc, block, updatedTokenChoiceSet) + if err != nil { + return nil, err + } + } else { + exchangeRate = block.ExchangeRate() + } + } + work.wo.Header().SetExchangeRate(exchangeRate) + + for _, etx := range work.etxs { + // If the etx is conversion + if types.IsConversionTx(etx) { + value := etx.Value() + // If to is in Qi, convert the value into Qi + if etx.To().IsInQiLedgerScope() { + value = misc.QuaiToQi(work.wo, value) + } + // If To is in Quai, convert the value into Quai + if etx.To().IsInQuaiLedgerScope() { + value = misc.QiToQuai(work.wo, value) + } + etx.SetValue(value) + } + } + } + // If there are no transcations in the env, reset the BaseFee to zero if len(work.txs) == 0 { work.wo.Header().SetBaseFee(big.NewInt(0)) } + if block.NumberU64(common.ZONE_CTX) < params.TimeToStartTx { + work.wo.Header().SetGasUsed(0) + } + if nodeCtx == common.ZONE_CTX && w.hc.ProcessingState() { if !fromOrderedTransactionSet { select { @@ -708,21 +750,6 @@ func (w *worker) OrderTransactionSet(txs []*types.Transaction, gasUsedAfterTrans return } - _, parentOrder, err := w.engine.CalcOrder(w.hc, block) - if err != nil { - log.Global.WithField("err", err).Error("error calculating parent order") - return - } - var primeTerminus *types.WorkObject - if parentOrder == common.PRIME_CTX { - primeTerminus = block - } else { - primeTerminus = w.hc.GetPrimeTerminus(block) - if primeTerminus == nil { - log.Global.Error("prime terminus not found") - return - } - } utxoSetSize := rawdb.ReadUTXOSetSize(w.workerDb, block.Hash()) // gas price and the gas used is extracted from each of these non external // transactions for the sorting @@ -737,7 +764,7 @@ func (w *worker) OrderTransactionSet(txs []*types.Transaction, gasUsedAfterTrans if !exists { continue } - qiFeeInQuai := misc.QiToQuai(primeTerminus.WorkObjectHeader(), fee) + qiFeeInQuai := misc.QiToQuai(block, fee) // Divide the fee by the gas used by the Qi Tx gasPrice = new(big.Int).Div(qiFeeInQuai, new(big.Int).SetInt64(int64(types.CalculateBlockQiTxGas(tx, math.Log(float64(utxoSetSize)), w.hc.NodeLocation())))) } else { @@ -984,10 +1011,12 @@ func (w *worker) commitTransaction(env *environment, parent *types.WorkObject, t return nil, false, fmt.Errorf("invalid coinbase address %v: %v", tx.To(), err) } lockupByte := tx.Data()[0] - if err := env.gasPool.SubGas(params.TxGas); err != nil { - // etxs are taking more gas - w.logger.Info("Stopped the etx processing because we crossed the block gas limit processing coinbase etxs") - return nil, false, nil + if parent.NumberU64(common.ZONE_CTX) >= params.TimeToStartTx { + if err := env.gasPool.SubGas(params.TxGas); err != nil { + // etxs are taking more gas + w.logger.Info("Stopped the etx processing because we crossed the block gas limit processing coinbase etxs") + return nil, false, nil + } } if tx.To().IsInQiLedgerScope() { lockup := new(big.Int).SetUint64(params.LockupByteToBlockDepth[lockupByte]) @@ -1027,7 +1056,9 @@ func (w *worker) commitTransaction(env *environment, parent *types.WorkObject, t } } gasUsed := env.wo.GasUsed() - gasUsed += params.TxGas + if parent.NumberU64(common.ZONE_CTX) >= params.TimeToStartTx { + gasUsed += params.TxGas + } env.wo.Header().SetGasUsed(gasUsed) env.gasUsedAfterTransaction = append(env.gasUsedAfterTransaction, gasUsed) env.txs = append(env.txs, tx) @@ -1060,8 +1091,7 @@ func (w *worker) commitTransaction(env *environment, parent *types.WorkObject, t return nil, false, err } gasUsed += params.TxGas - value := misc.QuaiToQi(primeTerminus.WorkObjectHeader(), tx.Value()) - denominations := misc.FindMinDenominations(value) + denominations := misc.FindMinDenominations(tx.Value()) outputIndex := uint16(0) // Iterate over the denominations in descending order @@ -1132,7 +1162,7 @@ func (w *worker) commitTransaction(env *environment, parent *types.WorkObject, t var qiTxErrs uint64 -func (w *worker) commitTransactions(env *environment, primeTerminus *types.WorkObjectHeader, parent *types.WorkObject, txs *types.TransactionsByPriceAndNonce, excludeEtx bool) error { +func (w *worker) commitTransactions(env *environment, primeTerminus *types.WorkObject, parent *types.WorkObject, txs *types.TransactionsByPriceAndNonce, excludeEtx bool) error { qiTxsToRemove := make([]*common.Hash, 0) gasLimit := env.wo.GasLimit if env.gasPool == nil { @@ -1140,12 +1170,22 @@ func (w *worker) commitTransactions(env *environment, primeTerminus *types.WorkO } var coalescedLogs []*types.Log minEtxGas := gasLimit() / params.MinimumEtxGasDivisor + etxCount := 0 for { if excludeEtx { break } + etxCount = 0 + for _, tx := range env.txs { + if tx.Type() == types.ExternalTxType { + etxCount++ + } + } + if parent.NumberU64(common.ZONE_CTX) < params.TimeToStartTx && etxCount > params.MinEtxCount { + break + } // Add ETXs until minimum gas is used - if env.wo.GasUsed() >= minEtxGas { + if parent.NumberU64(common.ZONE_CTX) >= params.TimeToStartTx && env.wo.GasUsed() >= minEtxGas { // included etxs more than min etx gas break } @@ -1497,42 +1537,13 @@ func (w *worker) prepareWork(genParams *generateParams, wo *types.WorkObject) (* } // Calculate the new Qi/Quai exchange rate - if nodeCtx == common.PRIME_CTX { - var subRollup types.Transactions - rollup, exists := w.hc.subRollupCache.Peek(parent.Hash()) - if exists && rollup != nil { - subRollup = rollup - w.logger.WithFields(log.Fields{ - "Hash": parent.Hash(), - "len": len(subRollup), - }).Debug("Found the rollup in cache") - } else { - subRollup, err = w.hc.CollectSubRollup(parent) - if err != nil { - return nil, err - } - w.hc.subRollupCache.Add(parent.Hash(), subRollup) - } - qiToQuai := new(big.Int).Set(common.Big0) - quaiToQi := new(big.Int).Set(common.Big0) - for _, tx := range subRollup { - if types.IsCoinBaseTx(tx) { - if tx.ETXSender().IsInQiLedgerScope() { - qiToQuai = new(big.Int).Add(qiToQuai, tx.Value()) - } else if tx.ETXSender().IsInQuaiLedgerScope() { - quaiToQi = new(big.Int).Add(quaiToQi, tx.Value()) - } - } else if types.IsConversionTx(tx) { - if tx.To().IsInQiLedgerScope() { - quaiToQi = new(big.Int).Add(quaiToQi, tx.Value()) - } else if tx.To().IsInQuaiLedgerScope() { - qiToQuai = new(big.Int).Add(qiToQuai, tx.Value()) - } - } - } + if nodeCtx == common.ZONE_CTX { + // Update the exchange rate + qiToQuai := new(big.Int).Set(parent.Header().QiToQuai()) + quaiToQi := new(big.Int).Set(parent.Header().QuaiToQi()) + newWo.Header().SetQiToQuai(qiToQuai) newWo.Header().SetQuaiToQi(quaiToQi) - newWo.Header().SetExchangeRate(params.ExchangeRate) } // Only zone should calculate state @@ -1633,7 +1644,7 @@ func (w *worker) prepareWork(genParams *generateParams, wo *types.WorkObject) (* // fillTransactions retrieves the pending transactions from the txpool and fills them // into the given sealing block. The transaction selection and ordering strategy can // be customized with the plugin in the future. -func (w *worker) fillTransactions(env *environment, primeTerminus *types.WorkObjectHeader, block *types.WorkObject, fill bool, orderedTxs types.TxByPriceAndTime) error { +func (w *worker) fillTransactions(env *environment, primeTerminus *types.WorkObject, block *types.WorkObject, fill bool, orderedTxs types.TxByPriceAndTime) error { // Split the pending transactions into locals and remotes // Fill the block with all available pending transactions. etxs := false @@ -1721,7 +1732,7 @@ func (w *worker) fillTransactions(env *environment, primeTerminus *types.WorkObj pendingQiTxsWithQuaiFee := make([]*types.TxWithMinerFee, 0) for _, tx := range pendingQiTxs { // update the fee - qiFeeInQuai := misc.QiToQuai(primeTerminus, tx.MinerFee()) + qiFeeInQuai := misc.QiToQuai(block, tx.MinerFee()) minerFeeInQuai := new(big.Int).Div(qiFeeInQuai, big.NewInt(int64(types.CalculateBlockQiTxGas(tx.Tx(), env.qiGasScalingFactor, w.hc.NodeLocation())))) if minerFeeInQuai.Cmp(big.NewInt(0)) == 0 { w.logger.Error("rejecting qi tx that has zero gas price") @@ -1904,7 +1915,7 @@ func (w *worker) CurrentInfo(header *types.WorkObject) bool { return header.NumberU64(w.hc.NodeCtx())+c_startingPrintLimit > w.hc.CurrentHeader().NumberU64(w.hc.NodeCtx()) } -func (w *worker) processQiTx(tx *types.Transaction, env *environment, primeTerminus *types.WorkObjectHeader, parent *types.WorkObject, firstQiTx bool) error { +func (w *worker) processQiTx(tx *types.Transaction, env *environment, primeTerminus *types.WorkObject, parent *types.WorkObject, firstQiTx bool) error { location := w.hc.NodeLocation() if tx.Type() != types.QiTxType { return fmt.Errorf("tx %032x is not a QiTx", tx.Hash()) @@ -2069,13 +2080,13 @@ func (w *worker) processQiTx(tx *types.Transaction, env *environment, primeTermi return fmt.Errorf("tx %032x has too many ETXs to calculate required gas", tx.Hash()) } minimumFeeInQuai := new(big.Int).Mul(big.NewInt(int64(requiredGas)), env.wo.BaseFee()) - txFeeInQuai := misc.QiToQuai(primeTerminus, txFeeInQit) + txFeeInQuai := misc.QiToQuai(parent, txFeeInQit) if txFeeInQuai.Cmp(minimumFeeInQuai) < 0 { return fmt.Errorf("tx %032x has insufficient fee for base fee * gas, have %d want %d", tx.Hash(), txFeeInQit.Uint64(), minimumFeeInQuai.Uint64()) } if conversion { // Since this transaction contains a conversion, the rest of the tx gas is given to conversion - remainingTxFeeInQuai := misc.QiToQuai(env.wo.WorkObjectHeader(), txFeeInQit) + remainingTxFeeInQuai := misc.QiToQuai(parent, txFeeInQit) // Fee is basefee * gas, so gas remaining is fee remaining / basefee remainingGas := new(big.Int).Div(remainingTxFeeInQuai, env.wo.BaseFee()) if remainingGas.Uint64() > (env.wo.GasLimit() / params.MinimumEtxGasDivisor) { diff --git a/go.mod b/go.mod index 311e902028..b2d44e8ca4 100644 --- a/go.mod +++ b/go.mod @@ -48,10 +48,13 @@ require ( ) require ( + git.sr.ht/~sbinet/gg v0.5.0 // indirect github.com/DataDog/zstd v1.4.5 // indirect + github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect + github.com/campoy/embedmd v1.0.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cockroachdb/errors v1.8.1 // indirect github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect @@ -66,12 +69,16 @@ require ( github.com/flynn/noise v1.0.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/go-fonts/liberation v0.3.1 // indirect + github.com/go-latex/latex v0.0.0-20230307184459-12ec69307ad9 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect + github.com/go-pdf/fpdf v0.8.0 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/gopacket v1.1.19 // indirect github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect @@ -162,12 +169,13 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect + golang.org/x/image v0.11.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.20.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.17.0 // indirect - gonum.org/v1/gonum v0.13.0 // indirect + gonum.org/v1/gonum v0.14.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect ) @@ -181,4 +189,5 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.17.0 golang.org/x/sys v0.18.0 + gonum.org/v1/plot v0.14.0 ) diff --git a/go.sum b/go.sum index d2357d780d..e327855e0c 100644 --- a/go.sum +++ b/go.sum @@ -43,6 +43,8 @@ dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBr dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= +git.sr.ht/~sbinet/gg v0.5.0 h1:6V43j30HM623V329xA9Ntq+WJrMjDxRjuAB1LFWF5m8= +git.sr.ht/~sbinet/gg v0.5.0/go.mod h1:G2C0eRESqlKhS7ErsNey6HHrqU1PwsnCQlekFi9Q2Oo= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -60,6 +62,10 @@ github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkT github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= +github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= +github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= +github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw= +github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= @@ -75,12 +81,15 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= +github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= +github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= @@ -166,6 +175,7 @@ github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nI github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= +github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= @@ -182,11 +192,17 @@ github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aev github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= +github.com/go-fonts/liberation v0.3.1 h1:9RPT2NhUpxQ7ukUvz3jeUckmN42T9D9TpjtQcqK/ceM= +github.com/go-fonts/liberation v0.3.1/go.mod h1:jdJ+cqF+F4SUL2V+qxBth8fvBpBDS7yloUL5Fi8GTGY= +github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-latex/latex v0.0.0-20230307184459-12ec69307ad9 h1:NxXI5pTAtpEaU49bpLpQoDsu1zrteW/vxzTz8Cd2UAs= +github.com/go-latex/latex v0.0.0-20230307184459-12ec69307ad9/go.mod h1:gWuR/CrFDDeVRFQwHPvsv9soJVB/iqymhuZQuJ3a9OM= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= @@ -198,6 +214,8 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-pdf/fpdf v0.8.0 h1:IJKpdaagnWUeSkUFUjTcSzTppFxmv8ucGQyNPQWxYOQ= +github.com/go-pdf/fpdf v0.8.0/go.mod h1:gfqhcNwXrsd3XYKte9a7vM3smvU/jB4ZRDrmWSxpfdc= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= @@ -216,6 +234,8 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -549,6 +569,7 @@ github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhM github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -606,6 +627,7 @@ github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9cJvm4SvQ= github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= @@ -732,6 +754,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= @@ -789,6 +812,7 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= @@ -806,6 +830,8 @@ golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.11.0 h1:ds2RoQvBvYTiJkwpSFDwCcDFNX7DqjL2WsUgTNk0Ooo= +golang.org/x/image v0.11.0/go.mod h1:bglhjqbqVuEb9e9+eNR45Jfu7D+T4Qan+NhQk8Ck2P8= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -829,6 +855,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -876,6 +904,8 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -901,6 +931,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -965,7 +997,9 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -976,6 +1010,8 @@ golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -984,6 +1020,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1048,6 +1086,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1056,6 +1096,10 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.13.0 h1:a0T3bh+7fhRyqeNbiC3qVHYmkiQgit3wnNan/2c0HMM= gonum.org/v1/gonum v0.13.0/go.mod h1:/WPYRckkfWrhWefxyYTfrTtQR0KH4iyHNuzxqXAKyAU= +gonum.org/v1/gonum v0.14.0 h1:2NiG67LD1tEH0D7kM+ps2V+fXmsAnpUeec7n8tcr4S0= +gonum.org/v1/gonum v0.14.0/go.mod h1:AoWeoz0becf9QMWtE8iWXNXc27fK4fNeHNf/oMejGfU= +gonum.org/v1/plot v0.14.0 h1:+LBDVFYwFe4LHhdP8coW6296MBEY4nQ+Y4vuUpJopcE= +gonum.org/v1/plot v0.14.0/go.mod h1:MLdR9424SJed+5VqC6MsouEpig9pZX2VZ57H9ko2bXU= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= @@ -1200,11 +1244,13 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= diff --git a/internal/quaiapi/quai_api.go b/internal/quaiapi/quai_api.go index b4e4042c3e..57b269f300 100644 --- a/internal/quaiapi/quai_api.go +++ b/internal/quaiapi/quai_api.go @@ -488,13 +488,8 @@ func (s *PublicBlockChainQuaiAPI) BaseFee(ctx context.Context, txType bool) (*he if txType { return (*hexutil.Big)(s.b.CurrentBlock().BaseFee()), nil } else { - // Use the prime terminus if we have it - lastPrime, err := s.b.HeaderByHash(ctx, header.PrimeTerminusHash()) - if lastPrime == nil || err != nil { - lastPrime = header - } quaiBaseFee := s.b.CurrentBlock().BaseFee() - qiBaseFee := misc.QuaiToQi(lastPrime.WorkObjectHeader(), quaiBaseFee) + qiBaseFee := misc.QuaiToQi(header, quaiBaseFee) if qiBaseFee.Cmp(big.NewInt(0)) == 0 { // Minimum base fee is 1 qit or smallest unit return (*hexutil.Big)(types.Denominations[0]), nil @@ -526,12 +521,7 @@ func (s *PublicBlockChainQuaiAPI) EstimateFeeForQi(ctx context.Context, args Tra // Calculate the base fee quaiBaseFee := header.BaseFee() feeInQuai := new(big.Int).Mul(new(big.Int).SetUint64(uint64(gas)), quaiBaseFee) - // Use the prime terminus if we have it - lastPrime, err := s.b.HeaderByHash(ctx, header.PrimeTerminusHash()) - if lastPrime == nil || err != nil { - lastPrime = header - } - feeInQi := misc.QuaiToQi(lastPrime.WorkObjectHeader(), feeInQuai) + feeInQi := misc.QuaiToQi(header, feeInQuai) if feeInQi.Cmp(big.NewInt(0)) == 0 { // Minimum fee is 1 qit or smallest unit return (*hexutil.Big)(types.Denominations[0]), nil @@ -828,8 +818,7 @@ func (s *PublicBlockChainQuaiAPI) QiRateAtBlock(ctx context.Context, blockNrOrHa s.b.Logger().WithField("err", err).Error("Error calculating QiRateAtBlock") return nil } - - return (*hexutil.Big)(misc.QiToQuai(header.WorkObjectHeader(), new(big.Int).SetUint64(qiAmount))) + return (*hexutil.Big)(misc.QiToQuai(header, new(big.Int).SetUint64(qiAmount))) } // Calculate the amount of Qi that Quai can be converted to. Expect the current Header and the Quai amount in "its", returns the Qi amount in "qits" @@ -847,8 +836,7 @@ func (s *PublicBlockChainQuaiAPI) QuaiRateAtBlock(ctx context.Context, blockNrOr s.b.Logger().WithField("err", err).Error("Error calculating QuaiRateAtBlock") return nil } - - return (*hexutil.Big)(misc.QuaiToQi(header.WorkObjectHeader(), new(big.Int).SetUint64(quaiAmount))) + return (*hexutil.Big)(misc.QuaiToQi(header, new(big.Int).SetUint64(quaiAmount))) } func (s *PublicBlockChainQuaiAPI) CalcOrder(ctx context.Context, raw hexutil.Bytes) (hexutil.Uint, error) { diff --git a/p2p/node/peerManager/peerdb/peer_info.pb.go b/p2p/node/peerManager/peerdb/peer_info.pb.go index ca1882ad1f..cd3854f0dd 100644 --- a/p2p/node/peerManager/peerdb/peer_info.pb.go +++ b/p2p/node/peerManager/peerdb/peer_info.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 +// protoc-gen-go v1.35.1 // protoc v5.28.2 // source: p2p/node/peerManager/peerdb/peer_info.proto @@ -33,11 +33,9 @@ type ProtoPeerInfo struct { func (x *ProtoPeerInfo) Reset() { *x = ProtoPeerInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_p2p_node_peerManager_peerdb_peer_info_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_p2p_node_peerManager_peerdb_peer_info_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoPeerInfo) String() string { @@ -48,7 +46,7 @@ func (*ProtoPeerInfo) ProtoMessage() {} func (x *ProtoPeerInfo) ProtoReflect() protoreflect.Message { mi := &file_p2p_node_peerManager_peerdb_peer_info_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -102,11 +100,9 @@ type ProtoAddrInfo struct { func (x *ProtoAddrInfo) Reset() { *x = ProtoAddrInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_p2p_node_peerManager_peerdb_peer_info_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_p2p_node_peerManager_peerdb_peer_info_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProtoAddrInfo) String() string { @@ -117,7 +113,7 @@ func (*ProtoAddrInfo) ProtoMessage() {} func (x *ProtoAddrInfo) ProtoReflect() protoreflect.Message { mi := &file_p2p_node_peerManager_peerdb_peer_info_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -203,32 +199,6 @@ func file_p2p_node_peerManager_peerdb_peer_info_proto_init() { if File_p2p_node_peerManager_peerdb_peer_info_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_p2p_node_peerManager_peerdb_peer_info_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*ProtoPeerInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_p2p_node_peerManager_peerdb_peer_info_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ProtoAddrInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/p2p/pb/quai_messages.pb.go b/p2p/pb/quai_messages.pb.go index a1fc057b18..9706e38414 100644 --- a/p2p/pb/quai_messages.pb.go +++ b/p2p/pb/quai_messages.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 +// protoc-gen-go v1.35.1 // protoc v5.28.2 // source: p2p/pb/quai_messages.proto @@ -33,11 +33,9 @@ type GossipWorkObject struct { func (x *GossipWorkObject) Reset() { *x = GossipWorkObject{} - if protoimpl.UnsafeEnabled { - mi := &file_p2p_pb_quai_messages_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_p2p_pb_quai_messages_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GossipWorkObject) String() string { @@ -48,7 +46,7 @@ func (*GossipWorkObject) ProtoMessage() {} func (x *GossipWorkObject) ProtoReflect() protoreflect.Message { mi := &file_p2p_pb_quai_messages_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -80,11 +78,9 @@ type GossipTransaction struct { func (x *GossipTransaction) Reset() { *x = GossipTransaction{} - if protoimpl.UnsafeEnabled { - mi := &file_p2p_pb_quai_messages_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_p2p_pb_quai_messages_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GossipTransaction) String() string { @@ -95,7 +91,7 @@ func (*GossipTransaction) ProtoMessage() {} func (x *GossipTransaction) ProtoReflect() protoreflect.Message { mi := &file_p2p_pb_quai_messages_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -141,11 +137,9 @@ type QuaiRequestMessage struct { func (x *QuaiRequestMessage) Reset() { *x = QuaiRequestMessage{} - if protoimpl.UnsafeEnabled { - mi := &file_p2p_pb_quai_messages_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_p2p_pb_quai_messages_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *QuaiRequestMessage) String() string { @@ -156,7 +150,7 @@ func (*QuaiRequestMessage) ProtoMessage() {} func (x *QuaiRequestMessage) ProtoReflect() protoreflect.Message { mi := &file_p2p_pb_quai_messages_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -304,11 +298,9 @@ type QuaiResponseMessage struct { func (x *QuaiResponseMessage) Reset() { *x = QuaiResponseMessage{} - if protoimpl.UnsafeEnabled { - mi := &file_p2p_pb_quai_messages_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_p2p_pb_quai_messages_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *QuaiResponseMessage) String() string { @@ -319,7 +311,7 @@ func (*QuaiResponseMessage) ProtoMessage() {} func (x *QuaiResponseMessage) ProtoReflect() protoreflect.Message { mi := &file_p2p_pb_quai_messages_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -425,11 +417,9 @@ type QuaiMessage struct { func (x *QuaiMessage) Reset() { *x = QuaiMessage{} - if protoimpl.UnsafeEnabled { - mi := &file_p2p_pb_quai_messages_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_p2p_pb_quai_messages_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *QuaiMessage) String() string { @@ -440,7 +430,7 @@ func (*QuaiMessage) ProtoMessage() {} func (x *QuaiMessage) ProtoReflect() protoreflect.Message { mi := &file_p2p_pb_quai_messages_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -638,68 +628,6 @@ func file_p2p_pb_quai_messages_proto_init() { if File_p2p_pb_quai_messages_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_p2p_pb_quai_messages_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*GossipWorkObject); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_p2p_pb_quai_messages_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*GossipTransaction); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_p2p_pb_quai_messages_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*QuaiRequestMessage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_p2p_pb_quai_messages_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*QuaiResponseMessage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_p2p_pb_quai_messages_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*QuaiMessage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } file_p2p_pb_quai_messages_proto_msgTypes[2].OneofWrappers = []any{ (*QuaiRequestMessage_Hash)(nil), (*QuaiRequestMessage_Number)(nil), diff --git a/p2p/protocol/handler.go b/p2p/protocol/handler.go index ca2973895a..2e91cd90c9 100644 --- a/p2p/protocol/handler.go +++ b/p2p/protocol/handler.go @@ -6,6 +6,7 @@ import ( "io" "math/big" "runtime/debug" + "sync" "time" "github.com/libp2p/go-libp2p/core/network" @@ -35,8 +36,12 @@ type rateTracker struct { var inRateTrackers map[peer.ID]rateTracker var outRateTrackers map[peer.ID]rateTracker +var requestRateMu sync.RWMutex + // Feed the request rate tracker, recomputing the rate, and returning an error if the rate limit is exceeded func ProcRequestRate(peerId peer.ID, inbound bool) error { + requestRateMu.Lock() + defer requestRateMu.Unlock() var rateTrackers *map[peer.ID]rateTracker if inRateTrackers == nil { inRateTrackers = make(map[peer.ID]rateTracker) diff --git a/params/config.go b/params/config.go index 5a382cf1a2..922df15c12 100644 --- a/params/config.go +++ b/params/config.go @@ -26,7 +26,7 @@ import ( // Genesis hashes to enforce below configs on. var ( // Progpow GenesisHashes - ProgpowColosseumGenesisHash = common.HexToHash("0x1ff6d28f14b993b75883c4611e8f9a8d157cd4e872e76f43c27c0bdfa0970069") + ProgpowColosseumGenesisHash = common.HexToHash("0x863406b0b535b316d4ae5a4d97336c0a015a36c0e5c055aa2e4461e9048b62c9") ProgpowGardenGenesisHash = common.HexToHash("0xb610af2eef9d854d01510785b0171247cb221912124c74fcef888bbed42448bb") ProgpowOrchardGenesisHash = common.HexToHash("0x863406b0b535b316d4ae5a4d97336c0a015a36c0e5c055aa2e4461e9048b62c9") ProgpowLighthouseGenesisHash = common.HexToHash("0xf60de17f1ae6cbae820d14599eb95581f5c18799f84904520c264be9cfff64c4") diff --git a/params/protocol_params.go b/params/protocol_params.go index 3747704d4a..4ee7ec3ef5 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -24,15 +24,12 @@ import ( ) const ( - GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations. - PercentGasUsedThreshold uint64 = 50 // Percent Gas used threshold at which the gas limit adjusts - GasLimitStepOneBlockThreshold uint64 = 150000 - GasLimitStepTwoBlockThreshold uint64 = 300000 - GasLimitStepThreeBlockThreshold uint64 = 450000 - MinGasLimit uint64 = 40000000 // Minimum the gas limit may ever be. - GenesisGasLimit uint64 = 5000000 // Gas limit of the Genesis block. - - StateCeil uint64 = 40000000 // Maximum the StateCeil may ever be + GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations. + PercentGasUsedThreshold uint64 = 90 // Percent Gas used threshold at which the gas limit adjusts + MinGasLimit uint64 = 5000000 // Minimum the gas limit may ever be. + GenesisGasLimit uint64 = 5000000 // Gas limit of the Genesis block. + + StateCeil uint64 = 20000000 // Maximum the StateCeil may ever be StateLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations. PercentStateUsedThreshold uint64 = 90 // Percent Gas used threshold at which the gas limit adjusts @@ -121,6 +118,8 @@ const ( MaxAddressGrindAttempts int = 1000 // Maximum number of attempts to grind an address to a valid one MinimumEtxGasDivisor = 5 // The divisor for the minimum gas for inbound ETXs (Block gas limit / MinimumEtxGasDivisor) MaximumEtxGasMultiplier = 2 // Multiplied with the minimum ETX gas for inbound ETXs (Block gas limit / MinimumEtxGasDivisor) * MaximumEtxGasMultiplier + MinEtxCount = 50 // These counts are used in the case where tx is not eligible to be started + MaxEtxCount = 100 // Dynamic Expansion parameters @@ -151,7 +150,7 @@ const ( TREE_EXPANSION_WAIT_COUNT = 1024 ConversionLockPeriod uint64 = 10 // The number of zone blocks that a conversion output is locked for - MinQiConversionDenomination = 1 + MinQiConversionDenomination = 10 ConversionConfirmationContext = common.PRIME_CTX // A conversion requires a single coincident Dom confirmation SoftMaxUTXOSetSize = 10000000 // The soft maximum number of UTXOs that can be stored in the UTXO set MinimumTrimDepth = math.MaxInt // The minimum block depth of the chain to begin trimming @@ -159,51 +158,46 @@ const ( var ( MaxGossipsubPacketSize = 3 << 20 - GasCeil uint64 = 20000000 - ColosseumGasCeil uint64 = 70000000 - GardenGasCeil uint64 = 160000000 - OrchardGasCeil uint64 = 50000000 - LighthouseGasCeil uint64 = 160000000 - LocalGasCeil uint64 = 20000000 - DifficultyBoundDivisor = big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations. - ZoneMinDifficulty = big.NewInt(1000) // The minimum difficulty in a zone. Prime & regions should be multiples of this value - MinimumDifficulty = ZoneMinDifficulty // The minimum that the difficulty may ever be. - GenesisDifficulty = ZoneMinDifficulty // Difficulty of the Genesis block. - DurationLimit = big.NewInt(12) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. - GardenDurationLimit = big.NewInt(7) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. - OrchardDurationLimit = big.NewInt(5) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. - LighthouseDurationLimit = big.NewInt(7) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. - LocalDurationLimit = big.NewInt(1) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. - TimeToStartTx uint64 = 0 * BlocksPerDay + GasCeil uint64 = 30000000 + ColosseumGasCeil uint64 = 30000000 + GardenGasCeil uint64 = 30000000 + OrchardGasCeil uint64 = 30000000 + LighthouseGasCeil uint64 = 30000000 + LocalGasCeil uint64 = 30000000 + DurationLimit = big.NewInt(5) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. + GardenDurationLimit = big.NewInt(5) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. + OrchardDurationLimit = big.NewInt(5) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. + LighthouseDurationLimit = big.NewInt(5) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. + LocalDurationLimit = big.NewInt(1) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. + TimeToStartTx uint64 = 100 BlocksPerDay uint64 = new(big.Int).Div(big.NewInt(86400), DurationLimit).Uint64() // BlocksPerDay is the number of blocks per day assuming 12 second block time - DifficultyAdjustmentPeriod = big.NewInt(360) // This is the number of blocks over which the average has to be taken + DifficultyAdjustmentPeriod = big.NewInt(720) // This is the number of blocks over which the average has to be taken DifficultyAdjustmentFactor int64 = 40 // This is the factor that divides the log of the change in the difficulty - MinQuaiConversionAmount = new(big.Int).Mul(big.NewInt(1), big.NewInt(GWei)) // 0.000000001 Quai + MinQuaiConversionAmount = new(big.Int).Mul(big.NewInt(10000000000), big.NewInt(GWei)) // 0.000000001 Quai MaxWorkShareCount = 16 WorkSharesThresholdDiff = 3 // Number of bits lower than the target that the default consensus engine uses WorkSharesInclusionDepth = 3 // Number of blocks upto which the work shares can be referenced and this is protocol enforced LockupByteToBlockDepth = make(map[uint8]uint64) LockupByteToRewardsRatio = make(map[uint8]*big.Int) - - ExchangeRate = big.NewInt(1000000000000000) // This is the initial exchange rate in Qi per Quai in Its/Qit + ExchangeRate = big.NewInt(86196385918997143) // This is the initial exchange rate in Qi per Quai in Its/Qit // Garden = big.NewInt(166666666666666667) // These numbers should be "equivalent" to the initial conversion rate - QuaiToQiConversionBase = big.NewInt(10000000) // Is the starting "historical conversion" in Qits for 10,000 Quai we need 10,000*1e3 - QiToQuaiConversionBase = big.NewInt(10000000) // Is the starting "historical conversion" in Qits for 10,000 Qi we need 10,000*1e3 - - MaxTimeDiffBetweenBlocks int64 = 100 // Max time difference between the blocks to 100 secs + QuaiToQiConversionBase = big.NewInt(10000000) // UNUSED Is the starting "historical conversion" in Qits for 10,000 Quai we need 10,000*1e3 + QiToQuaiConversionBase = big.NewInt(10000000) // UNUSED Is the starting "historical conversion" in Qits for 10,000 Qi we need 10,000*1e3 + OneOverKqi = big.NewInt(30000000) // This is the number of hashes need to get 1 Qit. 3e9 is ~$0.001 // = big.NewInt(500) + MaxTimeDiffBetweenBlocks int64 = 100 // Max time difference between the blocks to 100 secs + OneOverAlpha = big.NewInt(200) // The alpha value for the quai to qi conversion + ControllerKickInBlock uint64 = 1000000000 ) func init() { LockupByteToBlockDepth[0] = ConversionLockPeriod // minimum lockup period - LockupByteToBlockDepth[1] = 720 // 2 hours - LockupByteToBlockDepth[2] = 1440 // 4 hours - LockupByteToBlockDepth[3] = 2880 // 8 hours - LockupByteToBlockDepth[4] = 4320 // 12 hours - - LockupByteToRewardsRatio[1] = big.NewInt(7) // additional 14% - LockupByteToRewardsRatio[2] = big.NewInt(6) // additional 16% - LockupByteToRewardsRatio[3] = big.NewInt(5) // additional 20% - LockupByteToRewardsRatio[4] = big.NewInt(4) // additional 25% + LockupByteToBlockDepth[1] = 30240 // 1.75 days + LockupByteToBlockDepth[2] = 60480 // 3.5 days + LockupByteToBlockDepth[3] = 120960 // 7 days + + LockupByteToRewardsRatio[1] = big.NewInt(24) // additional 16% WPY + LockupByteToRewardsRatio[2] = big.NewInt(10) // additional 20% WPY + LockupByteToRewardsRatio[3] = big.NewInt(4) // additional 25% WPY } // This is TimeFactor*TimeFactor*common.NumZonesInRegion*common.NumRegionsInPrime @@ -259,17 +253,18 @@ func SstoreClearsScheduleRefund(stateSize, contractSize *big.Int) uint64 { } func CalculateGasWithStateScaling(stateSize, contractSize *big.Int, baseRate uint64) uint64 { - var stateSizeFloat, contractSizeFloat, scalingFactor float64 + var scalingFactor *big.Int if stateSize.Sign() != 0 { - stateSizeFloat, _ = stateSize.Float64() - scalingFactor += math.Log(stateSizeFloat) + scalingFactor = common.LogBig(stateSize) } if contractSize.Sign() != 0 { - contractSizeFloat, _ = contractSize.Float64() - scalingFactor += math.Log(contractSizeFloat) + logContractSize := common.LogBig(contractSize) + scalingFactor = new(big.Int).Add(scalingFactor, logContractSize) } - // If we can assume that the gas price constants is correct for level 7 trie - return (uint64(scalingFactor) * baseRate) / 7 + // If we can assume that the gas price constants is correct for level 4 trie + num := new(big.Int).Mul(scalingFactor, big.NewInt(int64(baseRate))) + den := new(big.Int).Mul(big.NewInt(4), common.Big2e64) + return new(big.Int).Div(num, den).Uint64() } func CalculateCoinbaseValueWithLockup(value *big.Int, lockupByte uint8) *big.Int { diff --git a/quaistats/quaistats.go b/quaistats/quaistats.go index 07f2633af9..d5774dc514 100644 --- a/quaistats/quaistats.go +++ b/quaistats/quaistats.go @@ -1266,17 +1266,23 @@ func (s *Service) assembleBlockDetailStats(block *types.WorkObject) *blockDetail woCount += 1 } } + parent, err := s.backend.(fullNodeBackend).BlockByHash(context.Background(), block.ParentHash(common.ZONE_CTX)) + if err != nil { + s.backend.Logger().WithField("err", err).Error("Failed to get prime terminus block") + return nil + } + qiType := block.PrimaryCoinbase().IsInQiLedgerScope() difficulty := block.Difficulty().String() - quaiPerQi := misc.QiToQuai(block.WorkObjectHeader(), big.NewInt(1)).String() + quaiPerQi := misc.QiToQuai(parent, big.NewInt(1)).String() var quaiReward *big.Int var qiReward *big.Int if qiType { - qiReward = misc.CalculateReward(block.WorkObjectHeader()) - quaiReward = misc.QiToQuai(block.WorkObjectHeader(), qiReward) + qiReward = misc.CalculateReward(parent, block.WorkObjectHeader()) + quaiReward = misc.QiToQuai(parent, qiReward) } else { - quaiReward = misc.CalculateReward(block.WorkObjectHeader()) - qiReward = misc.QuaiToQi(block.WorkObjectHeader(), quaiReward) + quaiReward = misc.CalculateReward(parent, block.WorkObjectHeader()) + qiReward = misc.QuaiToQi(parent, quaiReward) } // Assemble and return the block stats