Skip to content

Commit

Permalink
execute the syncValidatorsDataTx before filling the block (#69)
Browse files Browse the repository at this point in the history
* execute the syncValidatorsDataTx before filling the block
* fix updateOnInit test in the stake manager tests
* update hydra build docs
  • Loading branch information
Vitomir2 authored Oct 24, 2024
1 parent f454c6b commit c59b9ea
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
24 changes: 12 additions & 12 deletions consensus/polybft/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ func (f *fsm) BuildProposal(currentRound uint64) ([]byte, error) {
err,
)
}
} else if f.isStartOfEpoch && f.syncValidatorsDataInput != nil {
tx, err := f.createSyncValidatorsDataTx()
if err != nil {
return nil, err
}

if err := f.blockBuilder.WriteTx(tx); err != nil {
return nil, fmt.Errorf(
"failed to apply sync validators data transaction: %w",
err,
)
}
}

if f.config.IsBridgeEnabled() {
Expand All @@ -251,18 +263,6 @@ func (f *fsm) BuildProposal(currentRound uint64) ([]byte, error) {
}

extra.Validators = f.newValidatorsDelta
} else if f.isStartOfEpoch && f.syncValidatorsDataInput != nil {
tx, err := f.createSyncValidatorsDataTx()
if err != nil {
return nil, err
}

if err := f.blockBuilder.WriteTx(tx); err != nil {
return nil, fmt.Errorf(
"failed to apply sync validators data transaction: %w",
err,
)
}
}

currentValidatorsHash, err := f.validators.Accounts().Hash()
Expand Down
16 changes: 8 additions & 8 deletions consensus/polybft/stake_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,18 +621,18 @@ func TestStakeManager_UpdateOnInit(t *testing.T) {
Once()
bcMock.On("GetHeaderByNumber", uint64(1)).
Return(&types.Header{Number: 1, Hash: header1Hash}, true).
Twice()
Once()
bcMock.On("GetHeaderByNumber", uint64(2)).
Return(&types.Header{Number: 2, Hash: header2Hash}, true).
Twice()
Once()
bcMock.On("GetHeaderByNumber", uint64(3)).
Return(&types.Header{Number: 3, Hash: header3Hash}, true).
Twice()
Once()
bcMock.On("GetHeaderByNumber", uint64(4)).
Return(&types.Header{Number: 4, Hash: header4Hash}, true).
Twice()
Once()

bcMock.On("GetReceiptsByHash", header1Hash).Return([]*types.Receipt(nil), nil).Twice()
bcMock.On("GetReceiptsByHash", header1Hash).Return([]*types.Receipt(nil), nil).Once()
bcMock.On("GetReceiptsByHash", header2Hash).Return([]*types.Receipt{
{
Status: &success,
Expand All @@ -655,7 +655,7 @@ func TestStakeManager_UpdateOnInit(t *testing.T) {
),
},
},
}, nil).Twice()
}, nil).Once()
bcMock.On("GetReceiptsByHash", header3Hash).Return([]*types.Receipt{
{
Status: &success,
Expand All @@ -668,7 +668,7 @@ func TestStakeManager_UpdateOnInit(t *testing.T) {
),
},
},
}, nil).Twice()
}, nil).Once()
bcMock.On("GetReceiptsByHash", header4Hash).Return([]*types.Receipt{{},
{
Status: &success,
Expand All @@ -680,7 +680,7 @@ func TestStakeManager_UpdateOnInit(t *testing.T) {
),
},
},
}, nil).Twice()
}, nil).Once()

_, err := newStakeManager(
hclog.NewNullLogger(),
Expand Down
14 changes: 7 additions & 7 deletions h_docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o hydra -a -installsuffix cgo ma
sudo mv hydra /usr/local/bin
```

## Build devnet node docker image
## Build the hydra client's docker image

1. Build node source code

```
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o hydra -a -installsuffix cgo main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o hydra -a -installsuffix cgo main.go
```

2. Build node image
Expand All @@ -46,21 +46,21 @@ Use Docker Desktop or:
docker push rsantev/hydra-client:latest
```

4. Build hydrag devnet image
1. Build hydragon devnet (or testnet) image

```
docker build --platform linux/amd64 -t rsantev/hydrag-devnet:latest ./h_devnet
docker build --platform linux/amd64 -t rsantev/hydragon-devnet:latest ./h_devnet
```

5. Push hydrag devnet image to DockerHub
5. Push hydragon devnet image to DockerHub

```
docker push rsantev/hydrag-devnet:latest
docker push rsantev/hydragon-devnet:latest
```

### Build devnet cluster docker image

4. Build hydrag devnet cluster image
4. Build hydragon devnet cluster image

```
cd h_devnet/devnet_cluster \
Expand Down

0 comments on commit c59b9ea

Please sign in to comment.