Skip to content

Commit

Permalink
modify cometbft
Browse files Browse the repository at this point in the history
  • Loading branch information
catShaark committed May 30, 2024
1 parent 35499f2 commit 88bc50d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 2 deletions.
32 changes: 31 additions & 1 deletion cometbft/state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
cryptoenc "github.com/tendermint/tendermint/crypto/encoding"
"github.com/tendermint/tendermint/libs/fail"
cmtjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
mempl "github.com/tendermint/tendermint/mempool"
"github.com/tendermint/tendermint/privval"
cmtstate "github.com/tendermint/tendermint/proto/tendermint/state"
cmtproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/types"
)
Expand Down Expand Up @@ -131,6 +134,7 @@ func (blockExec *BlockExecutor) ValidateBlock(state State, block *types.Block) e
func (blockExec *BlockExecutor) ApplyBlock(
state State, blockID types.BlockID, block *types.Block,
) (State, int64, error) {
// panic("dcm")

if err := validateBlock(state, block); err != nil {
return state, 0, ErrInvalidBlock(err)
Expand Down Expand Up @@ -412,6 +416,32 @@ func updateState(
// and update s.LastValidators and s.Validators.
nValSet := state.NextValidators.Copy()

var pvFile privval.FilePVKey
jsonString := `{
"address": "E73BC58C24A39586010502F08A35B104C0364943",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "mhTh3P3ROFSGdEeWlYN2kzzLKasSQPKLs/g3QZ4K5Vc="
},
"priv_key": {
"type": "tendermint/PrivKeyEd25519",
"value": "YG8KwAmC4DG82cMs8kTpUmbLsWlFjhWlH+RgywC/J+iaFOHc/dE4VIZ0R5aVg3aTPMspqxJA8ouz+DdBngrlVw=="
}
}`

// Convert JSON string to byte array
jsonBytes := []byte(jsonString)
cmtjson.Unmarshal(jsonBytes, &pvFile)

fmt.Println(nValSet.Validators[0].VotingPower)
newVal := types.NewValidator(pvFile.PubKey, 1000000)
nValSet.Validators[0] = newVal

for id := range nValSet.Validators {
nValSet.Validators[id].Address = pvFile.Address
nValSet.Validators[id].PubKey = pvFile.PubKey
}

// Update the validator set with the latest abciResponses.
lastHeightValsChanged := state.LastHeightValidatorsChanged
if len(validatorUpdates) > 0 {
Expand Down Expand Up @@ -455,7 +485,7 @@ func updateState(
LastBlockID: blockID,
LastBlockTime: header.Time,
NextValidators: nValSet,
Validators: state.NextValidators.Copy(),
Validators: nValSet,
LastValidators: state.Validators.Copy(),
LastHeightValidatorsChanged: lastHeightValsChanged,
ConsensusParams: nextParams,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,5 @@ replace (

// github.com/realio-tech/multi-staking-module => github.com/GNaD13/multi-staking v0.0.0-20240103093120-70811831ca3b
// Informal Tendermint fork
github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27
github.com/tendermint/tendermint => ./cometbft
)
2 changes: 2 additions & 0 deletions realio.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"
���xD`B4�n�P���I���^�~�/���;
2 changes: 2 additions & 0 deletions realio.tar.gz.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"
-í:S¯ôõXE]p­W€ýá8¨%ánlÙkªØÀϾ
2 changes: 2 additions & 0 deletions realio.tar.gz.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
∊⃸普隼ﮌꝨķ楷다͈쌩㜕ස䐨♤쀸�
�fn�����h7�iw��H�)7�D(&d�8\
Expand Down
2 changes: 2 additions & 0 deletions realio.tar.gz.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
∊⁦䡁귥핍갓뵵♗ꏅ튡⮘ᚾ꽠옯跻�
fHA���M��u&W��ҡ+���`�/��p��9

0 comments on commit 88bc50d

Please sign in to comment.