Skip to content

Commit

Permalink
Merge pull request #46 from testinprod-io/upstream-v2.40.0
Browse files Browse the repository at this point in the history
Upstream v2.40.0
  • Loading branch information
ImTei authored May 3, 2023
2 parents dec16ef + c19a854 commit 27d4e93
Show file tree
Hide file tree
Showing 254 changed files with 17,581 additions and 3,334 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ jobs:
VERSION: ${{ steps.prepare.outputs.tag_name }}
DOCKER_USERNAME: ${{ secrets.DOCKERHUB }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_KEY }}

# - name: Publish downloads
# run: |
# cd cmd/release
# docker buildx build --push --platform linux/amd64 --build-arg GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -t thorax/download:latest .
4 changes: 2 additions & 2 deletions .github/workflows/stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
steps:
- uses: actions/stale@v7
with: # core team are exempt
exempt-issue-assignees: 'AskAlexSharov,realLedgerwatch,AndreaLanfranchi,yperbasis,vorot93,b00ris,JekaMas,mandrigin,Giulio2002,tjayrush,revitteth,hexoscott'
exempt-pr-assignees: 'AskAlexSharov,realLedgerwatch,AndreaLanfranchi,yperbasis,vorot93,b00ris,JekaMas,mandrigin,Giulio2002,tjayrush,revitteth,hexoscott'
exempt-issue-assignees: 'AskAlexSharov,realLedgerwatch,AndreaLanfranchi,yperbasis,vorot93,b00ris,JekaMas,mandrigin,Giulio2002,tjayrush,revitteth,hexoscott,nanevardanyan'
exempt-pr-assignees: 'AskAlexSharov,realLedgerwatch,AndreaLanfranchi,yperbasis,vorot93,b00ris,JekaMas,mandrigin,Giulio2002,tjayrush,revitteth,hexoscott,nanevardanyan'
stale-issue-message: 'This issue is stale because it has been open for 40 days with no activity. Remove stale label or comment, or this will be closed in 7 days.'
stale-pr-message: 'This PR is stale because it has been open for 40 days with no activity.'
close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.'
Expand Down
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,7 @@ issues:
linters:
- gosec
- gocritic
- path: p2p/dnsdisc
linters:
- gosec
- gocritic
16 changes: 8 additions & 8 deletions DEV_CHAIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ make erigon
```


## 2. Build RPCdeamon
## 2. Build RPC deamon
On the same terminal folder you can build the RPC daemon.

```bash
make rpcdaemon
```

## 3. Start Node 1
If evereything is fine, by changing directory to erigon/build/bin you will see the two exec for erigon and rpc daemon.
If everything is fine, by changing directory to erigon/build/bin you will see the two exec for erigon and rpc daemon.
On the terminal you can type the following command to start node1.

```bash
Expand All @@ -31,9 +31,9 @@ On the terminal you can type the following command to start node1.
* chain : Tells that we want to run Erigon in the dev chain.
* private.api.addr=localhost:9090 : Tells where Eigon is going to listen for connections.
* mine : Add this if you want the node to mine.
* dev.period <number-of-seconds>: Add this to specify the timing interval amongst blocks. Number of seconds MUST be > 0 (if you want empty blocks) otherwise the default value 0 does not allow mining of empty blocks.
* dev.period <number-of-seconds>: Add this to specify the timing interval among blocks. Number of seconds MUST be > 0 (if you want empty blocks) otherwise the default value 0 does not allow mining of empty blocks.

The result will be somenthing like this:
The result will be something like this:

<img width="1652" alt="Node 1 start" src="https://user-images.githubusercontent.com/24697803/140478108-c93a131d-745d-45ac-a76f-9bb808e504df.png">

Expand Down Expand Up @@ -72,7 +72,7 @@ To check if the nodes are connected, you can go to the log of both the nodes and

``` [p2p] GoodPeers eth66=1 ```

Note: this might take a while it is not istantaneus, also if you see a 1 on either one of the two the node is fine.
Note: this might take a while it is not instantaneous, also if you see a 1 on either one of the two the node is fine.



