-
Notifications
You must be signed in to change notification settings - Fork 19.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all: implement eip-7002 EL triggered withdrawal requests
- Loading branch information
1 parent
e86bac2
commit 3e2561f
Showing
9 changed files
with
272 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2024 The go-ethereum Authors | ||
// This file is part of the go-ethereum library. | ||
// | ||
// The go-ethereum library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The go-ethereum library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
package types | ||
|
||
import ( | ||
"bytes" | ||
"encoding/binary" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/rlp" | ||
) | ||
|
||
// WithdrawalRequest represents an EIP-7002 withdrawal request from source for | ||
// the validator associated with the public key for amount. | ||
type WithdrawalRequest struct { | ||
Source common.Address `json:"source"` | ||
PublicKey BLSPublicKey `json:"pubkey"` | ||
Amount uint64 `json:"amount"` | ||
} | ||
|
||
func (w *WithdrawalRequest) Bytes() []byte { | ||
out := make([]byte, 76) | ||
copy(out, w.Source.Bytes()) | ||
copy(out[20:], w.PublicKey[:]) | ||
binary.LittleEndian.PutUint64(out, w.Amount) | ||
return out | ||
} | ||
|
||
// WithdrawalRequests implements DerivableList for withdrawal requests. | ||
type WithdrawalRequests []*WithdrawalRequest | ||
|
||
// Len returns the length of s. | ||
func (s WithdrawalRequests) Len() int { return len(s) } | ||
|
||
// EncodeIndex encodes the i'th withdrawal request to w. | ||
func (s WithdrawalRequests) EncodeIndex(i int, w *bytes.Buffer) { | ||
rlp.Encode(w, s[i]) | ||
} | ||
|
||
// Requests creates a deep copy of each deposit and returns a slice of the | ||
// withdrwawal requests as Request objects. | ||
func (s WithdrawalRequests) Requests() (reqs Requests) { | ||
for _, d := range s { | ||
reqs = append(reqs, NewRequest(d)) | ||
} | ||
return | ||
} | ||
|
||
func (w *WithdrawalRequest) requestType() byte { return WithdrawalRequestType } | ||
func (w *WithdrawalRequest) encode(b *bytes.Buffer) error { return rlp.Encode(b, w) } | ||
func (w *WithdrawalRequest) decode(input []byte) error { return rlp.DecodeBytes(input, w) } | ||
func (w *WithdrawalRequest) copy() RequestData { | ||
return &WithdrawalRequest{ | ||
Source: w.Source, | ||
PublicKey: w.PublicKey, | ||
Amount: w.Amount, | ||
} | ||
} |
Oops, something went wrong.