Skip to content

Commit 142d248

Browse files
authored
Merge branch 'main' into consolidate-deposits-storage-pt2
2 parents 63e74aa + 76f873f commit 142d248

31 files changed

+1437
-73
lines changed

config/spec/mainnet.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
package spec
2222

2323
import (
24-
"math"
25-
2624
"github.com/berachain/beacon-kit/chain"
2725
"github.com/berachain/beacon-kit/consensus/cometbft/service/delay"
2826
"github.com/berachain/beacon-kit/primitives/bytes"
@@ -76,18 +74,18 @@ const (
7674
mainnetDepositContractAddress = defaultDepositContractAddress
7775

7876
// mainnetGenesisTime is the timestamp of the Berachain mainnet genesis block.
79-
mainnetGenesisTime = 1737381600
77+
mainnetGenesisTime = 1_737_381_600
8078

8179
// mainnetDeneb1ForkTime is the timestamp at which the Deneb1 fork occurs.
8280
// This is calculated based on the timestamp of the 2855th mainnet epoch, block 548160, which
8381
// was used to initiate the fork when beacon-kit forked by epoch instead of by timestamp.
84-
mainnetDeneb1ForkTime = 1738415507
82+
mainnetDeneb1ForkTime = 1_738_415_507
8583

8684
// mainnetElectraForkTime is the timestamp at which the Electra fork occurs.
87-
mainnetElectraForkTime = 1749056400
85+
mainnetElectraForkTime = 1_749_056_400
8886

8987
// mainnetElectra1ForkTime is the timestamp at which the Electra1 fork occurs.
90-
mainnetElectra1ForkTime = math.MaxInt64
88+
mainnetElectra1ForkTime = 1_756_915_200
9189

9290
// mainnetEVMInflationAddressDeneb1 is the address on the EVM which will receive the
9391
// inflation amount of native EVM balance through a withdrawal every block in the Deneb1 fork.
@@ -100,11 +98,15 @@ const (
10098
// mainnetMinValidatorWithdrawabilityDelay is the number of epochs of delay epochs of delay for a balance to be withdrawable.
10199
// 256 Epochs equates to roughly ~27 hours of withdrawal delay. This gives us room to emergency fork if needed.
102100
mainnetMinValidatorWithdrawabilityDelay = defaultMinValidatorWithdrawabilityDelay
101+
102+
// These are the heights at which SBT is activated on mainnet.
103+
mainnetSBTConsensusUpdateHeight = 9_983_085
104+
mainnetSBTConsensusEnableHeight = 9_983_086
103105
)
104106

105107
// MainnetChainSpecData is the chain.SpecData for the Berachain mainnet.
106108
func MainnetChainSpecData() *chain.SpecData {
107-
return &chain.SpecData{
109+
specData := &chain.SpecData{
108110
Config: delay.DefaultConfig(),
109111

110112
// Gwei values constants.
@@ -173,6 +175,11 @@ func MainnetChainSpecData() *chain.SpecData {
173175
MinActivationBalance: mainnetMinActivationBalance,
174176
MinValidatorWithdrawabilityDelay: mainnetMinValidatorWithdrawabilityDelay,
175177
}
178+
179+
specData.Config.ConsensusUpdateHeight = mainnetSBTConsensusUpdateHeight
180+
specData.Config.ConsensusEnableHeight = mainnetSBTConsensusEnableHeight
181+
182+
return specData
176183
}
177184

178185
// MainnetChainSpec is the ChainSpec for the Berachain mainnet.

config/spec/testnet.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ func TestnetChainSpecData() *chain.SpecData {
3232
specData.DepositEth1ChainID = chain.TestnetEth1ChainID
3333

3434
// Timestamp of the genesis block of Bepolia testnet.
35-
specData.GenesisTime = 1739976735
35+
specData.GenesisTime = 1_739_976_735
3636

3737
// Deneb1 fork timing on Bepolia. This is calculated based on the timestamp of the first bepolia
3838
// epoch, block 192, which was used to initiate the fork when beacon-kit forked by epoch instead
3939
// of by timestamp.
40-
specData.Deneb1ForkTime = 1740090694
40+
specData.Deneb1ForkTime = 1_740_090_694
4141

4242
// Timestamp of the Electra fork on Bepolia.
43-
specData.ElectraForkTime = 1746633600
43+
specData.ElectraForkTime = 1_746_633_600
4444

4545
// Enable stable block time before the Electra1 fork.
4646
specData.Config.ConsensusUpdateHeight = 7_768_334
4747
specData.Config.ConsensusEnableHeight = 7_768_335
4848

4949
// Timestamp of the Electra1 fork on Bepolia.
50-
specData.Electra1ForkTime = 1754496000
50+
specData.Electra1ForkTime = 1_754_496_000
5151

5252
return specData
5353
}

contracts/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# BeaconKit Contracts
2+
3+
## Mock PoL Contracts
4+
5+
Mock Proof-of-Liquidity contracts for testing execution client integration.
6+
7+
### Usage
8+
9+
Generate bytecode for genesis deployment:
10+
11+
```bash
12+
# Build contracts
13+
forge build
14+
15+
# Extract SimplePoLDistributor bytecode
16+
cat out/MockPoL.sol/SimplePoLDistributor.json | jq -r .deployedBytecode.object
17+
18+
# Extract ValidatorRegistry bytecode
19+
cat out/MockValidatorRegistry.sol/ValidatorRegistry.json | jq -r .deployedBytecode.object
20+
```
21+
22+
The same pattern can be used to extract bytecode for other contracts in the
23+
`brip0004/` directory.
24+
25+
### Contracts
26+
27+
- `MockPoL.sol` - Basic PoL distributor with multi-contract state changes
28+
- `MockPoLReverting.sol` - PoL distributor that reverts after 10 distributions
29+
- `MockPoLGasEnforcer.sol` - Gas-constrained PoL distributor for gas limit testing
30+
- `MockValidatorRegistry.sol` - Registry contract for testing cross-contract calls

contracts/src/brip0004/MockPoL.sol

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.26;
3+
4+
import "./MockValidatorRegistry.sol";
5+
6+
/// @title SimplePoLDistributor
7+
/// @notice Mock PoL distributor for testing execution client integration
8+
/// @dev Interacts with ValidatorRegistry to test multi-contract state changes
9+
contract SimplePoLDistributor {
10+
/// @notice System address that can call distributeFor (execution layer client)
11+
address private constant SYSTEM_ADDRESS =
12+
0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE;
13+
14+
/// @notice The validator registry contract address (hardcoded for genesis deployment)
15+
ValidatorRegistry private constant VALIDATOR_REGISTRY =
16+
ValidatorRegistry(0x4200000000000000000000000000000000000043);
17+
18+
/// @notice Event emitted when distributeFor is called
19+
event PoLDistributed(bytes pubkey);
20+
21+
/// @notice Counter for total distributions
22+
uint256 public totalDistributions;
23+
24+
/// @notice Error thrown when caller is not the system address
25+
error NotSystemAddress();
26+
27+
/// @dev Restricts access to system address (execution layer client only)
28+
modifier onlySystemCall() {
29+
if (msg.sender != SYSTEM_ADDRESS) {
30+
revert NotSystemAddress();
31+
}
32+
_;
33+
}
34+
35+
/// @notice Main function called by execution client
36+
/// @param pubkey The validator public key
37+
/// @dev Calls ValidatorRegistry to test multi-contract state changes
38+
// slither-disable-next-line reentrancy-events
39+
function distributeFor(bytes calldata pubkey) external onlySystemCall {
40+
totalDistributions++;
41+
VALIDATOR_REGISTRY.recordValidatorActivity(pubkey);
42+
43+
emit PoLDistributed(pubkey);
44+
}
45+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.26;
3+
4+
/// @title GasEnforcedPoLDistributor
5+
/// @notice PoL distributor requiring exactly 29,999,646 gas for testing gas limits
6+
/// @dev Reverts if called with incorrect gas amount
7+
contract GasEnforcedPoLDistributor {
8+
function distributeFor(bytes calldata /*pubkey*/ ) public view {
9+
uint256 start_gas = gasleft();
10+
require(start_gas == 29_999_646, "Insufficient gas");
11+
}
12+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.26;
3+
4+
import "./MockValidatorRegistry.sol";
5+
6+
/// @title RevertingPoLDistributor
7+
/// @notice Mock PoL distributor that reverts after 10 distributions for testing
8+
/// @dev Interacts with ValidatorRegistry to test multi-contract state changes
9+
contract RevertingPoLDistributor {
10+
/// @notice System address that can call distributeFor (execution layer client)
11+
address private constant SYSTEM_ADDRESS =
12+
0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE;
13+
14+
/// @notice The validator registry contract address (hardcoded for genesis deployment)
15+
ValidatorRegistry private constant VALIDATOR_REGISTRY =
16+
ValidatorRegistry(0x4200000000000000000000000000000000000043);
17+
18+
/// @notice Event emitted when distributeFor is called
19+
event PoLDistributed(bytes pubkey);
20+
21+
/// @notice Counter for total distributions
22+
uint256 public totalDistributions;
23+
24+
/// @notice Error thrown when caller is not the system address
25+
error NotSystemAddress();
26+
27+
/// @dev Restricts access to system address (execution layer client only)
28+
modifier onlySystemCall() {
29+
if (msg.sender != SYSTEM_ADDRESS) {
30+
revert NotSystemAddress();
31+
}
32+
_;
33+
}
34+
35+
/// @notice Main function called by execution client
36+
/// @param pubkey The validator public key
37+
/// @dev Calls ValidatorRegistry to test multi-contract state changes
38+
// slither-disable-next-line reentrancy-events
39+
function distributeFor(bytes calldata pubkey) external onlySystemCall {
40+
require(totalDistributions < 10, "Max distributions reached");
41+
totalDistributions++;
42+
VALIDATOR_REGISTRY.recordValidatorActivity(pubkey);
43+
44+
emit PoLDistributed(pubkey);
45+
}
46+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.26;
3+
4+
/// @title ValidatorRegistry
5+
/// @notice Simple registry contract for testing multi-contract state changes
6+
/// @dev Called by PoL distributors to increment activity counter
7+
contract ValidatorRegistry {
8+
/// @notice Activity counter incremented on each call
9+
uint256 public callCount;
10+
11+
/// @notice Event emitted when activity is recorded
12+
event RegistryCalled(uint256 newCount);
13+
14+
/// @notice Records validator activity by incrementing counter
15+
function recordValidatorActivity(bytes calldata /* pubkey */ ) external {
16+
callCount++;
17+
emit RegistryCalled(callCount);
18+
}
19+
}

go.mod

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ require (
1515
cosmossdk.io/core v1.0.0
1616
cosmossdk.io/depinject v1.2.1
1717
cosmossdk.io/errors v1.0.2
18-
cosmossdk.io/log v1.6.0
18+
cosmossdk.io/log v1.6.1
1919
cosmossdk.io/math v1.5.3
2020
cosmossdk.io/store v1.10.0-rc.1.0.20241218084712-ca559989da43
21-
github.com/cenkalti/backoff/v5 v5.0.2
21+
github.com/cenkalti/backoff/v5 v5.0.3
2222
github.com/cometbft/cometbft v1.0.1-0.20241220100824-07c737de00ff
2323
github.com/cometbft/cometbft/api v1.0.1-0.20241220100824-07c737de00ff
2424
github.com/cosmos/cosmos-db v1.1.3
@@ -28,7 +28,7 @@ require (
2828
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
2929
github.com/go-faster/xor v1.0.0
3030
github.com/go-playground/validator/v10 v10.27.0
31-
github.com/golang-jwt/jwt/v5 v5.2.3
31+
github.com/golang-jwt/jwt/v5 v5.3.0
3232
github.com/hashicorp/go-metrics v0.5.4
3333
github.com/hashicorp/golang-lru/v2 v2.0.7
3434
github.com/holiman/uint256 v1.3.2
@@ -37,21 +37,21 @@ require (
3737
github.com/minio/sha256-simd v1.0.1
3838
github.com/mitchellh/mapstructure v1.5.0
3939
github.com/ory/dockertest v3.3.5+incompatible
40-
github.com/phuslu/log v1.0.118
40+
github.com/phuslu/log v1.0.119
4141
github.com/pkg/errors v0.9.1
4242
github.com/prysmaticlabs/gohashtree v0.0.4-beta.0.20240624100937-73632381301b
4343
github.com/prysmaticlabs/prysm/v5 v5.3.0
4444
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8
4545
github.com/spf13/afero v1.14.0
4646
github.com/spf13/cast v1.9.2
4747
github.com/spf13/cobra v1.9.1
48-
github.com/spf13/pflag v1.0.6
48+
github.com/spf13/pflag v1.0.7
4949
github.com/spf13/viper v1.20.1
5050
github.com/umbracle/fastrlp v0.1.0
5151
go.uber.org/automaxprocs v1.6.0
52-
golang.org/x/crypto v0.40.0
52+
golang.org/x/crypto v0.41.0
5353
golang.org/x/sync v0.16.0
54-
sigs.k8s.io/yaml v1.5.0
54+
sigs.k8s.io/yaml v1.6.0
5555
)
5656

5757
// build/test dependencies
@@ -64,7 +64,7 @@ require (
6464
github.com/protolambda/zrnt v0.34.1
6565
github.com/protolambda/ztyp v0.2.2
6666
github.com/rs/zerolog v1.34.0
67-
github.com/stretchr/testify v1.10.0
67+
github.com/stretchr/testify v1.11.0
6868
)
6969

7070
require (
@@ -91,8 +91,8 @@ require (
9191
github.com/bgentry/speakeasy v0.2.0 // indirect
9292
github.com/bits-and-blooms/bitset v1.20.0 // indirect
9393
github.com/bufbuild/protocompile v0.14.1 // indirect
94-
github.com/bytedance/sonic v1.13.1 // indirect
95-
github.com/bytedance/sonic/loader v0.2.4 // indirect
94+
github.com/bytedance/sonic v1.14.0 // indirect
95+
github.com/bytedance/sonic/loader v0.3.0 // indirect
9696
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
9797
github.com/cespare/xxhash/v2 v2.3.0 // indirect
9898
github.com/cloudwego/base64x v0.1.5 // indirect
@@ -250,12 +250,12 @@ require (
250250
go.opentelemetry.io/otel/metric v1.34.0 // indirect
251251
go.opentelemetry.io/otel/trace v1.34.0 // indirect
252252
go.yaml.in/yaml/v2 v2.4.2 // indirect
253-
golang.org/x/arch v0.15.0 // indirect
253+
golang.org/x/arch v0.17.0 // indirect
254254
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
255-
golang.org/x/net v0.41.0 // indirect
256-
golang.org/x/sys v0.34.0 // indirect
257-
golang.org/x/term v0.33.0 // indirect
258-
golang.org/x/text v0.27.0 // indirect
255+
golang.org/x/net v0.42.0 // indirect
256+
golang.org/x/sys v0.35.0 // indirect
257+
golang.org/x/term v0.34.0 // indirect
258+
golang.org/x/text v0.28.0 // indirect
259259
golang.org/x/time v0.11.0 // indirect
260260
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
261261
google.golang.org/genproto v0.0.0-20240624140628-dc46fd24d27d // indirect

0 commit comments

Comments
 (0)