Expand Down Expand Up @@ -110,10 +110,10 @@ Other commands you can try:
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id":83}' localhost:8545
```

## 7. Send a transaction with metamask
## 7. Send a transaction with MetaMask

Finally, we want to try sending a transaction between two accounts.
For this example we will use dev accounts retrived from Erigon code:
For this example we will use dev accounts retrieved from Erigon code:

* Account with balance (Dev 1)
* address = ``` 0x67b1d87101671b127f5f8714789C7192f7ad340e ```
Expand All @@ -125,7 +125,7 @@ Other commands you can try:



Now from metamask, you can import Dev 1 , and then send a transaction to pass some ethers from Dev 1 to Dev 2.
Now from MetaMask, you can import Dev 1 , and then send a transaction to pass some ethers from Dev 1 to Dev 2.
From the RPC daemon terminal, you will see something like this

<img width="1633" alt="Transaction example" src="https://user-images.githubusercontent.com/24697803/140479146-94b6e66c-22b7-4d8a-a160-b3643d27b612.png">
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/testinprod-io/op-erigon.git" \
org.label-schema.version=$VERSION

ENTRYPOINT ["erigon"]
2 changes: 2 additions & 0 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/testinprod-io/op-erigon.git" \
org.label-schema.version=$VERSION

ENTRYPOINT ["erigon"]
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,12 @@ db-tools:
devnet-up:
./build/bin/erigon --datadir=.dev --chain=op-dev --private.api.addr=localhost:9090 --mine --http.port=8545 --externalcl --log.console.verbosity=4 --genesis.path=./genesis-l2.json

## test: run unit tests with a 50s timeout
test-state:
$(CGO_CFLAGS) GODEBUG=cgocheck=0 $(GO) test $(GO_FLAGS) --timeout 30m ./tests -tags $(BUILD_TAGS),integration -run TestState -v
## test: run unit tests with a 100s timeout
test:
$(GOTEST) --timeout 50s
$(GOTEST) --timeout 100s

test3:
$(GOTEST) --timeout 50s -tags $(BUILD_TAGS),erigon3
$(GOTEST) --timeout 100s -tags $(BUILD_TAGS),erigon3

## test-integration: run integration tests with a 30m timeout
test-integration:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,11 @@ node.

#### `RPC` ports

| Port | Protocol | Purpose | Expose |
|:----:|:--------:|:-----------------:|:-------:|
| 8545 | TCP | HTTP & WebSockets | Private |
| Port | Protocol | Purpose | Expose |
|:----:|:--------:|:---------------------------:|:-------:|
| 8545 | TCP | HTTP & WebSockets & GraphQL | Private |

Typically, 8545 is exposed only internally for JSON-RPC queries. Both HTTP and WebSocket connections are on the same
Typically, 8545 is exposed only internally for JSON-RPC queries. Both HTTP and WebSocket and GraphQL are on the same
port.

#### `sentry` ports
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func NewTestSimulatedBackendWithConfig(t *testing.T, alloc core.GenesisAlloc, co
func (b *SimulatedBackend) DB() kv.RwDB { return b.m.DB }
func (b *SimulatedBackend) Agg() *state2.AggregatorV3 { return b.m.HistoryV3Components() }
func (b *SimulatedBackend) BlockReader() *snapshotsync.BlockReaderWithSnapshots {
return snapshotsync.NewBlockReaderWithSnapshots(b.m.BlockSnapshots)
return snapshotsync.NewBlockReaderWithSnapshots(b.m.BlockSnapshots, b.m.TransactionsV3)
}
func (b *SimulatedBackend) HistoryV3() bool { return b.m.HistoryV3 }
func (b *SimulatedBackend) Engine() consensus.Engine { return b.m.Engine }
Expand Down
61 changes: 48 additions & 13 deletions cl/clparams/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const (
VersionLength int = 4
MaxChunkSize uint64 = 1 << 20 // 1 MiB
ReqTimeout time.Duration = 1 * time.Second
RespTimeout time.Duration = 15 * time.Second
RespTimeout time.Duration = 1 * time.Second
)

var (
Expand Down Expand Up @@ -420,14 +420,14 @@ type BeaconChainConfig struct {

// Fork-related values.
GenesisForkVersion uint32 `yaml:"GENESIS_FORK_VERSION" spec:"true"` // GenesisForkVersion is used to track fork version between state transitions.
AltairForkVersion uint32 `yaml:"ALTAIR_FORK_VERSION" spec:"true"` // AltairForkVersion is used to represent the fork version for altair.
AltairForkEpoch uint64 `yaml:"ALTAIR_FORK_EPOCH" spec:"true"` // AltairForkEpoch is used to represent the assigned fork epoch for altair.
BellatrixForkVersion uint32 `yaml:"BELLATRIX_FORK_VERSION" spec:"true"` // BellatrixForkVersion is used to represent the fork version for bellatrix.
BellatrixForkEpoch uint64 `yaml:"BELLATRIX_FORK_EPOCH" spec:"true"` // BellatrixForkEpoch is used to represent the assigned fork epoch for bellatrix.
ShardingForkVersion uint32 `yaml:"SHARDING_FORK_VERSION" spec:"true"` // ShardingForkVersion is used to represent the fork version for sharding.
ShardingForkEpoch uint64 `yaml:"SHARDING_FORK_EPOCH" spec:"true"` // ShardingForkEpoch is used to represent the assigned fork epoch for sharding.
CapellaForkVersion uint32 `yaml:"CAPELLA_FORK_VERSION" spec:"true"` // CapellaForkVersion is used to represent the fork version for capella.
CapellaForkEpoch uint64 `yaml:"CAPELLA_FORK_EPOCH" spec:"true"` // CapellaForkEpoch is used to represent the assigned fork epoch for capella.
AltairForkVersion uint32 `yaml:"ALTAIR_FORK_VERSION" spec:"true"` // AltairForkVersion is used to represent the fork version for Altair.
AltairForkEpoch uint64 `yaml:"ALTAIR_FORK_EPOCH" spec:"true"` // AltairForkEpoch is used to represent the assigned fork epoch for Altair.
BellatrixForkVersion uint32 `yaml:"BELLATRIX_FORK_VERSION" spec:"true"` // BellatrixForkVersion is used to represent the fork version for Bellatrix.
BellatrixForkEpoch uint64 `yaml:"BELLATRIX_FORK_EPOCH" spec:"true"` // BellatrixForkEpoch is used to represent the assigned fork epoch for Bellatrix.
CapellaForkVersion uint32 `yaml:"CAPELLA_FORK_VERSION" spec:"true"` // CapellaForkVersion is used to represent the fork version for Capella.
CapellaForkEpoch uint64 `yaml:"CAPELLA_FORK_EPOCH" spec:"true"` // CapellaForkEpoch is used to represent the assigned fork epoch for Capella.
DenebForkVersion uint32 `yaml:"DENEB_FORK_VERSION" spec:"true"` // DenebForkVersion is used to represent the fork version for Deneb.
DenebForkEpoch uint64 `yaml:"DENEB_FORK_EPOCH" spec:"true"` // DenebForkEpoch is used to represent the assigned fork epoch for Deneb.

ForkVersionSchedule map[[VersionLength]byte]uint64 // Schedule of fork epochs by version.
ForkVersionNames map[[VersionLength]byte]string // Human-readable names of fork versions.
Expand Down Expand Up @@ -673,8 +673,8 @@ var MainnetBeaconConfig BeaconChainConfig = BeaconChainConfig{
BellatrixForkEpoch: 144869,
CapellaForkVersion: 0x03000000,
CapellaForkEpoch: math.MaxUint64,
ShardingForkVersion: 0x04000000,
ShardingForkEpoch: math.MaxUint64,
DenebForkVersion: 0x04000000,
DenebForkEpoch: math.MaxUint64,

// New values introduced in Altair hard fork 1.
// Participation flag indices.
Expand Down Expand Up @@ -767,6 +767,8 @@ func sepoliaConfig() BeaconChainConfig {
cfg.AltairForkVersion = 0x90000070
cfg.BellatrixForkEpoch = 100
cfg.BellatrixForkVersion = 0x90000071
cfg.CapellaForkEpoch = 56832
cfg.CapellaForkVersion = 0x90000072
cfg.TerminalTotalDifficulty = "17000000000000000"
cfg.DepositContractAddress = "0x7f02C3E3c98b133055B8B348B2Ac625669Ed295D"
cfg.InitializeForkSchedule()
Expand All @@ -784,10 +786,11 @@ func goerliConfig() BeaconChainConfig {
cfg.DepositNetworkID = uint64(GoerliNetwork)
cfg.AltairForkEpoch = 36660
cfg.AltairForkVersion = 0x1001020
cfg.CapellaForkVersion = 0x03001020
cfg.ShardingForkVersion = 0x40001020
cfg.BellatrixForkEpoch = 112260
cfg.BellatrixForkVersion = 0x02001020
cfg.CapellaForkEpoch = 162304
cfg.CapellaForkVersion = 0x03001020
cfg.DenebForkVersion = 0x40001020
cfg.TerminalTotalDifficulty = "10790000"
cfg.DepositContractAddress = "0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b"
cfg.InitializeForkSchedule()
Expand Down Expand Up @@ -846,6 +849,32 @@ func chiadoConfig() BeaconChainConfig {
return cfg
}

func (b *BeaconChainConfig) GetMinSlashingPenaltyQuotient(version StateVersion) uint64 {
switch version {
case Phase0Version:
return b.MinSlashingPenaltyQuotient
case AltairVersion:
return b.MinSlashingPenaltyQuotientAltair
case BellatrixVersion:
return b.MinSlashingPenaltyQuotientBellatrix
default:
panic("not implemented")
}
}

func (b *BeaconChainConfig) GetPenaltyQuotient(version StateVersion) uint64 {
switch version {
case Phase0Version:
return b.InactivityPenaltyQuotient
case AltairVersion:
return b.InactivityPenaltyQuotientAltair
case BellatrixVersion:
return b.InactivityPenaltyQuotientBellatrix
default:
panic("not implemented")
}
}

// Beacon configs
var BeaconConfigs map[NetworkType]BeaconChainConfig = map[NetworkType]BeaconChainConfig{
MainnetNetwork: mainnetConfig(),
Expand Down Expand Up @@ -904,3 +933,9 @@ func GetCheckpointSyncEndpoint(net NetworkType) string {
func EmbeddedSupported(id uint64) bool {
return id == 1 || id == 5 || id == 11155111 || id == 100 || id == 10200
}

// Subset of supported networks where embedded CL is stable enough
// (sufficient number of light-client peers) as to be enabled by default
func EmbeddedEnabledByDefault(id uint64) bool {
return id == 1 || id == 5 || id == 11155111
}
4 changes: 4 additions & 0 deletions cl/cltypes/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ func (agg *SyncAggregate) DecodeSSZ(buf []byte) error {
return nil
}

func (agg *SyncAggregate) DecodeSSZWithVersion(buf []byte, _ int) error {
return agg.DecodeSSZ(buf)
}

func (agg *SyncAggregate) EncodingSizeSSZ() int {
return 160
}
Expand Down
5 changes: 5 additions & 0 deletions cl/cltypes/attestations.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ type AttestationData struct {
Target *Checkpoint
}

func (a *AttestationData) Equal(other *AttestationData) bool {
return a.Slot == other.Slot && a.Index == other.Index && a.BeaconBlockHash == other.BeaconBlockHash &&
a.Source.Equal(other.Source) && a.Target.Equal(other.Target)
}

// EncodeSSZ ssz marshals the AttestationData object
func (a *AttestationData) EncodeSSZ(dst []byte) ([]byte, error) {
buf := dst
Expand Down
19 changes: 11 additions & 8 deletions cl/cltypes/beacon_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ func (b *BeaconBody) EncodingSizeSSZ() (size int) {
return
}

func (b *BeaconBody) DecodeSSZ(buf []byte, version clparams.StateVersion) error {
b.Version = version
func (b *BeaconBody) DecodeSSZWithVersion(buf []byte, version int) error {
b.Version = clparams.StateVersion(version)
var err error

if len(buf) < b.EncodingSizeSSZ() {
Expand All @@ -295,7 +295,7 @@ func (b *BeaconBody) DecodeSSZ(buf []byte, version clparams.StateVersion) error
offsetDeposits := ssz_utils.DecodeOffset(buf[212:])
offsetExits := ssz_utils.DecodeOffset(buf[216:])
// Decode sync aggregate if we are past altair.
if version >= clparams.AltairVersion {
if b.Version >= clparams.AltairVersion {
if len(buf) < 380 {
return ssz_utils.ErrLowBufferSize
}
Expand All @@ -307,12 +307,12 @@ func (b *BeaconBody) DecodeSSZ(buf []byte, version clparams.StateVersion) error

// Execution Payload offset if past bellatrix.
var offsetExecution uint32
if version >= clparams.BellatrixVersion {
if b.Version >= clparams.BellatrixVersion {
offsetExecution = ssz_utils.DecodeOffset(buf[380:])
}
// Execution to BLS changes
var blsChangesOffset uint32
if version >= clparams.CapellaVersion {
if b.Version >= clparams.CapellaVersion {
blsChangesOffset = ssz_utils.DecodeOffset(buf[384:])
}
// Decode Proposer slashings
Expand Down Expand Up @@ -463,7 +463,7 @@ func (b *BeaconBlock) EncodingSizeSSZ() int {
return 80 + b.Body.EncodingSizeSSZ()
}

func (b *BeaconBlock) DecodeSSZ(buf []byte, version clparams.StateVersion) error {
func (b *BeaconBlock) DecodeSSZWithVersion(buf []byte, version int) error {
if len(buf) < b.EncodingSizeSSZ() {
return ssz_utils.ErrLowBufferSize
}
Expand All @@ -472,7 +472,7 @@ func (b *BeaconBlock) DecodeSSZ(buf []byte, version clparams.StateVersion) error
copy(b.ParentRoot[:], buf[16:])
copy(b.StateRoot[:], buf[48:])
b.Body = new(BeaconBody)
return b.Body.DecodeSSZ(buf[84:], version)
return b.Body.DecodeSSZWithVersion(buf[84:], version)
}

func (b *BeaconBlock) HashSSZ() ([32]byte, error) {
Expand All @@ -489,6 +489,9 @@ func (b *BeaconBlock) HashSSZ() ([32]byte, error) {
}, 8)
}

func (*BeaconBlock) DecodeSSZ(buf []byte) error {
panic("A")
}
func (b *SignedBeaconBlock) EncodeSSZ(buf []byte) ([]byte, error) {
dst := buf
var err error
Expand Down Expand Up @@ -517,7 +520,7 @@ func (b *SignedBeaconBlock) DecodeSSZWithVersion(buf []byte, s int) error {
return ssz_utils.ErrLowBufferSize
}
copy(b.Signature[:], buf[4:100])
return b.Block.DecodeSSZ(buf[100:], clparams.StateVersion(s))
return b.Block.DecodeSSZWithVersion(buf[100:], s)
}

func (b *SignedBeaconBlock) HashSSZ() ([32]byte, error) {
Expand Down
4 changes: 4 additions & 0 deletions cl/cltypes/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ type Checkpoint struct {
Root libcommon.Hash
}

func (c *Checkpoint) Equal(other *Checkpoint) bool {
return c.Epoch == other.Epoch && c.Root == other.Root
}

func (c *Checkpoint) EncodeSSZ(buf []byte) ([]byte, error) {
return append(buf, append(ssz_utils.Uint64SSZ(c.Epoch), c.Root[:]...)...), nil
}
Expand Down
8 changes: 8 additions & 0 deletions cl/cltypes/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func (*SignedAggregateAndProof) Clone() clonable.Clonable {
return &SignedAggregateAndProof{}
}

func (*SyncAggregate) Clone() clonable.Clonable {
return &SyncAggregate{}
}

func (*SignedVoluntaryExit) Clone() clonable.Clonable {
return &SignedVoluntaryExit{}
}
Expand Down Expand Up @@ -74,6 +78,10 @@ func (*LightClientBootstrap) Clone() clonable.Clonable {
return &LightClientBootstrap{}
}

func (*BeaconBlock) Clone() clonable.Clonable {
return &BeaconBlock{}
}

func (*LightClientUpdate) Clone() clonable.Clonable {
return &LightClientUpdate{}
}
Loading

0 comments on commit 27d4e93

Please sign in to comment.