diff --git a/cmd/goal/clerk.go b/cmd/goal/clerk.go index 594ddf38f5..f229247541 100644 --- a/cmd/goal/clerk.go +++ b/cmd/goal/clerk.go @@ -359,7 +359,11 @@ var inspectCmd = &cobra.Command{ if err != nil { reportErrorf(txDecodeError, txFilename, err) } - fmt.Printf("%s[%d]\n%s\n\n", txFilename, count, string(protocol.EncodeJSON(txn))) + sti, err := inspectTxn(txn) + if err != nil { + reportErrorf(txDecodeError, txFilename, err) + } + fmt.Printf("%s[%d]\n%s\n\n", txFilename, count, string(protocol.EncodeJSON(sti))) } } }, diff --git a/cmd/goal/inspect.go b/cmd/goal/inspect.go new file mode 100644 index 0000000000..5024c27338 --- /dev/null +++ b/cmd/goal/inspect.go @@ -0,0 +1,116 @@ +// Copyright (C) 2019 Algorand, Inc. +// This file is part of go-algorand +// +// go-algorand is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// go-algorand is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with go-algorand. If not, see . + +package main + +import ( + "fmt" + "reflect" + + "github.com/algorand/go-algorand/crypto" + "github.com/algorand/go-algorand/data/basics" + "github.com/algorand/go-algorand/data/transactions" + "github.com/algorand/go-algorand/protocol" +) + +// inspectSignedTxn is isomorphic to SignedTxn but uses different +// types to print public keys using algorand's address format +// (base32 + checksum) in JSON, instead of the default base64. +type inspectSignedTxn struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + + Sig crypto.Signature `codec:"sig"` + Msig inspectMultisigSig `codec:"msig"` + Txn transactions.Transaction `codec:"txn"` +} + +// inspectMultisigSig is isomorphic to MultisigSig but uses different +// types to print public keys using algorand's address format in JSON. +type inspectMultisigSig struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + + Version uint8 `codec:"v"` + Threshold uint8 `codec:"thr"` + Subsigs []inspectMultisigSubsig `codec:"subsig"` +} + +// inspectMultisigSig is isomorphic to MultisigSig but uses different +// types to print public keys using algorand's address format in JSON. +type inspectMultisigSubsig struct { + _struct struct{} `codec:",omitempty,omitemptyarray"` + + Key basics.Address `codec:"pk"` + Sig crypto.Signature `codec:"s"` +} + +func inspectTxn(stxn transactions.SignedTxn) (sti inspectSignedTxn, err error) { + sti = txnToInspect(stxn) + if !reflect.DeepEqual(stxn, txnFromInspect(sti)) { + err = fmt.Errorf("non-idempotent transformation to inspectSignedTxn (DeepEqual)") + } + if !reflect.DeepEqual(protocol.Encode(sti), protocol.Encode(stxn)) { + err = fmt.Errorf("non-idempotent transformation to inspectSignedTxn (protocol.Encode)") + } + return +} + +func txnToInspect(stxn transactions.SignedTxn) inspectSignedTxn { + return inspectSignedTxn{ + Txn: stxn.Txn, + Sig: stxn.Sig, + Msig: msigToInspect(stxn.Msig), + } +} + +func txnFromInspect(sti inspectSignedTxn) transactions.SignedTxn { + return transactions.SignedTxn{ + Txn: sti.Txn, + Sig: sti.Sig, + Msig: msigFromInspect(sti.Msig), + } +} + +func msigToInspect(msig crypto.MultisigSig) inspectMultisigSig { + res := inspectMultisigSig{ + Version: msig.Version, + Threshold: msig.Threshold, + } + + for _, subsig := range msig.Subsigs { + res.Subsigs = append(res.Subsigs, inspectMultisigSubsig{ + Sig: subsig.Sig, + Key: basics.Address(subsig.Key), + }) + } + + return res +} + +func msigFromInspect(msi inspectMultisigSig) crypto.MultisigSig { + res := crypto.MultisigSig{ + Version: msi.Version, + Threshold: msi.Threshold, + } + + for _, subsig := range msi.Subsigs { + res.Subsigs = append(res.Subsigs, crypto.MultisigSubsig{ + Sig: subsig.Sig, + Key: crypto.PublicKey(subsig.Key), + }) + } + + return res +} diff --git a/cmd/updater/update.sh b/cmd/updater/update.sh index b26d286709..7ed7aeaa3e 100755 --- a/cmd/updater/update.sh +++ b/cmd/updater/update.sh @@ -76,7 +76,7 @@ while [ "$1" != "" ]; do -g) shift GENESIS_NETWORK_DIR=$1 - GENESIS_NETWORK_DIR_SPEC=-g $1 + GENESIS_NETWORK_DIR_SPEC="-g $1" ;; -b) shift @@ -330,7 +330,7 @@ function copy_genesis_files() { function check_for_new_ledger() { CURDATADIR=$1 echo "Checking for new ledger in ${CURDATADIR}" - EXISTING_VER="$(head -n 1 ${CURDATADIR}/wallet-genesis.id)" + EXISTING_VER=$(${UPDATESRCDIR}/bin/algod -d ${CURDATADIR} -g ${CURDATADIR}/genesis.json -G) if [ -z $EXISTING_VER ]; then if [ -z ${GENESIS_NETWORK_DIR} ]; then @@ -359,10 +359,10 @@ function check_for_new_ledger() { # changed the file itself in a compatible way. cp ${UPDATESRCDIR}/genesis/${GENESIS_NETWORK_DIR}/genesis.json ${CURDATADIR} + echo ${NEW_VER} > ${CURDATADIR}/wallet-genesis.id if [ "${NEW_VER}" != "${EXISTING_VER}" ]; then echo "New genesis ID, resetting wallets" NEW_LEDGER=1 - echo ${NEW_VER} > ${CURDATADIR}/wallet-genesis.id reset_wallets_for_new_ledger ${CURDATADIR} import_rootkeys ${CURDATADIR} diff --git a/installer/debian/conffiles b/installer/debian/conffiles new file mode 100644 index 0000000000..4aa4aa1622 --- /dev/null +++ b/installer/debian/conffiles @@ -0,0 +1,2 @@ +/etc/apt/apt.conf.d/50algorand-upgrades +/var/lib/algorand/genesis.json diff --git a/installer/rpm/RPM-GPG-KEY-Algorand b/installer/rpm/RPM-GPG-KEY-Algorand index e69de29bb2..71d2149c0a 100644 --- a/installer/rpm/RPM-GPG-KEY-Algorand +++ b/installer/rpm/RPM-GPG-KEY-Algorand @@ -0,0 +1,30 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQENBF0BeeQBCADIUu66SGiqaFFcKY18unyFGvq2VU/uoHUiKbMsagvbHxggXeMk +x6t4E1XJ89wmoQJNuxVGGNSaCtdEh65+l5XRrzKJUDb/9CLuf2dvVLWq0sZAo48z +3KW8Si1yrh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yiG73A40bP988e3QE3M2Tuz0Ei2j +09x1ABEBAAGJATwEGAEIACYWIQQTk8G1ae02MJH9u2YimZ7Zkai6QQUCXQF55AIb +DAUJA8JnAAAKCRAimZ7Zkai6QT6bCACdnrW9Sp2LyfHLKNb3j/WOWX15r8vCcjdG +Xn8bVkwB2KApsICSnW9xtQPBMfoQwlAFcJuaIFcEIl0TyWRamLdRFh+773IKoQgw +YZ0WDx6sNnUB/e9aCuio1kAxmfEXWvEWu7JLN4J5FFmgzJs2JYNSeBRm4kbPjwe/ +zKdBBMK05ND348Jnduj1kZ6fwWKWIue3+nIVUCxyZao5dRp6zhEPtN5gDFpc18uT +kXNB/j0KjwzFUOB3u1ioOMxfbiga9B2fJZO/OSsm+3S4AGNCrn96hRCHnsgPehGT +AZEyE+M1SYulIyylMIcWwOVWUSKxmeSR20g1H83wWZqNpYmdgY24 +=gLD6 +-----END PGP PUBLIC KEY BLOCK----- diff --git a/installer/rpm/algorand.repo b/installer/rpm/algorand.repo index 48a895eeec..c2ecc032c9 100644 --- a/installer/rpm/algorand.repo +++ b/installer/rpm/algorand.repo @@ -3,4 +3,4 @@ name=Algorand baseurl=http://algorand-releases.s3-website-us-east-1.amazonaws.com/rpm/stable/ enabled=1 gpgcheck=1 -gpgkey=http://algorand-releases.s3-website-us-east-1.amazonaws.com/key.pub +gpgkey=https://releases.algorand.com/rpm/rpm_algorand.pub diff --git a/installer/rpm/algorand.spec b/installer/rpm/algorand.spec index 60e839f24c..35537ac137 100644 --- a/installer/rpm/algorand.spec +++ b/installer/rpm/algorand.spec @@ -77,15 +77,15 @@ fi /usr/bin/goal /var/lib/algorand/config.json.example /var/lib/algorand/system.json -/var/lib/algorand/genesis.json +%config(noreplace) /var/lib/algorand/genesis.json %if %{RELEASE_GENESIS_PROCESS} != "x" /var/lib/algorand/genesis/devnet/genesis.json /var/lib/algorand/genesis/testnet/genesis.json /var/lib/algorand/genesis/mainnet/genesis.json %endif /lib/systemd/system/algorand.service -/etc/cron.hourly/0yum-algorand-hourly.cron -/etc/yum/yum-cron-algorand.conf +%config(noreplace) /etc/cron.hourly/0yum-algorand-hourly.cron +%config(noreplace) /etc/yum/yum-cron-algorand.conf /etc/pki/rpm-gpg/RPM-GPG-KEY-Algorand /usr/lib/algorand/yum.repos.d/algorand.repo diff --git a/scripts/build_deb.sh b/scripts/build_deb.sh index 7c743d0cef..a125b2b26e 100755 --- a/scripts/build_deb.sh +++ b/scripts/build_deb.sh @@ -101,7 +101,7 @@ for f in "${unattended_upgrades_files[@]}"; do done mkdir -p ${PKG_ROOT}/DEBIAN -debian_files=("control" "postinst" "prerm" "postrm") +debian_files=("control" "postinst" "prerm" "postrm" "conffiles") for ctl in "${debian_files[@]}"; do # Copy first, to preserve permissions, then overwrite to fill in template. cp -a installer/debian/${ctl} ${PKG_ROOT}/DEBIAN/${ctl}