fix : TxDependency

This commit is contained in:
Shivam Sharma 2023-07-28 18:02:53 +05:30
parent 36fa343a1b
commit 750437b93e
5 changed files with 6 additions and 38 deletions

View file

@ -50,7 +50,7 @@ type ParallelStateProcessor struct {
engine consensus.Engine // Consensus engine used for block rewards
}
// NewParallelStateProcessor NewStateProcessor initialises a new StateProcessor.
// NewParallelStateProcessor initialises a new StateProcessor.
func NewParallelStateProcessor(config *params.ChainConfig, bc *BlockChain, engine consensus.Engine) *ParallelStateProcessor {
return &ParallelStateProcessor{
config: config,

View file

@ -97,11 +97,6 @@ type Header struct {
// ExcessDataGas was added by EIP-4844 and is ignored in legacy headers.
ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"`
// length of TxDependency -> n (n = number of transactions in the block)
// length of TxDependency[i] -> k (k = a whole number)
// k elements in TxDependency[i] -> transaction indexes on which transaction i is dependent on
TxDependency [][]uint64 `json:"txDependency" rlp:"optional"`
/*
TODO (MariusVanDerWijden) Add this field once needed
// Random was added during the merge and contains the BeaconState randomness
@ -321,15 +316,6 @@ func CopyHeader(h *Header) *Header {
*cpy.WithdrawalsHash = *h.WithdrawalsHash
}
if len(h.TxDependency) > 0 {
cpy.TxDependency = make([][]uint64, len(h.TxDependency))
for i, dep := range h.TxDependency {
cpy.TxDependency[i] = make([]uint64, len(dep))
copy(cpy.TxDependency[i], dep)
}
}
return &cpy
}

View file

@ -94,7 +94,7 @@ func GetValidatorBytesTest(h *Header) []byte {
func TestTxDependencyBlockDecoding(t *testing.T) {
t.Parallel()
blockEnc := common.FromHex("f903a8f9029ba083cafc574e1f51ba9dc0568fc617a08ea2429fb384059c972f13b19fa1c8dd55a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a05fe50b260da6308036625b850b5d6ced6d0a9f814c0688bc91ffb7b7a3a54b67a0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845506eb07b8710000000000000000000000000000000000000000000000000000000000000000cf8776616c20736574c6c20201c201800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c4843b9aca00a0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff4988204d2c6c20201c20180f90106f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1b8a302f8a0018080843b9aca008301e24194095e7baea6a6c7c4c2dfeb977efac326af552d878080f838f7940000000000000000000000000000000000000001e1a0000000000000000000000000000000000000000000000000000000000000000080a0fe38ca4e44a30002ac54af7cf922a6ac2ba11b7d22f548e8ecb3f51f41cb31b0a06de6a5cbae13c0c856e33acf021b51819636cfc009d39eafb9f606d546e305a8c0")
blockEnc := common.FromHex("f9037df90270a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8825208845506eb07b8710000000000000000000000000000000000000000000000000000000000000000cf8776616c20736574c6c20201c201800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c4843b9aca00f90106f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1b8a302f8a0018080843b9aca008301e24194095e7baea6a6c7c4c2dfeb977efac326af552d878080f838f7940000000000000000000000000000000000000001e1a0000000000000000000000000000000000000000000000000000000000000000080a0fe38ca4e44a30002ac54af7cf922a6ac2ba11b7d22f548e8ecb3f51f41cb31b0a06de6a5cbae13c0c856e33acf021b51819636cfc009d39eafb9f606d546e305a8c0")
var block Block
@ -114,7 +114,7 @@ func TestTxDependencyBlockDecoding(t *testing.T) {
check("Coinbase", block.Coinbase(), common.HexToAddress("8888f1f195afa192cfee860698584c030f4c9db1"))
check("MixDigest", block.MixDigest(), common.HexToHash("bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff498"))
check("Root", block.Root(), common.HexToHash("ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017"))
check("Hash", block.Hash(), common.HexToHash("0x6a1f80562f62adcb5d1dedcb1b77c00da1fa4f99e86356bf9d6a04b618f9c499"))
check("Hash", block.Hash(), common.HexToHash("0xd41b39190a90b9c047ed091c4c77ba03289fef1ae6e87600ab60f7242d63e4a5"))
check("Nonce", block.Nonce(), uint64(0xa13a5a8c8f2bb1c4))
check("Time", block.Time(), uint64(1426516743))
check("Size", block.Size(), uint64(len(blockEnc)))

View file

@ -34,7 +34,6 @@ func (h Header) MarshalJSON() ([]byte, error) {
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"`
TxDependency [][]uint64 `json:"txDependency" rlp:"optional"`
Hash common.Hash `json:"hash"`
}
var enc Header
@ -56,7 +55,6 @@ func (h Header) MarshalJSON() ([]byte, error) {
enc.BaseFee = (*hexutil.Big)(h.BaseFee)
enc.WithdrawalsHash = h.WithdrawalsHash
enc.ExcessDataGas = h.ExcessDataGas
enc.TxDependency = h.TxDependency
enc.Hash = h.Hash()
return json.Marshal(&enc)
}
@ -82,7 +80,6 @@ func (h *Header) UnmarshalJSON(input []byte) error {
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"`
TxDependency [][]uint64 `json:"txDependency" rlp:"optional"`
}
var dec Header
if err := json.Unmarshal(input, &dec); err != nil {
@ -154,8 +151,5 @@ func (h *Header) UnmarshalJSON(input []byte) error {
if dec.ExcessDataGas != nil {
h.ExcessDataGas = dec.ExcessDataGas
}
if dec.TxDependency != nil {
h.TxDependency = dec.TxDependency
}
return nil
}

View file

@ -43,8 +43,7 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
_tmp1 := obj.BaseFee != nil
_tmp2 := obj.WithdrawalsHash != nil
_tmp3 := obj.ExcessDataGas != nil
_tmp4 := len(obj.TxDependency) > 0
if _tmp1 || _tmp2 || _tmp3 || _tmp4 {
if _tmp1 || _tmp2 || _tmp3 {
if obj.BaseFee == nil {
w.Write(rlp.EmptyString)
} else {
@ -54,14 +53,14 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
w.WriteBigInt(obj.BaseFee)
}
}
if _tmp2 || _tmp3 || _tmp4 {
if _tmp2 || _tmp3 {
if obj.WithdrawalsHash == nil {
w.Write([]byte{0x80})
} else {
w.WriteBytes(obj.WithdrawalsHash[:])
}
}
if _tmp3 || _tmp4 {
if _tmp3 {
if obj.ExcessDataGas == nil {
w.Write(rlp.EmptyString)
} else {
@ -71,17 +70,6 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
w.WriteBigInt(obj.ExcessDataGas)
}
}
if _tmp4 {
_tmp5 := w.List()
for _, _tmp6 := range obj.TxDependency {
_tmp7 := w.List()
for _, _tmp8 := range _tmp6 {
w.WriteUint64(_tmp8)
}
w.ListEnd(_tmp7)
}
w.ListEnd(_tmp5)
}
w.ListEnd(_tmp0)
return w.Flush()
}