Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to add custom consensus in conduit and indexer #625

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fcc30ce
Merge branch 'release/v2.3.0'
Algo-devops-service Sep 18, 2023
5fd2c1c
Merge branch 'release/v2.4.0'
Algo-devops-service Dec 15, 2023
479719b
PreloadConfigurableConsensusProtocols sdk
scholtz Jan 6, 2024
6d06ab2
os functions
scholtz Jan 6, 2024
7c38063
Fix: Fix indexer sync issue in cucumber tests (#628)
jasonpaulos Feb 27, 2024
c31a3b8
Bump go version for builds/workflows to 1.20.14. (#629)
gmalouf Mar 7, 2024
2a7a407
Incentives: Add fields in block header for proposer and fees collecte…
jannotti Apr 24, 2024
b28ed19
chore: fix function names (#632)
tianzedavid May 1, 2024
89b33c0
Regenerate code from specification file (#631)
github-actions[bot] May 1, 2024
d34226c
Fix funding for cucumber tests by rotating sender accounts (#630)
jasonpaulos May 8, 2024
51d8a8f
Build: Bump golang version to 1.21.10 (#636)
gmalouf May 8, 2024
a651ced
bump up version to v2.5.0
gmalouf May 8, 2024
eabc0bf
Regenerate code from specification file (#635)
github-actions[bot] May 15, 2024
049734f
Regenerate code from specification file (#640)
github-actions[bot] May 16, 2024
d3b2c94
Regenerate code from specification file (#641)
github-actions[bot] May 23, 2024
6c2a3e8
Enable min-balance tests for indexer and algod APIs. (#642)
gmalouf Jun 3, 2024
5e95fc1
bump up version to v2.6.0
gmalouf Jun 5, 2024
221c8bd
Update .test-env to use Cucumber specs from master (#645)
gmalouf Jun 5, 2024
b84250a
Bump gopkg.in/yaml.v3 from 3.0.0-20200313102051-9f266ea9e77c to 3.0.0…
dependabot[bot] Jun 5, 2024
40f6b15
build(deps): bump golang.org/x/crypto (#646)
dependabot[bot] Jun 12, 2024
002f5ea
Regenerate code from specification file (#647)
github-actions[bot] Jun 25, 2024
966d6c3
rebase (#2)
scholtz Sep 15, 2024
4cd687c
Merge branch 'algorand:develop' into v2.4.1
scholtz Sep 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion protocol/config/consensus.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package config

import (
"encoding/json"
"time"

"os"
"path/filepath"
"github.com/algorand/go-algorand-sdk/v2/protocol"
)

const ConfigurableConsensusProtocolsFilename = "consensus.json"

// ConsensusParams specifies settings that might vary based on the
// particular version of the consensus protocol.
type ConsensusParams struct {
Expand Down Expand Up @@ -818,6 +822,56 @@ func (cp ConsensusProtocols) Merge(configurableConsensus ConsensusProtocols) Con
return staticConsensus
}


// LoadConfigurableConsensusProtocols loads the configurable protocols from the data directory
func LoadConfigurableConsensusProtocols(dataDirectory string) error {
newConsensus, err := PreloadConfigurableConsensusProtocols(dataDirectory)
if err != nil {
return err
}
if newConsensus != nil {
SetConfigurableConsensusProtocols(newConsensus)
}
return nil
}

// SetConfigurableConsensusProtocols sets the configurable protocols.
func SetConfigurableConsensusProtocols(newConsensus ConsensusProtocols) ConsensusProtocols {
oldConsensus := Consensus
Consensus = newConsensus
// Set allocation limits
for _, p := range Consensus {
checkSetAllocBounds(p)
}
return oldConsensus
}

// https://github.com/algorand/go-algorand/blob/21eec2d39b4ac93d66f9e930e7b07d45f8248c24/config/consensus.go#L787
// PreloadConfigurableConsensusProtocols loads the configurable protocols from the data directory
// and merge it with a copy of the Consensus map. Then, it returns it to the caller.
func PreloadConfigurableConsensusProtocols(dataDirectory string) (ConsensusProtocols, error) {
consensusProtocolPath := filepath.Join(dataDirectory, ConfigurableConsensusProtocolsFilename)
file, err := os.Open(consensusProtocolPath)

if err != nil {
if os.IsNotExist(err) {
// this file is not required, only optional. if it's missing, no harm is done.
return Consensus, nil
}
return nil, err
}
defer file.Close()

configurableConsensus := make(ConsensusProtocols)

decoder := json.NewDecoder(file)
err = decoder.Decode(&configurableConsensus)
if err != nil {
return nil, err
}
return Consensus.Merge(configurableConsensus), nil
}

// initConsensusProtocols defines the consensus protocol values and how values change across different versions of the protocol.
//
// These are the only valid and tested consensus values and transitions. Other settings are not tested and may lead to unexpected behavior.
Expand Down
Loading