Skip to content

Commit 31752f2

Browse files
Frozenmur-me
andauthored
Update 1.10: London and Berlin forks (#4953)
* Add Docker support for Go tests with new Makefile target and Dockerfile * Refactor Dockerfile for Go tests: remove unnecessary commands and ensure proper dependency installation * update 1.9.25 * update 1.9.25 * update 1.9.25 * update 1.9.25 * Fixed code * Fixed StructLog * compiled * BlockContext * Fixed interpreter. * Fixed tests partially. * Passed unit tests. * Fixed imports * Removed commented block * Fixed StructLog initialization * Fixed formatting * Removed unused * Fixed code generation * Removed intpool * Fixed rpc override.go * Fixed rpc override_test.go * Add gas prices for BLS12-381 elliptic curve operations * Add gas discount table for BLS12-381 G1 and G2 multi exponentiation operations * Refactor CaptureStart method to remove unused EVM parameter * Fix chain rules check in readonly mode to use Byzantium instead of S3 * Update gas calculations to reflect EIP-150 and EIP-158 rules * Add EIP flags for gas calculations in config * Refactor precompiled contracts to use WriteCapablePrecompiledContract interface and add BLS12-381 precompile implementations * Refactor precompiled contract tests to use RequiredGas method with updated parameters * Add readOnly parameter to RunPrecompiledContract and implement IsWrite method for precompiled contracts * Update RunPrecompiledContract calls in tests to include readOnly parameter * Update RunPrecompiledContract calls in tests to include gas parameter * Add BLS12-381 failure test cases and implement IsWrite method for dummy precompile * Fix code hash retrieval in contract execution for precompiled contracts * Handle validator addresses in EVM to avoid using code and codeHash fields * Fixed issue with tests running. * Remove commented-out test data for bn256 addition and scalar multiplication precompiled contracts * Refactor precompiled contracts to use wrapper for write capability and remove unused gas parameters * Refactor precompiled contracts to use wrapper for write capability and remove unused gas parameters * Update EVM initialization in TestEIP2537Precompile to include BlockContext and TxContext * Skip tests for EIP 2565 precompiled modexp implementation * Fix gas calculation in precompiled contract tests to ensure accurate error handling * Update IsWrite method in precompiled contracts to reflect correct write capability and add tests for validation * Refactor precompiled contract tests to remove unused variables and improve error handling * Fix read-only write protection check and enhance precompiled contract tests * Reorder precompiled contract mappings for improved readability * Uncomment execution reverted error in errors.go and update related comments * update 1.9.25 * BlockContext * Fixed imports * Added access list. * Provided eips. * Add EIP implementations and Harmony-specific support to EVM Enhanced the EVM with support for EIPs 3855, 3529, and 3198, including new opcodes and gas optimizations. Integrated Harmony-specific functionalities such as validator checks, staking-related operations, and cross-shard transfer support. Refactored gas calculation logic to accommodate both EIP and Harmony enhancements, ensuring extensibility and improved maintenance. * Add new function signatures for validator and staking precompiles in EVM * Add RosettaLogAddressItem struct and RosettaTracer interface to EVM * Remove obsolete error definitions and add new error types for EVM execution * Refactor opcode definitions for clarity and consistency in opcodes.go * Refactor contract code by removing unused validJumpSubdest function and simplifying GetByte method * Add TODO comment to check precompiles in EVM precompile method * Refactor gas calculations and update function names for clarity in gas_table.go * Refactor EVM context by removing unused BlockContext and TxContext types in evm.go * Refactor EVM code by updating chain configuration and simplifying contract execution logic * Uncomment execution reverted error and clean up commented code in EVM * Add WithDataCopyFix field to contract struct for EVM execution * Use ErrWriteProtection constant for error handling in contracts.go * Refactor EVM contract handling by updating precompile execution logic and improving code structure * Update chain configuration to include London hard fork in precompiles * Refactor opAdd function to use ScopeContext for stack operations * Update EVM instruction handling for S3 chain rules and adjust difficulty operation * Fix EVM configuration reference for debugging in evm.go * Add gas parameters for KECCAK256 operations in protocol_params.go * Rename memorySha3 function to memoryKeccak256 for clarity * Rename memorySha3 function to memoryKeccak256 for clarity * Update SetCode method call to include 'false' parameter for state database * Refactor gas usage validation in interpreter to simplify logic * Comment out StateDB.Prepare() calls in runtime and state_transition for EIP 1153 * Add SetTxContext method to reset EVM with new transaction context * Remove unnecessary return statement in CaptureEnd method of ParityBlockTracer * Implement stubs for transaction capture methods in ParityBlockTracer * Refactor ParityBlockTracer to replace uint256.Int with big.Int for value handling * Update Tracer methods to include EVM context in state capture * Fix CaptureFault method to include memory and stack in fault logging * Enhance state capture in interpreter by including memory, stack, and contract details * Fix logger to use big.Int for stack logging and remove unused PaddedBytes function * Refactor RosettaBlockTracer to use big.Int for value initialization * Refactor RosettaLogItem to use uint256 for value representation * Update CaptureStart method to return an error for improved error handling * Refactor tracer to use uint256 for stack representation * Add CaptureEnter and CaptureExit methods to Tracer for enhanced tracing functionality * Add CaptureEnter method to StructLogger and refactor stack logging to use uint256 * Refactor JSONLogger methods and improve stack logging functionality * Refactor JSONLogger methods and improve stack logging functionality * Refactor block tracer tests to replace uint256 with big.Int for value handling * Refactor EVMInterpreter initialization to use env.Config instead of env.vmConfig * Refactor EVMInterpreter initialization to use env.Config instead of env.vmConfig * Refactor test utility functions to improve clarity and update file writing method * Refactor test utility functions to improve clarity and update file writing method * Refactor instructions tests to replace callCtx with ScopeContext and simplify stack handling * Add storage field to StructLogger for improved state management * Refactor TestStoreCapture to remove unused return stack parameter * Fix TestBigToHash to dereference uint256.NewInt for correct comparison * Update ChainConfig.Rules to accept isMerge parameter and adjust runtime usage * Remove isMerge parameter from ChainConfig.Rules and clean up related code * Fix uint256ToHash function to use common.BigToHash and enhance TestBigToHash with additional test cases * Fix uint256ToHash function to use common.BigToHash and enhance TestBigToHash with additional test cases * Refactor EVM contract initialization to streamline code execution flow * Comment out Stack field in structLogMarshaling for clarity * Rename variable for clarity in GetState method * Skip TestStoreCapture due to misconfiguration * Update go:generate directive to specify gencodec version * Update go:generate directive to simplify command for AccessTuple * Add JSON marshaling and unmarshaling for AccessTuple and StructLog * Refactored consensus decider access and improved thread safety. * Refactored consensus decider access and improved thread safety. * Feature: transient storage (#4950) * Transient storage functionality * Commented code block in blockchain_test.go * Refactor state transition rules and remove commented-out Prepare method * Remove commented-out code block in chain_makers_test.go * Remove unnecessary parameter from ChainConfig.Rules calls in runtime.go * Refactor ActivePrecompiles function to use rules parameter instead of evm.chainRules * Refactor state transition preparation to use statedb.Prepare method * Feature: replaced duktape with goja (#4958) * Refactor tracing implementation to replace duktape with goja and clean up unused code * Update transaction context handling in tracer to use SetTxContext method * Refactor tracing implementation to use hmyapi for state and block overrides * Refactor trace event subscriptions to use events package and clean up unused code * fix(ci): change if condition to build all RPs without checkin a base branch, previously only dev and main * Refactor jsTracer methods to improve parameter handling and remove unused context * Refactor logger_test.go to update import paths for Harmony package * Refactor tracer_test.go to update import paths and improve state handling * Refactor tracer_test.go to comment out a test case for bad arguments to stack peeks * Refactor Makefile to run specific test for TestTracer in go-test target * Refactor Makefile to run TestTracer specifically in the js tracer directory * Refactor tracer_test.go to improve error handling and logging in test cases * Refactor tracer_test.go to simplify error message formatting in test cases * Refactor Makefile to enable verbose output for TestTracer tests * Refactor tracer_test.go to enhance logging of tracer results during test execution * Add logging for contract code in EVMInterpreter Run method * Add debug logging for contract input in EVMInterpreter Run method * Enable debug mode in EVM configuration for enhanced tracing during tests * Refactor tracer_test.go to improve test case formatting and readability * Refactor tracer_test.go to comment out unused test cases for clarity * Refactor tracer_test.go to uncomment and enable relevant test cases for improved coverage * Refactor tracer_test.go to add a test case for intrinsic gas calculation * Refactor goja.go to store intrinsic gas calculation in context * Refactor tracer_test.go to improve test case clarity and formatting * Refactor goja.go to update gasUsed assignment and add time context * Refactor goja.go to remove unused gasUsed assignment in CaptureTxEnd * Refactor tracer_test.go to improve test case formatting and clarity * Refactor tracer_test.go to simplify error reporting in test cases * Refactor tracer_test.go to remove unnecessary debug print statements * Refactor interpreter.go to remove unused debug print statement * Refactor Makefile to enhance go test command with race detection and vetting * Refactor gen_structlog.go to add omitempty for Memory and ReturnData fields and reorder CallerAddress and ContractAddress * Refactor logger.go to simplify go:generate command for gencodec * Refactor Makefile to run specific tracer tests and enhance tracer result logging * Refactor tracer_test.go to comment out specific test cases for memory access and intrinsic gas * Refactor Makefile to enable verbose output for tracer tests * Refactor tracer_test.go to print tracer results as a string for better readability * Refactor tracer_test.go to enhance logging of tracer results for improved debugging * Refactor tracer.go to log trace results and errors for improved visibility * Add debug logging for tracer type and configuration in tracer.go * Add logging for execution results in logger.go for improved traceability * Add logging for gas limit and remaining gas in CaptureTxEnd for better traceability * Add debug tracing for transaction start and end in state_transition.go * Add contract and caller address to StructLog for enhanced logging * Add caller and contract addresses to structured logs for enhanced traceability * Improve error message for tracer not found in tracers.go * Enhance error message for tracer not found in tracers.go to include lookup count * Add native tracers for transaction analysis: fourByteTracer, callTracer, prestateTracer, revertReasonTracer, and noopTracer * Add debug log for lookup registration count in tracers.go * Add panic message for unregistered JS tracer and implement RegisterLookupCount function * Add panic message in init function for debugging purposes * Update import path for tracers to use Harmony's package * Import JS tracers package in hmy.go * Refactor import paths to use Harmony's core and tracers packages * Remove debug panic statements from init function in goja.go * Add time field to callFrame struct in call.go * Clean up tracer_test.go by removing unnecessary debug print statements * Update contract code in tracer_test.go to use STOP instruction * Update logger fields to be omitempty and adjust test expectations * Remove rosetta checker from Travis CI configuration * Update CallerAddress and ContractAddress fields to be omitempty in gen_structlog.go --------- Co-authored-by: Uladzislau Muraveika <[email protected]> * Refactor: remove unused function and clean up tracer code * Refactor: remove unused testBackend struct and related functions * Refactor: improve Makefile test command and enhance state transition logic * Refactor: fix contract creation condition in state transition logic * Transient storage additional tests. (#4967) * Test: add transient storage opcodes test case * Refactor: update go test command to run specific transient storage opcodes test * Refactor: update go test command to run specific transient storage opcodes test * Refactor: configure EVM with ExtraEips for transient storage opcodes * Refactor: implement EIP-1153 for transient storage opcodes TLOAD and TSTORE * Refactor: update contract code to use PUSH1 for transient storage opcodes * Refactor: enhance TestTransientStorageOpcodes for opcode testing and update Makefile for improved test command * Refactor: add support for EIP-1153 transient storage in ChainConfig and update instruction set * Activation epoch for transient storage on devnet (#4968) * Test: add transient storage opcodes test case * Refactor: update go test command to run specific transient storage opcodes test * Refactor: update go test command to run specific transient storage opcodes test * Refactor: configure EVM with ExtraEips for transient storage opcodes * Refactor: implement EIP-1153 for transient storage opcodes TLOAD and TSTORE * Refactor: update contract code to use PUSH1 for transient storage opcodes * Refactor: enhance TestTransientStorageOpcodes for opcode testing and update Makefile for improved test command * Refactor: add support for EIP-1153 transient storage in ChainConfig and update instruction set * Activation epoch for transient storage --------- Co-authored-by: Uladzislau Muraveika <[email protected]>
1 parent 922ec9f commit 31752f2

File tree

133 files changed

+18890
-5843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+18890
-5843
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ env:
1313
- TEST="make"
1414
- TEST="bash ./scripts/travis_go_checker.sh"
1515
- TEST="bash ./scripts/travis_rpc_checker.sh"
16-
- TEST="bash ./scripts/travis_rosetta_checker.sh"
1716
- TEST="bash ./scripts/travis_pyhmy_checker.sh"
1817

19-
# We enable Travis on the main/dev branches or forked repositories here.
20-
# PRs workflow isn't affected by this condition
18+
# We enable Travis on the main/dev branches.
19+
# pull_request type includes both main repo/fork PR workflow
2120
if: >
22-
repo != harmony-one/harmony OR
21+
type = pull_request OR
2322
(repo = harmony-one/harmony AND (branch = main OR branch = dev))
2423
2524
# upgrade docker to latest stable version

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,6 @@ debug-delete-log:
269269
@echo "[WARN] - it needs sudo to remove folder created with loki docker image user"
270270
sudo rm -rf test/logs_aggregator/loki
271271

272+
273+
docker-go-test:
274+
docker run --rm -it -v "$PWD":/go/src/github.com/harmony-one/harmony frozen621/harmony-test bash -c 'make go-test'

Test.Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM golang:1.24
2+
3+
ARG ENV=dev
4+
5+
RUN apt-get update && \
6+
apt-get install -y build-essential make git curl libgmp-dev libssl-dev gcc g++ && \
7+
rm -rf /var/lib/apt/lists/*
8+
9+
WORKDIR /go/src/github.com/harmony-one
10+
11+
RUN git clone https://github.com/harmony-one/mcl.git && \
12+
git clone https://github.com/harmony-one/bls.git
13+
14+
RUN echo "Cloning branch: ${ENV}" && \
15+
git clone -b ${ENV} https://github.com/harmony-one/harmony.git && \
16+
cd harmony && \
17+
go mod tidy && \
18+
make deps
19+
20+
WORKDIR /go/src/github.com/harmony-one/harmony
21+
22+
CMD ["make", "go-test"]

consensus/consensus.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ type DownloadAsync interface {
6161

6262
// Consensus is the main struct with all states and data related to consensus process.
6363
type Consensus struct {
64-
decider quorum.Decider
6564
// FBFTLog stores the pbft messages and blocks during FBFT process
6665
fBFTLog *FBFTLog
6766
// current indicates what state a node is in
@@ -147,6 +146,10 @@ func (consensus *Consensus) Blockchain() core.BlockChain {
147146
return consensus.registry.GetBlockchain()
148147
}
149148

149+
func (consensus *Consensus) decider() quorum.Decider {
150+
return consensus.registry.GetQuorum()
151+
}
152+
150153
func (consensus *Consensus) FBFTLog() FBFT {
151154
return threadsafeFBFTLog{
152155
log: consensus.fBFTLog,
@@ -217,7 +220,7 @@ func (consensus *Consensus) BlocksNotSynchronized(reason string) {
217220
func (consensus *Consensus) VdfSeedSize() int {
218221
consensus.mutex.RLock()
219222
defer consensus.mutex.RUnlock()
220-
return int(consensus.decider.ParticipantsCount()) * 2 / 3
223+
return int(consensus.decider().ParticipantsCount()) * 2 / 3
221224
}
222225

223226
// GetPublicKeys returns the public keys
@@ -285,11 +288,11 @@ func New(
285288
Decider quorum.Decider, minPeers int, aggregateSig bool,
286289
) (*Consensus, error) {
287290
consensus := Consensus{
288-
mutex: &sync.RWMutex{},
289-
ShardID: shard,
290-
fBFTLog: NewFBFTLog(),
291-
current: NewState(Normal, shard),
292-
decider: Decider,
291+
mutex: &sync.RWMutex{},
292+
ShardID: shard,
293+
fBFTLog: NewFBFTLog(),
294+
current: NewState(Normal, shard),
295+
//decider: Decider,
293296
registry: registry,
294297
MinPeers: minPeers,
295298
AggregateSig: aggregateSig,
@@ -300,6 +303,7 @@ func New(
300303
dHelper: downloadAsync{},
301304
pendingCXReceipts: make(map[utils.CXKey]*types.CXReceiptsProof), // All the receipts received but not yet processed for Consensus
302305
}
306+
registry.SetQuorum(Decider)
303307

304308
if multiBLSPriKey != nil {
305309
consensus.priKey = multiBLSPriKey
@@ -338,7 +342,7 @@ func (consensus *Consensus) Registry() *registry.Registry {
338342
}
339343

340344
func (consensus *Consensus) Decider() quorum.Decider {
341-
return quorum.NewThreadSafeDecider(consensus.decider, consensus.mutex)
345+
return consensus.registry.GetQuorum()
342346
}
343347

344348
// InitConsensusWithValidators initialize shard state

consensus/consensus_service.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package consensus
22

33
import (
44
"math/big"
5+
"sync"
56
"time"
67

78
"github.com/ethereum/go-ethereum/common"
@@ -75,7 +76,7 @@ func (consensus *Consensus) signAndMarshalConsensusMessage(message *msg_pb.Messa
7576
}
7677

7778
func (consensus *Consensus) updatePublicKeys(pubKeys, allowlist []bls_cosi.PublicKeyWrapper) int64 {
78-
consensus.decider.UpdateParticipants(pubKeys, allowlist)
79+
consensus.decider().UpdateParticipants(pubKeys, allowlist)
7980
consensus.getLogger().Info().Msg("My Committee updated")
8081
for i := range pubKeys {
8182
consensus.getLogger().Info().
@@ -84,7 +85,7 @@ func (consensus *Consensus) updatePublicKeys(pubKeys, allowlist []bls_cosi.Publi
8485
Msg("Member")
8586
}
8687

87-
allKeys := consensus.decider.Participants()
88+
allKeys := consensus.decider().Participants()
8889
if len(allKeys) != 0 {
8990
consensus.setLeaderPubKey(&allKeys[0])
9091
consensus.getLogger().Info().
@@ -108,7 +109,7 @@ func (consensus *Consensus) updatePublicKeys(pubKeys, allowlist []bls_cosi.Publi
108109
if !consensus.isViewChangingMode() {
109110
consensus.resetViewChangeState()
110111
}
111-
return consensus.decider.ParticipantsCount()
112+
return consensus.decider().ParticipantsCount()
112113
}
113114

114115
// Sign on the hash of the message
@@ -136,7 +137,7 @@ func signConsensusMessage(message *msg_pb.Message,
136137
func (consensus *Consensus) updateBitmaps() {
137138
consensus.getLogger().Debug().
138139
Msg("[UpdateBitmaps] Updating consensus bitmaps")
139-
members := consensus.decider.Participants()
140+
members := consensus.decider().Participants()
140141
prepareBitmap := bls_cosi.NewMask(members)
141142
commitBitmap := bls_cosi.NewMask(members)
142143
multiSigBitmap := bls_cosi.NewMask(members)
@@ -153,9 +154,9 @@ func (consensus *Consensus) sendLastSignPower() {
153154
consensus.getLogger().Err(err).Msg("Leader not found in the committee")
154155
return
155156
}
156-
comm := getOrZero(consensus.decider.CurrentTotalPower(quorum.Commit))
157-
prep := getOrZero(consensus.decider.CurrentTotalPower(quorum.Prepare))
158-
view := consensus.decider.ComputeTotalPowerByMask(consensus.vc.GetViewIDBitmap(consensus.current.viewChangingID)).Int64()
157+
comm := getOrZero(consensus.decider().CurrentTotalPower(quorum.Commit))
158+
prep := getOrZero(consensus.decider().CurrentTotalPower(quorum.Prepare))
159+
view := consensus.decider().ComputeTotalPowerByMask(consensus.vc.GetViewIDBitmap(consensus.current.viewChangingID)).Int64()
159160
for view > 100 {
160161
view /= 10
161162
}
@@ -199,7 +200,7 @@ func (consensus *Consensus) resetState() {
199200

200201
consensus.current.blockHash = [32]byte{}
201202
consensus.current.block = []byte{}
202-
consensus.decider.ResetPrepareAndCommitVotes()
203+
consensus.decider().ResetPrepareAndCommitVotes()
203204
if consensus.prepareBitmap != nil {
204205
consensus.prepareBitmap.Clear()
205206
}
@@ -216,7 +217,7 @@ func (consensus *Consensus) IsValidatorInCommittee(pubKey bls.SerializedPublicKe
216217
}
217218

218219
func (consensus *Consensus) isValidatorInCommittee(pubKey bls.SerializedPublicKey) bool {
219-
return consensus.decider.IndexOf(pubKey) != -1
220+
return consensus.decider().IndexOf(pubKey) != -1
220221
}
221222

222223
// SetMode sets the mode of consensus
@@ -304,7 +305,7 @@ func (consensus *Consensus) setBlockNum(blockNum uint64) {
304305
// ReadSignatureBitmapPayload read the payload for signature and bitmap; offset is the beginning position of reading
305306
func (consensus *Consensus) ReadSignatureBitmapPayload(recvPayload []byte, offset int) (*bls_core.Sign, *bls_cosi.Mask, error) {
306307
consensus.mutex.RLock()
307-
members := consensus.decider.Participants()
308+
members := consensus.decider().Participants()
308309
consensus.mutex.RUnlock()
309310
return readSignatureBitmapPayload(recvPayload, offset, members)
310311
}
@@ -370,12 +371,12 @@ func (consensus *Consensus) updateConsensusInformation(reason string) Mode {
370371
isFirstTimeStaking := consensus.Blockchain().Config().IsStaking(nextEpoch) &&
371372
curHeader.IsLastBlockInEpoch() && !consensus.Blockchain().Config().IsStaking(curEpoch)
372373
haventUpdatedDecider := consensus.Blockchain().Config().IsStaking(curEpoch) &&
373-
consensus.decider.Policy() != quorum.SuperMajorityStake
374+
consensus.decider().Policy() != quorum.SuperMajorityStake
374375

375376
// Only happens once, the flip-over to a new Decider policy
376377
if isFirstTimeStaking || haventUpdatedDecider {
377-
decider := quorum.NewDecider(quorum.SuperMajorityStake, consensus.ShardID)
378-
consensus.decider = decider
378+
decider := quorum.NewThreadSafeDecider(quorum.NewDecider(quorum.SuperMajorityStake, consensus.ShardID), &sync.RWMutex{})
379+
consensus.registry.SetQuorum(decider)
379380
}
380381

381382
var committeeToSet *shard.Committee
@@ -448,7 +449,7 @@ func (consensus *Consensus) updateConsensusInformation(reason string) Mode {
448449
consensus.updatePublicKeys(pubKeys, shard.Schedule.InstanceForEpoch(nextEpoch).ExternalAllowlist())
449450

450451
// Update voters in the committee
451-
if _, err := consensus.decider.SetVoters(
452+
if _, err := consensus.decider().SetVoters(
452453
committeeToSet, epochToSet,
453454
); err != nil {
454455
consensus.getLogger().Error().
@@ -619,7 +620,7 @@ func (consensus *Consensus) selfCommit(payload []byte) error {
619620
return errGetPreparedBlock
620621
}
621622

622-
aggSig, mask, err := readSignatureBitmapPayload(payload, 32, consensus.decider.Participants())
623+
aggSig, mask, err := readSignatureBitmapPayload(payload, 32, consensus.decider().Participants())
623624
if err != nil {
624625
return errReadBitmapPayload
625626
}
@@ -643,7 +644,7 @@ func (consensus *Consensus) selfCommit(payload []byte) error {
643644
continue
644645
}
645646

646-
if _, err := consensus.decider.AddNewVote(
647+
if _, err := consensus.decider().AddNewVote(
647648
quorum.Commit,
648649
[]*bls_cosi.PublicKeyWrapper{key.Pub},
649650
key.Pri.SignHash(commitPayload),
@@ -665,7 +666,7 @@ func (consensus *Consensus) selfCommit(payload []byte) error {
665666
// Method is thread safe.
666667
func (consensus *Consensus) NumSignaturesIncludedInBlock(block *types.Block) uint32 {
667668
count := uint32(0)
668-
members := consensus.decider.Participants()
669+
members := consensus.decider().Participants()
669670
pubKeys := consensus.getPublicKeys()
670671

671672
// TODO(audit): do not reconstruct the Mask

consensus/consensus_v2.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, peer libp2p
8888
case t == msg_pb.MessageType_VIEWCHANGE:
8989
fbftMsg, err = ParseViewChangeMessage(msg)
9090
case t == msg_pb.MessageType_NEWVIEW:
91-
members := consensus.decider.Participants()
91+
members := consensus.decider().Participants()
9292
fbftMsg, err = ParseNewViewMessage(msg, members)
9393
case t == msg_pb.MessageType_LAST_SIGN_POWER:
9494
return nil
@@ -151,7 +151,7 @@ func (consensus *Consensus) finalCommit(waitTime time.Duration, viewID uint64, i
151151
}
152152

153153
func (consensus *Consensus) _finalCommit(isLeader bool) {
154-
numCommits := consensus.decider.SignersCount(quorum.Commit)
154+
numCommits := consensus.decider().SignersCount(quorum.Commit)
155155

156156
consensus.getLogger().Info().
157157
Int64("NumCommits", numCommits).
@@ -478,7 +478,7 @@ func (consensus *Consensus) BlockChannel(newBlock *types.Block) {
478478
Int("numTxs", len(newBlock.Transactions())).
479479
Int("numStakingTxs", len(newBlock.StakingTransactions())).
480480
Time("startTime", startTime).
481-
Int64("publicKeys", consensus.decider.ParticipantsCount()).
481+
Int64("publicKeys", consensus.decider().ParticipantsCount()).
482482
Msg("[ConsensusMainLoop] STARTING CONSENSUS")
483483
consensus.announce(newBlock)
484484
})
@@ -788,18 +788,18 @@ func (consensus *Consensus) rotateLeader(epoch *big.Int, defaultKey *bls.PublicK
788788

789789
for i := 0; i < len(committee.Slots); i++ {
790790
if bc.Config().IsLeaderRotationV2Epoch(epoch) {
791-
wasFound, next = consensus.decider.NthNextValidatorV2(committee.Slots, leader, offset)
791+
wasFound, next = consensus.decider().NthNextValidatorV2(committee.Slots, leader, offset)
792792
} else if bc.Config().IsLeaderRotationExternalValidatorsAllowed(epoch) {
793-
wasFound, next = consensus.decider.NthNextValidator(committee.Slots, leader, offset)
793+
wasFound, next = consensus.decider().NthNextValidator(committee.Slots, leader, offset)
794794
} else {
795-
wasFound, next = consensus.decider.NthNextHmy(shard.Schedule.InstanceForEpoch(epoch), leader, offset)
795+
wasFound, next = consensus.decider().NthNextHmy(shard.Schedule.InstanceForEpoch(epoch), leader, offset)
796796
}
797797
if !wasFound {
798798
consensus.getLogger().Error().Msg("Failed to get next leader")
799799
// Seems like nothing we can do here.
800800
return defaultKey
801801
}
802-
members := consensus.decider.Participants()
802+
members := consensus.decider().Participants()
803803
mask := bls.NewMask(members)
804804
skipped := 0
805805
for i := 0; i < blocksCountAliveness; i++ {

consensus/construct.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (consensus *Consensus) construct(
7979
)
8080
} else {
8181
// TODO: use a persistent bitmap to report bitmap
82-
mask := bls.NewMask(consensus.decider.Participants())
82+
mask := bls.NewMask(consensus.decider().Participants())
8383
for _, key := range priKeys {
8484
mask.SetKey(key.Pub.Bytes, true)
8585
}
@@ -158,7 +158,7 @@ func (consensus *Consensus) construct(
158158
func (consensus *Consensus) constructQuorumSigAndBitmap(p quorum.Phase) []byte {
159159
buffer := bytes.Buffer{}
160160
// 96 bytes aggregated signature
161-
aggSig := consensus.decider.AggregateVotes(p)
161+
aggSig := consensus.decider().AggregateVotes(p)
162162
buffer.Write(aggSig.Serialize())
163163
// Bitmap
164164
if p == quorum.Prepare {

consensus/double_sign.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func (consensus *Consensus) checkDoubleSign(recvMsg *FBFTMessage) bool {
1717
if consensus.couldThisBeADoubleSigner(recvMsg) {
1818
addrSet := map[common.Address]struct{}{}
1919
for _, pubKey2 := range recvMsg.SenderPubkeys {
20-
if alreadyCastBallot := consensus.decider.ReadBallot(
20+
if alreadyCastBallot := consensus.decider().ReadBallot(
2121
quorum.Commit, pubKey2.Bytes,
2222
); alreadyCastBallot != nil {
2323
for _, pubKey1 := range alreadyCastBallot.SignerPubKeys {

0 commit comments

Comments
 (0)