Skip to content

Commit

Permalink
core: misc comments, tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
lightclient committed Apr 8, 2024
1 parent b15ae0e commit fc204f9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
3 changes: 1 addition & 2 deletions core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error {
blockchain.reportBlock(block, res.Receipts, err)
return err
}
err = blockchain.validator.ValidateState(block, statedb, res.Receipts, res.GasUsed)
err = blockchain.validator.ValidateState(block, statedb, res)
if err != nil {
blockchain.reportBlock(block, res.Receipts, err)
return err
Expand Down Expand Up @@ -4324,7 +4324,6 @@ func TestEIP3651(t *testing.T) {

func TestEIP6110(t *testing.T) {
var (
aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa")
engine = beacon.NewFaker()

// A sender who makes transactions, has some funds
Expand Down
62 changes: 32 additions & 30 deletions core/types/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,18 @@ import (
"github.com/ethereum/go-ethereum/rlp"
)

var (
// DepositABI is an ABI instance of beacon chain deposit events.
DepositABI = abi.ABI{Events: map[string]abi.Event{"DepositEvent": depositEvent}}

bytesT, _ = abi.NewType("bytes", "", nil)
depositEvent = abi.NewEvent("DepositEvent", "DepositEvent", false, abi.Arguments{
{Name: "pubkey", Type: bytesT, Indexed: false},
{Name: "withdrawal_credentials", Type: bytesT, Indexed: false},
{Name: "amount", Type: bytesT, Indexed: false},
{Name: "signature", Type: bytesT, Indexed: false},
{Name: "index", Type: bytesT, Indexed: false}},
)
)

//go:generate go run github.com/fjl/gencodec -type Deposit -field-override depositMarshaling -out gen_deposit_json.go

// Deposit contians EIP-6110 deposit data.
type Deposit struct {
PublicKey BLSPublicKey `json:"pubkey"`
WithdrawalCredentials common.Hash `json:"withdrawalCredentials"`
Amount uint64 `json:"amount"` // in gwei
Signature BLSSignature `json:"signature"`
Index uint64 `json:"index"`
PublicKey BLSPublicKey `json:"pubkey"` // public key of validator
WithdrawalCredentials common.Hash `json:"withdrawalCredentials"` // beneficiary of the validator funds
Amount uint64 `json:"amount"` // deposit size in Gwei
Signature BLSSignature `json:"signature"` // signature over deposit msg
Index uint64 `json:"index"` // deposit count value
}

// field type overrides for gencodec
type depositMarshaling struct {
PublicKey hexutil.Bytes
WithdrawalCredentials hexutil.Bytes
Expand All @@ -60,6 +47,7 @@ type depositMarshaling struct {
Index hexutil.Uint64
}

// field type overrides for abi upacking
type depositUnpacking struct {
Pubkey []byte
WithdrawalCredentials []byte
Expand All @@ -68,6 +56,31 @@ type depositUnpacking struct {
Index []byte
}

// Deposit implements DerivableList for withdrawals.
type Deposits []*Deposit

// Len returns the length of s.
func (s Deposits) Len() int { return len(s) }

// EncodeIndex encodes the i'th deposit to s.
func (s Deposits) EncodeIndex(i int, w *bytes.Buffer) {
rlp.Encode(w, s[i])
}

var (
// DepositABI is an ABI instance of beacon chain deposit events.
DepositABI = abi.ABI{Events: map[string]abi.Event{"DepositEvent": depositEvent}}
bytesT, _ = abi.NewType("bytes", "", nil)
depositEvent = abi.NewEvent("DepositEvent", "DepositEvent", false, abi.Arguments{
{Name: "pubkey", Type: bytesT, Indexed: false},
{Name: "withdrawal_credentials", Type: bytesT, Indexed: false},
{Name: "amount", Type: bytesT, Indexed: false},
{Name: "signature", Type: bytesT, Indexed: false},
{Name: "index", Type: bytesT, Indexed: false}},
)
)

// UnpackIntoDeposit unpacks a serialized DepositEvent.
func UnpackIntoDeposit(data []byte) (*Deposit, error) {
var du depositUnpacking
if err := DepositABI.UnpackIntoInterface(&du, "DepositEvent", data); err != nil {
Expand All @@ -83,17 +96,6 @@ func UnpackIntoDeposit(data []byte) (*Deposit, error) {
return &d, nil
}

// Deposit implements DerivableList for withdrawals.
type Deposits []*Deposit

// Len returns the length of s.
func (s Deposits) Len() int { return len(s) }

// EncodeIndex encodes the i'th deposit to s.
func (s Deposits) EncodeIndex(i int, w *bytes.Buffer) {
rlp.Encode(w, s[i])
}

// misc bls types
////

Expand Down

0 comments on commit fc204f9

Please sign in to comment.