Skip to content

Commit

Permalink
Merge branch 'mockery-2-49-0' into verify-deposits-against-contract
Browse files Browse the repository at this point in the history
  • Loading branch information
abi87 committed Nov 24, 2024
2 parents 4480026 + 8b2e72d commit 9285445
Show file tree
Hide file tree
Showing 29 changed files with 76 additions and 29 deletions.
1 change: 1 addition & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dir: "{{.InterfaceDir}}/mocks"
mockname: "{{.InterfaceNameCamel}}"
filename: "{{.InterfaceNameSnake}}.mock.go"
outpkg: "mocks"
resolve-type-alias: False # see https://vektra.github.io/mockery/latest/deprecations/#resolve-type-alias
packages:
github.com/berachain/beacon-kit/mod/execution/pkg/client/ethclient:
config:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/availability_store.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/beacon_block_header.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/beacon_state.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/block_store.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/deposit_store.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/node.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/state_processor.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/storage_backend.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/validator.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/withdrawal.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/node-api/backend/mocks/withdrawal_credentials.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion mod/node-core/pkg/components/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ func ProvideDispatcher[
dp.WithEvent[async.Event[ConsensusSidecars]](async.SidecarsReceived),
dp.WithEvent[async.Event[BeaconBlockT]](async.BeaconBlockVerified),
dp.WithEvent[async.Event[BlobSidecarsT]](async.SidecarsVerified),
dp.WithEvent[async.Event[ConsensusBlockT]](async.FinalBeaconBlockReceived),
dp.WithEvent[async.Event[ConsensusBlockT]](
async.FinalBeaconBlockReceived,
),
dp.WithEvent[async.Event[BlobSidecarsT]](async.FinalSidecarsReceived),
dp.WithEvent[ValidatorUpdateEvent](
async.FinalValidatorUpdatesProcessed,
Expand Down
2 changes: 1 addition & 1 deletion mod/node-core/pkg/services/registry/mocks/basic.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/primitives/pkg/crypto/mocks/bls_signer.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 26 additions & 1 deletion mod/state-transition/pkg/core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ import (
"github.com/berachain/beacon-kit/mod/primitives/pkg/math"
)

const (
// EVMMintingSlot is the slot at which we force a single withdrawal to
// mint EVMMintingAmount EVM tokens to EVMMintingAddress. No other
// withdrawals are inserted at this slot.
EVMMintingSlot uint64 = 69420

// EVMMintingAddress is the address at which we mint EVM tokens to.
EVMMintingAddress = "0x8a73D1380345942F1cb32541F1b19C40D8e6C94B"

// EVMMintingAmount is the amount of EVM tokens to mint.
EVMMintingAmount uint64 = 530000000000000000
)

// StateDB is the underlying struct behind the BeaconState interface.
//
//nolint:revive // todo fix somehow
Expand Down Expand Up @@ -187,7 +200,7 @@ func (s *StateDB[
// ExpectedWithdrawals as defined in the Ethereum 2.0 Specification:
// https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#new-get_expected_withdrawals
//
//nolint:lll
//nolint:lll,funlen
func (s *StateDB[
_, _, _, _, _, _, ValidatorT, _, WithdrawalT, _,
]) ExpectedWithdrawals() ([]WithdrawalT, error) {
Expand All @@ -203,6 +216,18 @@ func (s *StateDB[
return nil, err
}

// Slot used to mint EVM tokens.
if slot.Unwrap() == EVMMintingSlot {
var withdrawal WithdrawalT
withdrawals = append(withdrawals, withdrawal.New(
0, // NOT USED
0, // NOT USED
common.NewExecutionAddressFromHex(EVMMintingAddress),
math.Gwei(EVMMintingAmount),
))
return withdrawals, nil
}

epoch := math.Epoch(slot.Unwrap() / s.cs.SlotsPerEpoch())

withdrawalIndex, err := s.GetNextWithdrawalIndex()
Expand Down
2 changes: 1 addition & 1 deletion mod/state-transition/pkg/core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (sp *StateProcessor[
return err
}

if err := sp.processWithdrawals(st, blk.GetBody()); err != nil {
if err := sp.processWithdrawals(st, blk); err != nil {
return err
}

Expand Down
23 changes: 21 additions & 2 deletions mod/state-transition/pkg/core/state_processor_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/berachain/beacon-kit/mod/primitives/pkg/common"
"github.com/berachain/beacon-kit/mod/primitives/pkg/math"
"github.com/berachain/beacon-kit/mod/primitives/pkg/version"
"github.com/berachain/beacon-kit/mod/state-transition/pkg/core/state"
"github.com/davecgh/go-spew/spew"
)

Expand Down Expand Up @@ -231,11 +232,13 @@ func (sp *StateProcessor[
//
//nolint:lll
func (sp *StateProcessor[
_, BeaconBlockBodyT, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _,
BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _,
]) processWithdrawals(
st BeaconStateT,
body BeaconBlockBodyT,
blk BeaconBlockT,
) error {
body := blk.GetBody()

// Dequeue and verify the logs.
var (
nextValidatorIndex math.ValidatorIndex
Expand All @@ -259,6 +262,22 @@ func (sp *StateProcessor[
)
}

// Slot used to mint EVM tokens.
slot := blk.GetSlot()
if slot.Unwrap() == state.EVMMintingSlot {
// Sanity check.
wd := expectedWithdrawals[0]
if !wd.Equals(payloadWithdrawals[0]) {
return fmt.Errorf(
"minting withdrawal does not match expected %s, got %s",
spew.Sdump(wd), spew.Sdump(payloadWithdrawals[0]),
)
}

// No processing needed.
return nil
}

// Compare and process each withdrawal.
for i, wd := range expectedWithdrawals {
// Ensure the withdrawals match the local state.
Expand Down
2 changes: 1 addition & 1 deletion mod/storage/pkg/interfaces/mocks/db.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/storage/pkg/pruner/mocks/beacon_block.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/storage/pkg/pruner/mocks/block_event.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/storage/pkg/pruner/mocks/prunable.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/storage/pkg/pruner/mocks/pruner.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9285445

Please sign in to comment.