@@ -21,7 +21,6 @@ import (
21
21
"fmt"
22
22
"io"
23
23
24
- "github.com/holiman/uint256"
25
24
libcommon "github.com/ledgerwatch/erigon-lib/common"
26
25
"github.com/ledgerwatch/erigon-lib/common/length"
27
26
@@ -39,7 +38,7 @@ type Withdrawal struct {
39
38
Index uint64 `json:"index"` // monotonically increasing identifier issued by consensus layer
40
39
Validator uint64 `json:"validatorIndex"` // index of validator associated with withdrawal
41
40
Address libcommon.Address `json:"address"` // target address for withdrawn ether
42
- Amount uint256. Int `json:"amount"` // value of withdrawal in wei
41
+ Amount uint64 `json:"amount"` // value of withdrawal in GWei
43
42
}
44
43
45
44
func (obj * Withdrawal ) EncodingSize () int {
@@ -49,7 +48,7 @@ func (obj *Withdrawal) EncodingSize() int {
49
48
encodingSize ++
50
49
encodingSize += rlp .IntLenExcludingHead (obj .Validator )
51
50
encodingSize ++
52
- encodingSize += rlp .Uint256LenExcludingHead ( & obj .Amount )
51
+ encodingSize += rlp .IntLenExcludingHead ( obj .Amount )
53
52
return encodingSize
54
53
}
55
54
@@ -76,16 +75,15 @@ func (obj *Withdrawal) EncodeRLP(w io.Writer) error {
76
75
return err
77
76
}
78
77
79
- return obj .Amount . EncodeRLP ( w )
78
+ return rlp . EncodeInt ( obj .Amount , w , b [:] )
80
79
}
81
80
82
81
func (obj * Withdrawal ) EncodeSSZ () []byte {
83
82
buf := make ([]byte , obj .EncodingSizeSSZ ())
84
83
ssz_utils .MarshalUint64SSZ (buf , obj .Index )
85
84
ssz_utils .MarshalUint64SSZ (buf [8 :], obj .Validator )
86
85
copy (buf [16 :], obj .Address [:])
87
- // Supports only GWEI format.
88
- ssz_utils .MarshalUint64SSZ (buf [36 :], obj .Amount .Uint64 ())
86
+ ssz_utils .MarshalUint64SSZ (buf [36 :], obj .Amount )
89
87
return buf
90
88
}
91
89
@@ -96,7 +94,7 @@ func (obj *Withdrawal) DecodeSSZ(buf []byte) error {
96
94
obj .Index = ssz_utils .UnmarshalUint64SSZ (buf )
97
95
obj .Validator = ssz_utils .UnmarshalUint64SSZ (buf [8 :])
98
96
copy (obj .Address [:], buf [16 :])
99
- obj .Amount = * uint256 . NewInt ( ssz_utils .UnmarshalUint64SSZ (buf [36 :]) )
97
+ obj .Amount = ssz_utils .UnmarshalUint64SSZ (buf [36 :])
100
98
return nil
101
99
}
102
100
@@ -112,7 +110,7 @@ func (obj *Withdrawal) HashSSZ() ([32]byte, error) { // the [32]byte is temporar
112
110
merkle_tree .Uint64Root (obj .Index ),
113
111
merkle_tree .Uint64Root (obj .Validator ),
114
112
addressLeaf ,
115
- merkle_tree .Uint64Root (obj .Amount . Uint64 () ),
113
+ merkle_tree .Uint64Root (obj .Amount ),
116
114
}, 4 )
117
115
}
118
116
@@ -138,10 +136,9 @@ func (obj *Withdrawal) DecodeRLP(s *rlp.Stream) error {
138
136
}
139
137
copy (obj .Address [:], b )
140
138
141
- if b , err = s .Uint256Bytes (); err != nil {
139
+ if obj . Amount , err = s .Uint (); err != nil {
142
140
return fmt .Errorf ("read Amount: %w" , err )
143
141
}
144
- obj .Amount .SetBytes (b )
145
142
146
143
return s .ListEnd ()
147
144
}
@@ -150,7 +147,7 @@ func (obj *Withdrawal) DecodeRLP(s *rlp.Stream) error {
150
147
type withdrawalMarshaling struct {
151
148
Index hexutil.Uint64
152
149
Validator hexutil.Uint64
153
- Amount * hexutil.Big
150
+ Amount hexutil.Uint64
154
151
}
155
152
156
153
// Withdrawals implements DerivableList for withdrawals.
0 commit comments