Return payload value in Wei from /eth/v3/validator/blocks (#13497)

* Add value in Wei to execution payload

* simplify how payload is returned

* test fix

* fix issues

* review

* fix block handlers
This commit is contained in:
Radosław Kapka
2024-01-24 21:58:35 +01:00
committed by GitHub
parent e397f8a2bd
commit c996109b3a
41 changed files with 1265 additions and 1174 deletions

View File

@@ -18,7 +18,6 @@ go_library(
"//consensus-types/primitives:go_default_library",
"//crypto/bls:go_default_library",
"//encoding/bytesutil:go_default_library",
"//math:go_default_library",
"//network:go_default_library",
"//network/authorization:go_default_library",
"//proto/engine/v1:go_default_library",

View File

@@ -33,7 +33,6 @@ import (
"github.com/prysmaticlabs/prysm/v4/crypto/bls"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v4/math"
"github.com/prysmaticlabs/prysm/v4/network"
"github.com/prysmaticlabs/prysm/v4/network/authorization"
v1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
@@ -429,7 +428,7 @@ func (p *Builder) handleHeaderRequestCapella(w http.ResponseWriter) {
weiVal := big.NewInt(0).SetBytes(bytesutil.ReverseByteOrder(b.Value))
// we set the payload value as twice its actual one so that it always chooses builder payloads vs local payloads
weiVal = weiVal.Mul(weiVal, big.NewInt(2))
wObj, err := blocks.WrappedExecutionPayloadCapella(b.Payload, math.WeiToGwei(weiVal))
wObj, err := blocks.WrappedExecutionPayloadCapella(b.Payload, weiVal)
if err != nil {
p.cfg.logger.WithError(err).Error("Could not wrap execution payload")
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -510,7 +509,7 @@ func (p *Builder) handleHeaderRequestDeneb(w http.ResponseWriter) {
weiVal := big.NewInt(0).SetBytes(bytesutil.ReverseByteOrder(b.Value))
// we set the payload value as twice its actual one so that it always chooses builder payloads vs local payloads
weiVal = weiVal.Mul(weiVal, big.NewInt(2))
wObj, err := blocks.WrappedExecutionPayloadDeneb(b.Payload, math.WeiToGwei(weiVal))
wObj, err := blocks.WrappedExecutionPayloadDeneb(b.Payload, weiVal)
if err != nil {
p.cfg.logger.WithError(err).Error("Could not wrap execution payload")
http.Error(w, err.Error(), http.StatusInternalServerError)

View File

@@ -1,6 +1,7 @@
package operations
import (
"math/big"
"os"
"path"
"strings"
@@ -53,7 +54,7 @@ func RunExecutionPayloadTest(t *testing.T, config string) {
require.NoError(t, err)
}
payload, err := blocks2.WrappedExecutionPayloadCapella(block.ExecutionPayload, 0)
payload, err := blocks2.WrappedExecutionPayloadCapella(block.ExecutionPayload, big.NewInt(0))
require.NoError(t, err)
file, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "execution.yaml")

View File

@@ -2,6 +2,7 @@ package operations
import (
"context"
"math/big"
"path"
"testing"
@@ -43,7 +44,7 @@ func RunWithdrawalsTest(t *testing.T, config string) {
if err != nil {
return nil, err
}
p, err := consensusblocks.WrappedExecutionPayloadCapella(&enginev1.ExecutionPayloadCapella{Withdrawals: withdrawals}, 0)
p, err := consensusblocks.WrappedExecutionPayloadCapella(&enginev1.ExecutionPayloadCapella{Withdrawals: withdrawals}, big.NewInt(0))
require.NoError(t, err)
return blocks.ProcessWithdrawals(s, p)
})

View File

@@ -1,6 +1,7 @@
package operations
import (
"math/big"
"os"
"path"
"strings"
@@ -56,7 +57,7 @@ func RunExecutionPayloadTest(t *testing.T, config string) {
require.NoError(t, err)
}
payload, err := blocks2.WrappedExecutionPayloadDeneb(body.ExecutionPayload, 0)
payload, err := blocks2.WrappedExecutionPayloadDeneb(body.ExecutionPayload, big.NewInt(0))
require.NoError(t, err)
file, err := util.BazelFileBytes(testsFolderPath, folder.Name(), "execution.yaml")

View File

@@ -2,6 +2,7 @@ package operations
import (
"context"
"math/big"
"path"
"testing"
@@ -40,7 +41,7 @@ func RunWithdrawalsTest(t *testing.T, config string) {
if err != nil {
return nil, err
}
p, err := consensusblocks.WrappedExecutionPayloadDeneb(&enginev1.ExecutionPayloadDeneb{Withdrawals: withdrawals}, 0)
p, err := consensusblocks.WrappedExecutionPayloadDeneb(&enginev1.ExecutionPayloadDeneb{Withdrawals: withdrawals}, big.NewInt(0))
require.NoError(t, err)
return blocks.ProcessWithdrawals(s, p)
})