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

Feature/contract to contract update #3412

8 changes: 5 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ workflows:
context:
- slack-secrets
- aws-secrets

#- windows_x64_build

commands:
Expand Down Expand Up @@ -478,11 +477,14 @@ commands:
- attach_workspace:
at: << parameters.build_dir >>
- run:
name: Upload binaries << parameters.platform >>
name: Upload Binaries << parameters.platform >>
command: |
if [ "${CIRCLE_BRANCH}" = "rel/nightly" ]
then
export NO_BUILD="true"
fi
export PATH=$(echo "$PATH" | sed -e "s|:${HOME}/\.go_workspace/bin||g" | sed -e 's|:/usr/local/go/bin||g')
export GOPATH="<< parameters.build_dir >>/go"
export NO_BUILD=true
export TRAVIS_BRANCH=${CIRCLE_BRANCH}
scripts/travis/deploy_packages.sh
- when:
Expand Down
2 changes: 1 addition & 1 deletion agreement/cryptoVerifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func makeUnauthenticatedVote(l Ledger, sender basics.Address, selection *crypto.

m, _ := membership(l, rv.Sender, rv.Round, rv.Period, rv.Step)
cred := committee.MakeCredential(&selection.SK, m.Selector)
ephID := basics.OneTimeIDForRound(rv.Round, voting.KeyDilution(config.Consensus[protocol.ConsensusCurrentVersion]))
ephID := basics.OneTimeIDForRound(rv.Round, voting.KeyDilution(config.Consensus[protocol.ConsensusCurrentVersion].DefaultKeyDilution))
sig := voting.Sign(ephID, rv)

return unauthenticatedVote{
Expand Down
18 changes: 1 addition & 17 deletions agreement/demux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"time"

"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/logging/logspec"
"github.com/algorand/go-algorand/protocol"
Expand Down Expand Up @@ -236,22 +235,7 @@ func (d *demux) next(s *Service, deadline time.Duration, fastDeadline time.Durat

ledgerNextRoundCh := s.Ledger.Wait(nextRound)
deadlineCh := s.Clock.TimeoutAt(deadline)
var fastDeadlineCh <-chan time.Time

fastPartitionRecoveryEnabled := false
if proto, err := d.ledger.ConsensusVersion(ParamsRound(currentRound)); err != nil {
logging.Base().Warnf("demux: could not get consensus parameters for round %d: %v", ParamsRound(currentRound), err)
// this might happen during catchup, since the Ledger.Wait fires as soon as a new block is received by the ledger, which could be
// far before it's being committed. In these cases, it should be safe to default to the current consensus version. On subsequent
// iterations, it will get "corrected" since the ledger would finish flushing the blocks to disk.
fastPartitionRecoveryEnabled = config.Consensus[protocol.ConsensusCurrentVersion].FastPartitionRecovery
} else {
fastPartitionRecoveryEnabled = config.Consensus[proto].FastPartitionRecovery
}

if fastPartitionRecoveryEnabled {
fastDeadlineCh = s.Clock.TimeoutAt(fastDeadline)
}
fastDeadlineCh := s.Clock.TimeoutAt(fastDeadline)

d.UpdateEventsQueue(eventQueueDemux, 0)
d.monitor.dec(demuxCoserviceType)
Expand Down
3 changes: 3 additions & 0 deletions agreement/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type unauthenticatedProposal struct {
OriginalProposer basics.Address `codec:"oprop"`
}

// TransmittedPayload exported for dumping textual versions of messages
type TransmittedPayload = transmittedPayload

// ToBeHashed implements the Hashable interface.
func (p unauthenticatedProposal) ToBeHashed() (protocol.HashID, []byte) {
return protocol.Payload, protocol.Encode(&p)
Expand Down
28 changes: 11 additions & 17 deletions agreement/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ type (
Proposals [2]proposalValue `codec:"props"`
Sigs [2]crypto.OneTimeSignature `codec:"sigs"`
}

// UnauthenticatedVote exported for dumping textual versions of messages
UnauthenticatedVote = unauthenticatedVote
)

// verify verifies that a vote that was received from the network is valid.
Expand Down Expand Up @@ -152,27 +155,18 @@ func makeVote(rv rawVote, voting crypto.OneTimeSigner, selection *crypto.VRFSecr
return unauthenticatedVote{}, fmt.Errorf("makeVote: could not get consensus params for round %d: %v", ParamsRound(rv.Round), err)
}

if proto.FastPartitionRecovery {
switch rv.Step {
case propose, soft, cert, late, redo:
if rv.Proposal == bottom {
logging.Base().Panicf("makeVote: votes from step %d cannot validate bottom", rv.Step)
}
case down:
if rv.Proposal != bottom {
logging.Base().Panicf("makeVote: votes from step %d must validate bottom", rv.Step)
}
switch rv.Step {
case propose, soft, cert, late, redo:
if rv.Proposal == bottom {
logging.Base().Panicf("makeVote: votes from step %d cannot validate bottom", rv.Step)
}
} else {
switch rv.Step {
case propose, soft, cert:
if rv.Proposal == bottom {
logging.Base().Panicf("makeVote: votes from step %d cannot validate bottom", rv.Step)
}
case down:
if rv.Proposal != bottom {
logging.Base().Panicf("makeVote: votes from step %d must validate bottom", rv.Step)
}
}

ephID := basics.OneTimeIDForRound(rv.Round, voting.KeyDilution(proto))
ephID := basics.OneTimeIDForRound(rv.Round, voting.KeyDilution(proto.DefaultKeyDilution))
sig := voting.Sign(ephID, rv)
if (sig == crypto.OneTimeSignature{}) {
return unauthenticatedVote{}, fmt.Errorf("makeVote: got back empty signature for vote")
Expand Down
3 changes: 1 addition & 2 deletions agreement/voteAggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package agreement
import (
"fmt"

"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
)
Expand Down Expand Up @@ -227,7 +226,7 @@ func voteStepFresh(descr string, proto protocol.ConsensusVersion, mine, vote ste
// always propagate first recovery vote to ensure synchronous block of periods after partition
return nil
}
if config.Consensus[proto].FastPartitionRecovery && vote >= late {
if vote >= late {
// always propagate fast partition recovery votes
return nil
}
Expand Down
71 changes: 70 additions & 1 deletion cmd/goal/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ var (
assetURL string
assetName string
assetManager string
assetReserve string
assetClawback string
assetFreezer string
assetNoManager bool
assetNoReserve bool
assetNoFreezer bool
assetNoClawback bool

assetNewManager string
assetNewReserve string
Expand All @@ -64,6 +69,14 @@ func init() {
createAssetCmd.Flags().StringVar(&assetName, "name", "", "Name for the entire asset")
createAssetCmd.Flags().StringVar(&assetURL, "asseturl", "", "URL where user can access more information about the asset (max 32 bytes)")
createAssetCmd.Flags().StringVar(&assetMetadataHashBase64, "assetmetadatab64", "", "base-64 encoded 32-byte commitment to asset metadata")
createAssetCmd.Flags().StringVar(&assetManager, "manager", "", "Manager account that can issue transactions to re-configure or destroy the asset")
createAssetCmd.Flags().StringVar(&assetReserve, "reserve", "", "Reserve account that non-minted assets will reside in")
createAssetCmd.Flags().StringVar(&assetFreezer, "freezer", "", "Freezer account that can freeze or unfreeze the asset holdings for a specific account")
createAssetCmd.Flags().StringVar(&assetClawback, "clawback", "", "Clawback account that is allowed to transfer assets from and to any asset holder")
createAssetCmd.Flags().BoolVar(&assetNoManager, "no-manager", false, "Explicitly declare the lack of manager")
createAssetCmd.Flags().BoolVar(&assetNoReserve, "no-reserve", false, "Explicitly declare the lack of reserve")
createAssetCmd.Flags().BoolVar(&assetNoFreezer, "no-freezer", false, "Explicitly declare the lack of freezer")
createAssetCmd.Flags().BoolVar(&assetNoClawback, "no-clawback", false, "Explicitly declare the lack of clawback")
createAssetCmd.MarkFlagRequired("total")
createAssetCmd.MarkFlagRequired("creator")

Expand Down Expand Up @@ -185,10 +198,66 @@ var createAssetCmd = &cobra.Command{
Run: func(cmd *cobra.Command, _ []string) {
checkTxValidityPeriodCmdFlags(cmd)

if assetManager != "" && assetNoManager {
reportErrorf("The [--manager] flag and the [--no-manager] flag are mutually exclusive, do not provide both flags.")
}

if assetReserve != "" && assetNoReserve {
reportErrorf("The [--reserve] flag and the [--no-reserve] flag are mutually exclusive, do not provide both flags.")
}

if assetFreezer != "" && assetNoFreezer {
reportErrorf("The [--freezer] flag and the [--no-freezer] flag are mutually exclusive, do not provide both flags.")
}

if assetClawback != "" && assetNoClawback {
reportErrorf("The [--clawback] flag and the [--no-clawback] flag are mutually exclusive, do not provide both flags.")
}

dataDir := ensureSingleDataDir()
client := ensureFullClient(dataDir)
accountList := makeAccountsList(dataDir)
creator := accountList.getAddressByName(assetCreator)
manager := creator
reserve := creator
freezer := creator
clawback := creator

if cmd.Flags().Changed("manager") {
assetManager = accountList.getAddressByName(assetManager)
manager = assetManager
}

if assetNoManager {
manager = ""
}

if cmd.Flags().Changed("reserve") {
assetReserve = accountList.getAddressByName(assetReserve)
reserve = assetReserve
}

if assetNoReserve {
reserve = ""
}

if cmd.Flags().Changed("freezer") {
assetFreezer = accountList.getAddressByName(assetFreezer)
freezer = assetFreezer
}

if assetNoFreezer {
freezer = ""
}

if cmd.Flags().Changed("clawback") {
assetClawback = accountList.getAddressByName(assetClawback)
clawback = assetClawback
}

if assetNoClawback {
clawback = ""
}

var err error
var assetMetadataHash []byte
Expand All @@ -199,7 +268,7 @@ var createAssetCmd = &cobra.Command{
}
}

tx, err := client.MakeUnsignedAssetCreateTx(assetTotal, assetFrozen, creator, creator, creator, creator, assetUnitName, assetName, assetURL, assetMetadataHash, assetDecimals)
tx, err := client.MakeUnsignedAssetCreateTx(assetTotal, assetFrozen, manager, reserve, freezer, clawback, assetUnitName, assetName, assetURL, assetMetadataHash, assetDecimals)
if err != nil {
reportErrorf("Cannot construct transaction: %s", err)
}
Expand Down
4 changes: 1 addition & 3 deletions config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ type ConsensusParams struct {
// critical path
AgreementFilterTimeoutPeriod0 time.Duration

FastRecoveryLambda time.Duration // time between fast recovery attempts
FastPartitionRecovery bool // set when fast partition recovery is enabled
FastRecoveryLambda time.Duration // time between fast recovery attempts

// how to commit to the payset: flat or merkle tree
PaysetCommit PaysetCommitType
Expand Down Expand Up @@ -711,7 +710,6 @@ func initConsensusProtocols() {

// v10 introduces fast partition recovery (and also raises NumProposers).
v10 := v9
v10.FastPartitionRecovery = true
v10.NumProposers = 20
v10.LateCommitteeSize = 500
v10.LateCommitteeThreshold = 320
Expand Down
8 changes: 3 additions & 5 deletions crypto/onetimesig.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import (
"encoding/binary"
"fmt"

"github.com/algorand/go-deadlock"

"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-deadlock"
)

// A OneTimeSignature is a cryptographic signature that is produced a limited
Expand Down Expand Up @@ -432,10 +430,10 @@ type OneTimeSigner struct {
}

// KeyDilution returns the appropriate key dilution value for a OneTimeSigner.
func (ots OneTimeSigner) KeyDilution(params config.ConsensusParams) uint64 {
func (ots OneTimeSigner) KeyDilution(defaultKeyDilution uint64) uint64 {
if ots.OptionalKeyDilution != 0 {
return ots.OptionalKeyDilution
}

return params.DefaultKeyDilution
return defaultKeyDilution
}
16 changes: 8 additions & 8 deletions data/abi/abi_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ func encodeInt(intValue interface{}, bitSize uint16) ([]byte, error) {
return nil, fmt.Errorf("passed in numeric value should be non negative")
}

bytes := bigInt.Bytes()
if len(bytes) > int(bitSize/8) {
return nil, fmt.Errorf("input value bit size %d > abi type bit size %d", len(bytes)*8, bitSize)
castedBytes := make([]byte, bitSize/8)

if bigInt.Cmp(new(big.Int).Lsh(big.NewInt(1), uint(bitSize))) >= 0 {
return nil, fmt.Errorf("input value bit size %d > abi type bit size %d", bigInt.BitLen(), bitSize)
}

zeroPadding := make([]byte, bitSize/8-uint16(len(bytes)))
buffer := append(zeroPadding, bytes...)
return buffer, nil
bigInt.FillBytes(castedBytes)
return castedBytes, nil
}

// inferToSlice infers an interface element to a slice of interface{}, returns error if it cannot infer successfully
Expand All @@ -201,7 +201,7 @@ func inferToSlice(value interface{}) ([]interface{}, error) {

// encodeTuple encodes slice-of-interface of golang values to bytes, following ABI encoding rules
func encodeTuple(value interface{}, childT []Type) ([]byte, error) {
if len(childT) >= (1 << 16) {
if len(childT) >= abiEncodingLengthLimit {
return nil, fmt.Errorf("abi child type number exceeds uint16 maximum")
}
values, err := inferToSlice(value)
Expand Down Expand Up @@ -277,7 +277,7 @@ func encodeTuple(value interface{}, childT []Type) ([]byte, error) {
if isDynamicIndex[i] {
// calculate where the index of dynamic value encoding byte start
headValue := headLength + tailCurrLength
if headValue >= (1 << 16) {
if headValue >= abiEncodingLengthLimit {
return nil, fmt.Errorf("cannot encode abi tuple: encode length exceeds uint16 maximum")
}
binary.BigEndian.PutUint16(heads[i], uint16(headValue))
Expand Down
Loading